repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
TkTech/Jawa
jawa/util/flags.py
https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/util/flags.py#L40-L46
def set(self, name, value): """ Sets the value of the field `name` to `value`, which is `True` or `False`. """ flag = self.flags[name] self._value = (self.value | flag) if value else (self.value & ~flag)
[ "def", "set", "(", "self", ",", "name", ",", "value", ")", ":", "flag", "=", "self", ".", "flags", "[", "name", "]", "self", ".", "_value", "=", "(", "self", ".", "value", "|", "flag", ")", "if", "value", "else", "(", "self", ".", "value", "&",...
Sets the value of the field `name` to `value`, which is `True` or `False`.
[ "Sets", "the", "value", "of", "the", "field", "name", "to", "value", "which", "is", "True", "or", "False", "." ]
python
train
timothyb0912/pylogit
pylogit/pylogit.py
https://github.com/timothyb0912/pylogit/blob/f83b0fd6debaa7358d87c3828428f6d4ead71357/pylogit/pylogit.py#L83-L225
def create_choice_model(data, alt_id_col, obs_id_col, choice_col, specification, model_type, intercept_ref_pos=None, shape_ref_pos=None, ...
[ "def", "create_choice_model", "(", "data", ",", "alt_id_col", ",", "obs_id_col", ",", "choice_col", ",", "specification", ",", "model_type", ",", "intercept_ref_pos", "=", "None", ",", "shape_ref_pos", "=", "None", ",", "names", "=", "None", ",", "intercept_name...
Parameters ---------- data : string or pandas dataframe. If `data` is a string, it should be an absolute or relative path to a CSV file containing the long format data for this choice model. Note long format has one row per available alternative for each observation. If `data` is...
[ "Parameters", "----------", "data", ":", "string", "or", "pandas", "dataframe", ".", "If", "data", "is", "a", "string", "it", "should", "be", "an", "absolute", "or", "relative", "path", "to", "a", "CSV", "file", "containing", "the", "long", "format", "data...
python
train
gwastro/pycbc
pycbc/workflow/pegasus_workflow.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/workflow/pegasus_workflow.py#L141-L149
def add_raw_arg(self, arg): """ Add an argument to the command line of this job, but do *NOT* add white space between arguments. This can be added manually by adding ' ' if needed """ if not isinstance(arg, File): arg = str(arg) self._raw_options += [...
[ "def", "add_raw_arg", "(", "self", ",", "arg", ")", ":", "if", "not", "isinstance", "(", "arg", ",", "File", ")", ":", "arg", "=", "str", "(", "arg", ")", "self", ".", "_raw_options", "+=", "[", "arg", "]" ]
Add an argument to the command line of this job, but do *NOT* add white space between arguments. This can be added manually by adding ' ' if needed
[ "Add", "an", "argument", "to", "the", "command", "line", "of", "this", "job", "but", "do", "*", "NOT", "*", "add", "white", "space", "between", "arguments", ".", "This", "can", "be", "added", "manually", "by", "adding", "if", "needed" ]
python
train
gwpy/gwpy
gwpy/types/array.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/types/array.py#L441-L474
def flatten(self, order='C'): """Return a copy of the array collapsed into one dimension. Any index information is removed as part of the flattening, and the result is returned as a `~astropy.units.Quantity` array. Parameters ---------- order : {'C', 'F', 'A', 'K'}, opt...
[ "def", "flatten", "(", "self", ",", "order", "=", "'C'", ")", ":", "return", "super", "(", "Array", ",", "self", ")", ".", "flatten", "(", "order", "=", "order", ")", ".", "view", "(", "Quantity", ")" ]
Return a copy of the array collapsed into one dimension. Any index information is removed as part of the flattening, and the result is returned as a `~astropy.units.Quantity` array. Parameters ---------- order : {'C', 'F', 'A', 'K'}, optional 'C' means to flatten in...
[ "Return", "a", "copy", "of", "the", "array", "collapsed", "into", "one", "dimension", "." ]
python
train
saltstack/salt
salt/modules/inspectlib/fsdb.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/inspectlib/fsdb.py#L231-L255
def delete(self, obj, matches=None, mt=None, lt=None, eq=None): ''' Delete object from the database. :param obj: :param matches: :param mt: :param lt: :param eq: :return: ''' deleted = False objects = list() for _obj in sel...
[ "def", "delete", "(", "self", ",", "obj", ",", "matches", "=", "None", ",", "mt", "=", "None", ",", "lt", "=", "None", ",", "eq", "=", "None", ")", ":", "deleted", "=", "False", "objects", "=", "list", "(", ")", "for", "_obj", "in", "self", "."...
Delete object from the database. :param obj: :param matches: :param mt: :param lt: :param eq: :return:
[ "Delete", "object", "from", "the", "database", "." ]
python
train
trevisanj/a99
a99/fileio.py
https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/fileio.py#L206-L222
def create_symlink(source, link_name): """ Creates symbolic link for either operating system. http://stackoverflow.com/questions/6260149/os-symlink-support-in-windows """ os_symlink = getattr(os, "symlink", None) if isinstance(os_symlink, collections.Callable): os_symlink(source...
[ "def", "create_symlink", "(", "source", ",", "link_name", ")", ":", "os_symlink", "=", "getattr", "(", "os", ",", "\"symlink\"", ",", "None", ")", "if", "isinstance", "(", "os_symlink", ",", "collections", ".", "Callable", ")", ":", "os_symlink", "(", "sou...
Creates symbolic link for either operating system. http://stackoverflow.com/questions/6260149/os-symlink-support-in-windows
[ "Creates", "symbolic", "link", "for", "either", "operating", "system", ".", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "6260149", "/", "os", "-", "symlink", "-", "support", "-", "in", "-", "windows" ]
python
train
DemocracyClub/uk-election-ids
uk_election_ids/election_ids.py
https://github.com/DemocracyClub/uk-election-ids/blob/566895e15b539e8a7fa3bebb680d5cd326cf6b6b/uk_election_ids/election_ids.py#L62-L78
def with_subtype(self, subtype): """Add a subtype segment Args: subtype (str): May be one of ``['a', 'c', 'r']``. See the `Reference Definition <https://elections.democracyclub.org.uk/reference_definition>`_. for valid election type/subtype combinations. ...
[ "def", "with_subtype", "(", "self", ",", "subtype", ")", ":", "self", ".", "_validate_subtype", "(", "subtype", ")", "self", ".", "subtype", "=", "subtype", "return", "self" ]
Add a subtype segment Args: subtype (str): May be one of ``['a', 'c', 'r']``. See the `Reference Definition <https://elections.democracyclub.org.uk/reference_definition>`_. for valid election type/subtype combinations. Returns: IdBuilder ...
[ "Add", "a", "subtype", "segment" ]
python
train
ppinard/matplotlib-scalebar
matplotlib_scalebar/dimension.py
https://github.com/ppinard/matplotlib-scalebar/blob/ba8ca4df7d5a4efc43a394e4fe88b8e5e517abf4/matplotlib_scalebar/dimension.py#L29-L50
def add_units(self, units, factor, latexrepr=None): """ Add new possible units. :arg units: units :type units: :class:`str` :arg factor: multiplication factor to convert new units into base units :type factor: :class:`float` :arg latexr...
[ "def", "add_units", "(", "self", ",", "units", ",", "factor", ",", "latexrepr", "=", "None", ")", ":", "if", "units", "in", "self", ".", "_units", ":", "raise", "ValueError", "(", "'%s already defined'", "%", "units", ")", "if", "factor", "==", "1", ":...
Add new possible units. :arg units: units :type units: :class:`str` :arg factor: multiplication factor to convert new units into base units :type factor: :class:`float` :arg latexrepr: LaTeX representation of units (if ``None``, use *units) :ty...
[ "Add", "new", "possible", "units", ".", ":", "arg", "units", ":", "units", ":", "type", "units", ":", ":", "class", ":", "str", ":", "arg", "factor", ":", "multiplication", "factor", "to", "convert", "new", "units", "into", "base", "units", ":", "type"...
python
train
ontio/ontology-python-sdk
ontology/io/binary_reader.py
https://github.com/ontio/ontology-python-sdk/blob/ac88bdda941896c5d2ced08422a9c5179d3f9b19/ontology/io/binary_reader.py#L335-L358
def read_serializable_array(self, class_name, max_size=sys.maxsize): """ Deserialize a stream into the object specific by `class_name`. Args: class_name (str): a full path to the class to be deserialized into. e.g. 'neo.Core.Block.Block' max_size (int): (Optional) maximu...
[ "def", "read_serializable_array", "(", "self", ",", "class_name", ",", "max_size", "=", "sys", ".", "maxsize", ")", ":", "module", "=", "'.'", ".", "join", "(", "class_name", ".", "split", "(", "'.'", ")", "[", ":", "-", "1", "]", ")", "class_name", ...
Deserialize a stream into the object specific by `class_name`. Args: class_name (str): a full path to the class to be deserialized into. e.g. 'neo.Core.Block.Block' max_size (int): (Optional) maximum number of bytes to read. Returns: list: list of `class_name` objec...
[ "Deserialize", "a", "stream", "into", "the", "object", "specific", "by", "class_name", "." ]
python
train
lemieuxl/pyGenClean
pyGenClean/run_data_clean_up.py
https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/run_data_clean_up.py#L270-L493
def run_duplicated_samples(in_prefix, in_type, out_prefix, base_dir, options): """Runs step1 (duplicated samples). :param in_prefix: the prefix of the input files. :param in_type: the type of the input files. :param out_prefix: the output prefix. :param base_dir: the output directory. :param op...
[ "def", "run_duplicated_samples", "(", "in_prefix", ",", "in_type", ",", "out_prefix", ",", "base_dir", ",", "options", ")", ":", "# Creating the output directory", "os", ".", "mkdir", "(", "out_prefix", ")", "# We know we need tfile", "required_type", "=", "\"tfile\""...
Runs step1 (duplicated samples). :param in_prefix: the prefix of the input files. :param in_type: the type of the input files. :param out_prefix: the output prefix. :param base_dir: the output directory. :param options: the options needed. :type in_prefix: str :type in_type: str :type ...
[ "Runs", "step1", "(", "duplicated", "samples", ")", "." ]
python
train
mitsei/dlkit
dlkit/handcar/repository/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/repository/managers.py#L815-L845
def get_asset_admin_session_for_repository(self, repository_id=None, *args, **kwargs): """Gets an asset administration session for the given repository. arg: repository_id (osid.id.Id): the Id of the repository return: (osid.repository.AssetAdminSession) - an AssetAdminSessio...
[ "def", "get_asset_admin_session_for_repository", "(", "self", ",", "repository_id", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "repository_id", ":", "raise", "NullArgument", "(", ")", "if", "not", "self", ".", "supports_as...
Gets an asset administration session for the given repository. arg: repository_id (osid.id.Id): the Id of the repository return: (osid.repository.AssetAdminSession) - an AssetAdminSession raise: NotFound - repository_id not found raise: NullArgument - repository_id ...
[ "Gets", "an", "asset", "administration", "session", "for", "the", "given", "repository", "." ]
python
train
acutesoftware/AIKIF
aikif/cls_file_mapping.py
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/cls_file_mapping.py#L27-L39
def load_data_subject_areas(subject_file): """ reads the subject file to a list, to confirm config is setup """ lst = [] if os.path.exists(subject_file): with open(subject_file, 'r') as f: for line in f: lst.append(line.strip()) else: print('MISSING DA...
[ "def", "load_data_subject_areas", "(", "subject_file", ")", ":", "lst", "=", "[", "]", "if", "os", ".", "path", ".", "exists", "(", "subject_file", ")", ":", "with", "open", "(", "subject_file", ",", "'r'", ")", "as", "f", ":", "for", "line", "in", "...
reads the subject file to a list, to confirm config is setup
[ "reads", "the", "subject", "file", "to", "a", "list", "to", "confirm", "config", "is", "setup" ]
python
train
tchellomello/python-amcrest
src/amcrest/system.py
https://github.com/tchellomello/python-amcrest/blob/ed842139e234de2eaf6ee8fb480214711cde1249/src/amcrest/system.py#L26-L45
def current_time(self, date): """ According with API: The time format is "Y-M-D H-m-S". It is not be effected by Locales. TimeFormat in SetLocalesConfig Params: date = "Y-M-D H-m-S" Example: 2016-10-28 13:48:00 Return: True """ ...
[ "def", "current_time", "(", "self", ",", "date", ")", ":", "ret", "=", "self", ".", "command", "(", "'global.cgi?action=setCurrentTime&time={0}'", ".", "format", "(", "date", ")", ")", "if", "\"ok\"", "in", "ret", ".", "content", ".", "decode", "(", "'utf-...
According with API: The time format is "Y-M-D H-m-S". It is not be effected by Locales. TimeFormat in SetLocalesConfig Params: date = "Y-M-D H-m-S" Example: 2016-10-28 13:48:00 Return: True
[ "According", "with", "API", ":", "The", "time", "format", "is", "Y", "-", "M", "-", "D", "H", "-", "m", "-", "S", ".", "It", "is", "not", "be", "effected", "by", "Locales", ".", "TimeFormat", "in", "SetLocalesConfig" ]
python
train
neo4j-drivers/neobolt
neobolt/impl/python/routing.py
https://github.com/neo4j-drivers/neobolt/blob/724569d76e85777c4f5e30e8d0a18116bda4d8cd/neobolt/impl/python/routing.py#L222-L260
def fetch_routing_info(self, address): """ Fetch raw routing info from a given router address. :param address: router address :return: list of routing records or None if no connection could be established :raise ServiceUnavailable: if the server does not support routing...
[ "def", "fetch_routing_info", "(", "self", ",", "address", ")", ":", "metadata", "=", "{", "}", "records", "=", "[", "]", "def", "fail", "(", "md", ")", ":", "if", "md", ".", "get", "(", "\"code\"", ")", "==", "\"Neo.ClientError.Procedure.ProcedureNotFound\...
Fetch raw routing info from a given router address. :param address: router address :return: list of routing records or None if no connection could be established :raise ServiceUnavailable: if the server does not support routing or if routing s...
[ "Fetch", "raw", "routing", "info", "from", "a", "given", "router", "address", "." ]
python
train
tensorflow/tensor2tensor
tensor2tensor/utils/yellowfin.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/yellowfin.py#L398-L408
def _get_mu_tensor(self): """Get the min mu which minimize the surrogate. Returns: The mu_t. """ root = self._get_cubic_root() dr = self._h_max / self._h_min mu = tf.maximum( root**2, ((tf.sqrt(dr) - 1) / (tf.sqrt(dr) + 1))**2) return mu
[ "def", "_get_mu_tensor", "(", "self", ")", ":", "root", "=", "self", ".", "_get_cubic_root", "(", ")", "dr", "=", "self", ".", "_h_max", "/", "self", ".", "_h_min", "mu", "=", "tf", ".", "maximum", "(", "root", "**", "2", ",", "(", "(", "tf", "."...
Get the min mu which minimize the surrogate. Returns: The mu_t.
[ "Get", "the", "min", "mu", "which", "minimize", "the", "surrogate", "." ]
python
train
thombashi/DataProperty
examples/py/to_column_dp_list.py
https://github.com/thombashi/DataProperty/blob/1d1a4c6abee87264c2f870a932c0194895d80a18/examples/py/to_column_dp_list.py#L16-L24
def display_col_dp(dp_list, attr_name): """ show a value assocciated with an attribute for each DataProperty instance in the dp_list """ print() print("---------- {:s} ----------".format(attr_name)) print([getattr(dp, attr_name) for dp in dp_list])
[ "def", "display_col_dp", "(", "dp_list", ",", "attr_name", ")", ":", "print", "(", ")", "print", "(", "\"---------- {:s} ----------\"", ".", "format", "(", "attr_name", ")", ")", "print", "(", "[", "getattr", "(", "dp", ",", "attr_name", ")", "for", "dp", ...
show a value assocciated with an attribute for each DataProperty instance in the dp_list
[ "show", "a", "value", "assocciated", "with", "an", "attribute", "for", "each", "DataProperty", "instance", "in", "the", "dp_list" ]
python
train
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#L122-L134
def maps_get_rules_output_rules_value(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, "ru...
[ "def", "maps_get_rules_output_rules_value", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "maps_get_rules", "=", "ET", ".", "Element", "(", "\"maps_get_rules\"", ")", "config", "=", "maps_get_rules...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
svartalf/python-2gis
dgis/__init__.py
https://github.com/svartalf/python-2gis/blob/6eccd6073c99494b7abf20b38a5455cbd55d6420/dgis/__init__.py#L62-L82
def search(self, **kwargs): """Firms search http://api.2gis.ru/doc/firms/searches/search/ """ point = kwargs.pop('point', False) if point: kwargs['point'] = '%s,%s' % (point[0], point[1]) bound = kwargs.pop('bound', False) if bound: kwar...
[ "def", "search", "(", "self", ",", "*", "*", "kwargs", ")", ":", "point", "=", "kwargs", ".", "pop", "(", "'point'", ",", "False", ")", "if", "point", ":", "kwargs", "[", "'point'", "]", "=", "'%s,%s'", "%", "(", "point", "[", "0", "]", ",", "p...
Firms search http://api.2gis.ru/doc/firms/searches/search/
[ "Firms", "search" ]
python
train
joshspeagle/dynesty
dynesty/dynamicsampler.py
https://github.com/joshspeagle/dynesty/blob/9e482aafeb5cf84bedb896fa6f07a761d917983e/dynesty/dynamicsampler.py#L62-L151
def weight_function(results, args=None, return_weights=False): """ The default weight function utilized by :class:`DynamicSampler`. Zipped parameters are passed to the function via :data:`args`. Assigns each point a weight based on a weighted average of the posterior and evidence information content...
[ "def", "weight_function", "(", "results", ",", "args", "=", "None", ",", "return_weights", "=", "False", ")", ":", "# Initialize hyperparameters.", "if", "args", "is", "None", ":", "args", "=", "dict", "(", "{", "}", ")", "pfrac", "=", "args", ".", "get"...
The default weight function utilized by :class:`DynamicSampler`. Zipped parameters are passed to the function via :data:`args`. Assigns each point a weight based on a weighted average of the posterior and evidence information content:: weight = pfrac * pweight + (1. - pfrac) * zweight where `p...
[ "The", "default", "weight", "function", "utilized", "by", ":", "class", ":", "DynamicSampler", ".", "Zipped", "parameters", "are", "passed", "to", "the", "function", "via", ":", "data", ":", "args", ".", "Assigns", "each", "point", "a", "weight", "based", ...
python
train
pypa/pipenv
pipenv/vendor/passa/models/lockers.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/models/lockers.py#L124-L163
def lock(self): """Lock specified (abstract) requirements into (concrete) candidates. The locking procedure consists of four stages: * Resolve versions and dependency graph (powered by ResolveLib). * Walk the graph to determine "why" each candidate came to be, i.e. what top-l...
[ "def", "lock", "(", "self", ")", ":", "provider", "=", "self", ".", "get_provider", "(", ")", "reporter", "=", "self", ".", "get_reporter", "(", ")", "resolver", "=", "resolvelib", ".", "Resolver", "(", "provider", ",", "reporter", ")", "with", "vistir",...
Lock specified (abstract) requirements into (concrete) candidates. The locking procedure consists of four stages: * Resolve versions and dependency graph (powered by ResolveLib). * Walk the graph to determine "why" each candidate came to be, i.e. what top-level requirements result in...
[ "Lock", "specified", "(", "abstract", ")", "requirements", "into", "(", "concrete", ")", "candidates", "." ]
python
train
UCSBarchlab/PyRTL
pyrtl/rtllib/multipliers.py
https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/rtllib/multipliers.py#L67-L102
def complex_mult(A, B, shifts, start): """ Generate shift-and-add multiplier that can shift and add multiple bits per clock cycle. Uses substantially more space than `simple_mult()` but is much faster. :param WireVector A, B: two input wires for the multiplication :param int shifts: number of spaces Re...
[ "def", "complex_mult", "(", "A", ",", "B", ",", "shifts", ",", "start", ")", ":", "alen", "=", "len", "(", "A", ")", "blen", "=", "len", "(", "B", ")", "areg", "=", "pyrtl", ".", "Register", "(", "alen", ")", "breg", "=", "pyrtl", ".", "Registe...
Generate shift-and-add multiplier that can shift and add multiple bits per clock cycle. Uses substantially more space than `simple_mult()` but is much faster. :param WireVector A, B: two input wires for the multiplication :param int shifts: number of spaces Register is to be shifted per clk cycle (...
[ "Generate", "shift", "-", "and", "-", "add", "multiplier", "that", "can", "shift", "and", "add", "multiple", "bits", "per", "clock", "cycle", ".", "Uses", "substantially", "more", "space", "than", "simple_mult", "()", "but", "is", "much", "faster", "." ]
python
train
MacHu-GWU/macro-project
macro/bot.py
https://github.com/MacHu-GWU/macro-project/blob/dae909d2d28acbfa2be623aa2dffe988f3882d4d/macro/bot.py#L372-L381
def left(self, n=1, interval=0, pre_dl=None, post_dl=None): """Press left key n times **中文文档** 按左方向键 n 次。 """ self.delay(pre_dl) self.k.tap_key(self.k.left_key, n, interval) self.delay(post_dl)
[ "def", "left", "(", "self", ",", "n", "=", "1", ",", "interval", "=", "0", ",", "pre_dl", "=", "None", ",", "post_dl", "=", "None", ")", ":", "self", ".", "delay", "(", "pre_dl", ")", "self", ".", "k", ".", "tap_key", "(", "self", ".", "k", "...
Press left key n times **中文文档** 按左方向键 n 次。
[ "Press", "left", "key", "n", "times" ]
python
train
ioos/compliance-checker
compliance_checker/suite.py
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/suite.py#L393-L407
def serialize(self, o): ''' Returns a safe serializable object that can be serialized into JSON. @param o Python object to serialize ''' if isinstance(o, (list, tuple)): return [self.serialize(i) for i in o] if isinstance(o, dict): return {k: self...
[ "def", "serialize", "(", "self", ",", "o", ")", ":", "if", "isinstance", "(", "o", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "[", "self", ".", "serialize", "(", "i", ")", "for", "i", "in", "o", "]", "if", "isinstance", "(", "o", ...
Returns a safe serializable object that can be serialized into JSON. @param o Python object to serialize
[ "Returns", "a", "safe", "serializable", "object", "that", "can", "be", "serialized", "into", "JSON", "." ]
python
train
numenta/nupic
src/nupic/frameworks/opf/htm_prediction_model.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L983-L1001
def getRuntimeStats(self): """ Only returns data for a stat called ``numRunCalls``. :return: """ ret = {"numRunCalls" : self.__numRunCalls} #-------------------------------------------------- # Query temporal network stats temporalStats = dict() if self._hasTP: for stat in sel...
[ "def", "getRuntimeStats", "(", "self", ")", ":", "ret", "=", "{", "\"numRunCalls\"", ":", "self", ".", "__numRunCalls", "}", "#--------------------------------------------------", "# Query temporal network stats", "temporalStats", "=", "dict", "(", ")", "if", "self", ...
Only returns data for a stat called ``numRunCalls``. :return:
[ "Only", "returns", "data", "for", "a", "stat", "called", "numRunCalls", ".", ":", "return", ":" ]
python
valid
Terrance/SkPy
skpy/util.py
https://github.com/Terrance/SkPy/blob/0f9489c94e8ec4d3effab4314497428872a80ad1/skpy/util.py#L235-L259
def exhaust(fn, transform=None, *args, **kwargs): """ Repeatedly call a function, starting with init, until false-y, yielding each item in turn. The ``transform`` parameter can be used to map a collection to another format, for example iterating over a :class:`dict` by value rather than...
[ "def", "exhaust", "(", "fn", ",", "transform", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "while", "True", ":", "iterRes", "=", "fn", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "iterRes", ":", "for", "item", "i...
Repeatedly call a function, starting with init, until false-y, yielding each item in turn. The ``transform`` parameter can be used to map a collection to another format, for example iterating over a :class:`dict` by value rather than key. Use with state-synced functions to retrieve all results...
[ "Repeatedly", "call", "a", "function", "starting", "with", "init", "until", "false", "-", "y", "yielding", "each", "item", "in", "turn", "." ]
python
test
intel-analytics/BigDL
pyspark/bigdl/models/lenet/utils.py
https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/models/lenet/utils.py#L65-L75
def validate_optimizer(optimizer, test_data, options): """ Set validation and checkpoint for distributed optimizer. """ optimizer.set_validation( batch_size=options.batchSize, val_rdd=test_data, trigger=EveryEpoch(), val_method=[Top1Accuracy()] ) optimizer.set_che...
[ "def", "validate_optimizer", "(", "optimizer", ",", "test_data", ",", "options", ")", ":", "optimizer", ".", "set_validation", "(", "batch_size", "=", "options", ".", "batchSize", ",", "val_rdd", "=", "test_data", ",", "trigger", "=", "EveryEpoch", "(", ")", ...
Set validation and checkpoint for distributed optimizer.
[ "Set", "validation", "and", "checkpoint", "for", "distributed", "optimizer", "." ]
python
test
googleapis/oauth2client
oauth2client/_pure_python_crypt.py
https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/_pure_python_crypt.py#L75-L92
def verify(self, message, signature): """Verifies a message against a signature. Args: message: string or bytes, The message to verify. If string, will be encoded to bytes as utf-8. signature: string or bytes, The signature on the message. If ...
[ "def", "verify", "(", "self", ",", "message", ",", "signature", ")", ":", "message", "=", "_helpers", ".", "_to_bytes", "(", "message", ",", "encoding", "=", "'utf-8'", ")", "try", ":", "return", "rsa", ".", "pkcs1", ".", "verify", "(", "message", ",",...
Verifies a message against a signature. Args: message: string or bytes, The message to verify. If string, will be encoded to bytes as utf-8. signature: string or bytes, The signature on the message. If string, will be encoded to bytes as utf-8...
[ "Verifies", "a", "message", "against", "a", "signature", "." ]
python
valid
biocore/burrito-fillings
bfillings/formatdb.py
https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/formatdb.py#L60-L80
def _get_result_paths(self, data): """ Build the dict of result filepaths """ # access data through self.Parameters so we know it's been cast # to a FilePath wd = self.WorkingDir db_name = self.Parameters['-n'].Value log_name = self.Parameters['-l'].Value ...
[ "def", "_get_result_paths", "(", "self", ",", "data", ")", ":", "# access data through self.Parameters so we know it's been cast", "# to a FilePath", "wd", "=", "self", ".", "WorkingDir", "db_name", "=", "self", ".", "Parameters", "[", "'-n'", "]", ".", "Value", "lo...
Build the dict of result filepaths
[ "Build", "the", "dict", "of", "result", "filepaths" ]
python
train
Nic30/hwt
hwt/pyUtils/arrayQuery.py
https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/pyUtils/arrayQuery.py#L102-L114
def iter_with_last(iterable): """ :return: generator of tuples (isLastFlag, item) """ # Ensure it's an iterator and get the first field iterable = iter(iterable) prev = next(iterable) for item in iterable: # Lag by one item so I know I'm not at the end yield False, prev ...
[ "def", "iter_with_last", "(", "iterable", ")", ":", "# Ensure it's an iterator and get the first field", "iterable", "=", "iter", "(", "iterable", ")", "prev", "=", "next", "(", "iterable", ")", "for", "item", "in", "iterable", ":", "# Lag by one item so I know I'm no...
:return: generator of tuples (isLastFlag, item)
[ ":", "return", ":", "generator", "of", "tuples", "(", "isLastFlag", "item", ")" ]
python
test
Grunny/zap-cli
zapcli/commands/scripts.py
https://github.com/Grunny/zap-cli/blob/d58d4850ecfc5467badfac5e5bcc841d064bd419/zapcli/commands/scripts.py#L83-L92
def remove_script(zap_helper, script_name): """Remove a script.""" with zap_error_handler(): console.debug('Removing script "{0}"'.format(script_name)) result = zap_helper.zap.script.remove(script_name) if result != 'OK': raise ZAPError('Error removing script: {0}'.format(re...
[ "def", "remove_script", "(", "zap_helper", ",", "script_name", ")", ":", "with", "zap_error_handler", "(", ")", ":", "console", ".", "debug", "(", "'Removing script \"{0}\"'", ".", "format", "(", "script_name", ")", ")", "result", "=", "zap_helper", ".", "zap"...
Remove a script.
[ "Remove", "a", "script", "." ]
python
train
kushaldas/retask
retask/queue.py
https://github.com/kushaldas/retask/blob/5c955b8386653d3f0591ca2f4b1a213ff4b5a018/retask/queue.py#L299-L322
def wait(self, wait_time=0): """ Blocking call to check if the worker returns the result. One can use job.result after this call returns ``True``. :arg wait_time: Time in seconds to wait, default is infinite. :return: `True` or `False`. .. note:: This is a...
[ "def", "wait", "(", "self", ",", "wait_time", "=", "0", ")", ":", "if", "self", ".", "__result", ":", "return", "True", "data", "=", "self", ".", "rdb", ".", "brpop", "(", "self", ".", "urn", ",", "wait_time", ")", "if", "data", ":", "self", ".",...
Blocking call to check if the worker returns the result. One can use job.result after this call returns ``True``. :arg wait_time: Time in seconds to wait, default is infinite. :return: `True` or `False`. .. note:: This is a blocking call, you can specity wait_time argumen...
[ "Blocking", "call", "to", "check", "if", "the", "worker", "returns", "the", "result", ".", "One", "can", "use", "job", ".", "result", "after", "this", "call", "returns", "True", "." ]
python
train
jplusplus/statscraper
statscraper/base_scraper.py
https://github.com/jplusplus/statscraper/blob/932ec048b23d15b3dbdaf829facc55fd78ec0109/statscraper/base_scraper.py#L579-L588
def move_to(self, id_): """Select a child item by id (str), reference or index.""" if self.items: try: self.current_item = self.items[id_] except (StopIteration, IndexError, NoSuchItem): raise NoSuchItem for f in self._hooks["select"]: ...
[ "def", "move_to", "(", "self", ",", "id_", ")", ":", "if", "self", ".", "items", ":", "try", ":", "self", ".", "current_item", "=", "self", ".", "items", "[", "id_", "]", "except", "(", "StopIteration", ",", "IndexError", ",", "NoSuchItem", ")", ":",...
Select a child item by id (str), reference or index.
[ "Select", "a", "child", "item", "by", "id", "(", "str", ")", "reference", "or", "index", "." ]
python
train
peergradeio/flask-mongo-profiler
flask_mongo_profiler/contrib/flask_admin/formatters/polymorphic_relations.py
https://github.com/peergradeio/flask-mongo-profiler/blob/a267eeb49fea07c9a24fb370bd9d7a90ed313ccf/flask_mongo_profiler/contrib/flask_admin/formatters/polymorphic_relations.py#L27-L65
def generic_ref_formatter(view, context, model, name, lazy=False): """ For GenericReferenceField and LazyGenericReferenceField See Also -------- diff_formatter """ try: if lazy: rel_model = getattr(model, name).fetch() else: rel_model = getattr(model,...
[ "def", "generic_ref_formatter", "(", "view", ",", "context", ",", "model", ",", "name", ",", "lazy", "=", "False", ")", ":", "try", ":", "if", "lazy", ":", "rel_model", "=", "getattr", "(", "model", ",", "name", ")", ".", "fetch", "(", ")", "else", ...
For GenericReferenceField and LazyGenericReferenceField See Also -------- diff_formatter
[ "For", "GenericReferenceField", "and", "LazyGenericReferenceField" ]
python
train
CityOfZion/neo-python
neo/Core/TX/RegisterTransaction.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/TX/RegisterTransaction.py#L129-L148
def ToJson(self): """ Convert object members to a dictionary that can be parsed as JSON. Returns: dict: """ jsn = super(RegisterTransaction, self).ToJson() asset = { 'type': self.AssetType, 'name': self.Name.decode('utf-8'), ...
[ "def", "ToJson", "(", "self", ")", ":", "jsn", "=", "super", "(", "RegisterTransaction", ",", "self", ")", ".", "ToJson", "(", ")", "asset", "=", "{", "'type'", ":", "self", ".", "AssetType", ",", "'name'", ":", "self", ".", "Name", ".", "decode", ...
Convert object members to a dictionary that can be parsed as JSON. Returns: dict:
[ "Convert", "object", "members", "to", "a", "dictionary", "that", "can", "be", "parsed", "as", "JSON", "." ]
python
train
Azure/azure-sdk-for-python
azure-mgmt-storage/azure/mgmt/storage/storage_management_client.py
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-mgmt-storage/azure/mgmt/storage/storage_management_client.py#L147-L163
def blob_containers(self): """Instance depends on the API version: * 2018-02-01: :class:`BlobContainersOperations<azure.mgmt.storage.v2018_02_01.operations.BlobContainersOperations>` * 2018-03-01-preview: :class:`BlobContainersOperations<azure.mgmt.storage.v2018_03_01_preview.operations.B...
[ "def", "blob_containers", "(", "self", ")", ":", "api_version", "=", "self", ".", "_get_api_version", "(", "'blob_containers'", ")", "if", "api_version", "==", "'2018-02-01'", ":", "from", ".", "v2018_02_01", ".", "operations", "import", "BlobContainersOperations", ...
Instance depends on the API version: * 2018-02-01: :class:`BlobContainersOperations<azure.mgmt.storage.v2018_02_01.operations.BlobContainersOperations>` * 2018-03-01-preview: :class:`BlobContainersOperations<azure.mgmt.storage.v2018_03_01_preview.operations.BlobContainersOperations>` *...
[ "Instance", "depends", "on", "the", "API", "version", ":" ]
python
test
Azure/azure-sdk-for-python
azure-keyvault/azure/keyvault/_internal.py
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-keyvault/azure/keyvault/_internal.py#L131-L140
def _b64_to_bstr(b64str): """Deserialize base64 encoded string into string. :param str b64str: response string to be deserialized. :rtype: bytearray :raises: TypeError if string format invalid. """ padding = '=' * (3 - (len(b64str) + 3) % 4) b64str = b64str + padding encoded = b64str.rep...
[ "def", "_b64_to_bstr", "(", "b64str", ")", ":", "padding", "=", "'='", "*", "(", "3", "-", "(", "len", "(", "b64str", ")", "+", "3", ")", "%", "4", ")", "b64str", "=", "b64str", "+", "padding", "encoded", "=", "b64str", ".", "replace", "(", "'-'"...
Deserialize base64 encoded string into string. :param str b64str: response string to be deserialized. :rtype: bytearray :raises: TypeError if string format invalid.
[ "Deserialize", "base64", "encoded", "string", "into", "string", ".", ":", "param", "str", "b64str", ":", "response", "string", "to", "be", "deserialized", ".", ":", "rtype", ":", "bytearray", ":", "raises", ":", "TypeError", "if", "string", "format", "invali...
python
test
sephii/taxi-zebra
taxi_zebra/backend.py
https://github.com/sephii/taxi-zebra/blob/36affa22d4167e7ce5a8c7c6eaf5adc4cbfcfb5d/taxi_zebra/backend.py#L139-L148
def update_alias_mapping(settings, alias, new_mapping): """ Override `alias` mapping in the user configuration file with the given `new_mapping`, which should be a tuple with 2 or 3 elements (in the form `(project_id, activity_id, role_id)`). """ mapping = aliases_database[alias] new_mapping = M...
[ "def", "update_alias_mapping", "(", "settings", ",", "alias", ",", "new_mapping", ")", ":", "mapping", "=", "aliases_database", "[", "alias", "]", "new_mapping", "=", "Mapping", "(", "mapping", "=", "new_mapping", ",", "backend", "=", "mapping", ".", "backend"...
Override `alias` mapping in the user configuration file with the given `new_mapping`, which should be a tuple with 2 or 3 elements (in the form `(project_id, activity_id, role_id)`).
[ "Override", "alias", "mapping", "in", "the", "user", "configuration", "file", "with", "the", "given", "new_mapping", "which", "should", "be", "a", "tuple", "with", "2", "or", "3", "elements", "(", "in", "the", "form", "(", "project_id", "activity_id", "role_...
python
valid
sripathikrishnan/redis-rdb-tools
rdbtools/encodehelpers.py
https://github.com/sripathikrishnan/redis-rdb-tools/blob/543a73e84702e911ddcd31325ecfde77d7fd230b/rdbtools/encodehelpers.py#L96-L123
def bytes_to_unicode(byte_data, escape, skip_printable=False): """ Decode given bytes using specified escaping method. :param byte_data: The byte-like object with bytes to decode. :param escape: The escape method to use. :param skip_printable: If True, don't escape byte_data with all 'printable ASCI...
[ "def", "bytes_to_unicode", "(", "byte_data", ",", "escape", ",", "skip_printable", "=", "False", ")", ":", "if", "isnumber", "(", "byte_data", ")", ":", "if", "skip_printable", ":", "return", "num2unistr", "(", "byte_data", ")", "else", ":", "byte_data", "="...
Decode given bytes using specified escaping method. :param byte_data: The byte-like object with bytes to decode. :param escape: The escape method to use. :param skip_printable: If True, don't escape byte_data with all 'printable ASCII' bytes. Defaults to False. :return: New unicode string, escaped with ...
[ "Decode", "given", "bytes", "using", "specified", "escaping", "method", ".", ":", "param", "byte_data", ":", "The", "byte", "-", "like", "object", "with", "bytes", "to", "decode", ".", ":", "param", "escape", ":", "The", "escape", "method", "to", "use", ...
python
train
Capitains/MyCapytain
MyCapytain/resources/collections/dts/_resolver.py
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/collections/dts/_resolver.py#L187-L218
def parse_member( cls, obj: dict, collection: "HttpResolverDtsCollection", direction: str, **additional_parameters): """ Parse the member value of a Collection response and returns the list of object while setting the graph relationshi...
[ "def", "parse_member", "(", "cls", ",", "obj", ":", "dict", ",", "collection", ":", "\"HttpResolverDtsCollection\"", ",", "direction", ":", "str", ",", "*", "*", "additional_parameters", ")", ":", "members", "=", "[", "]", "# Start pagination check here", "hydra...
Parse the member value of a Collection response and returns the list of object while setting the graph relationship based on `direction` :param obj: PyLD parsed JSON+LD :param collection: Collection attached to the member property :param direction: Direction of the member (child...
[ "Parse", "the", "member", "value", "of", "a", "Collection", "response", "and", "returns", "the", "list", "of", "object", "while", "setting", "the", "graph", "relationship", "based", "on", "direction" ]
python
train
zalando/patroni
patroni/scripts/wale_restore.py
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/scripts/wale_restore.py#L131-L158
def run(self): """ Creates a new replica using WAL-E Returns ------- ExitCode 0 = Success 1 = Error, try again 2 = Error, don't try again """ if self.init_error: logger.error('init error: %r did not exist at initia...
[ "def", "run", "(", "self", ")", ":", "if", "self", ".", "init_error", ":", "logger", ".", "error", "(", "'init error: %r did not exist at initialization time'", ",", "self", ".", "wal_e", ".", "env_dir", ")", "return", "ExitCode", ".", "FAIL", "try", ":", "s...
Creates a new replica using WAL-E Returns ------- ExitCode 0 = Success 1 = Error, try again 2 = Error, don't try again
[ "Creates", "a", "new", "replica", "using", "WAL", "-", "E" ]
python
train
bitesofcode/projexui
projexui/widgets/xstackedwidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xstackedwidget.py#L66-L76
def _finishAnimation(self): """ Cleans up post-animation. """ self.setCurrentIndex(self._nextIndex) self.widget(self._lastIndex).hide() self.widget(self._lastIndex).move(self._lastPoint) self._active = False if not self.signalsBlocked(): ...
[ "def", "_finishAnimation", "(", "self", ")", ":", "self", ".", "setCurrentIndex", "(", "self", ".", "_nextIndex", ")", "self", ".", "widget", "(", "self", ".", "_lastIndex", ")", ".", "hide", "(", ")", "self", ".", "widget", "(", "self", ".", "_lastInd...
Cleans up post-animation.
[ "Cleans", "up", "post", "-", "animation", "." ]
python
train
egineering-llc/egat
egat/loggers/html_logger.py
https://github.com/egineering-llc/egat/blob/63a172276b554ae1c7d0f13ba305881201c49d55/egat/loggers/html_logger.py#L28-L36
def copy_resources_to_log_dir(log_dir): """Copies the necessary static assets to the log_dir and returns the path of the main css file.""" css_path = resource_filename(Requirement.parse("egat"), "/egat/data/default.css") header_path = resource_filename(Requirement.parse("egat"), "/egat/...
[ "def", "copy_resources_to_log_dir", "(", "log_dir", ")", ":", "css_path", "=", "resource_filename", "(", "Requirement", ".", "parse", "(", "\"egat\"", ")", ",", "\"/egat/data/default.css\"", ")", "header_path", "=", "resource_filename", "(", "Requirement", ".", "par...
Copies the necessary static assets to the log_dir and returns the path of the main css file.
[ "Copies", "the", "necessary", "static", "assets", "to", "the", "log_dir", "and", "returns", "the", "path", "of", "the", "main", "css", "file", "." ]
python
train
kubernetes-client/python
kubernetes/client/apis/storage_v1beta1_api.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/storage_v1beta1_api.py#L1074-L1099
def delete_csi_node(self, name, **kwargs): """ delete a CSINode This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_csi_node(name, async_req=True) >>> result = thread.get() ...
[ "def", "delete_csi_node", "(", "self", ",", "name", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "delete_csi_node_with_http_in...
delete a CSINode This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.delete_csi_node(name, async_req=True) >>> result = thread.get() :param async_req bool :param str name: name of the ...
[ "delete", "a", "CSINode", "This", "method", "makes", "a", "synchronous", "HTTP", "request", "by", "default", ".", "To", "make", "an", "asynchronous", "HTTP", "request", "please", "pass", "async_req", "=", "True", ">>>", "thread", "=", "api", ".", "delete_csi...
python
train
Pylons/plaster_pastedeploy
src/plaster_pastedeploy/__init__.py
https://github.com/Pylons/plaster_pastedeploy/blob/72a08f3fb6d11a0b039f381ade83f045668cfcb0/src/plaster_pastedeploy/__init__.py#L61-L107
def get_settings(self, section=None, defaults=None): """ Gets a named section from the configuration source. :param section: a :class:`str` representing the section you want to retrieve from the configuration source. If ``None`` this will fallback to the :attr:`plaster.P...
[ "def", "get_settings", "(", "self", ",", "section", "=", "None", ",", "defaults", "=", "None", ")", ":", "# This is a partial reimplementation of", "# ``paste.deploy.loadwsgi.ConfigLoader:get_context`` which supports", "# \"set\" and \"get\" options and filters out any other globals"...
Gets a named section from the configuration source. :param section: a :class:`str` representing the section you want to retrieve from the configuration source. If ``None`` this will fallback to the :attr:`plaster.PlasterURL.fragment`. :param defaults: a :class:`dict` that will g...
[ "Gets", "a", "named", "section", "from", "the", "configuration", "source", "." ]
python
train
PyGithub/PyGithub
github/PullRequest.py
https://github.com/PyGithub/PyGithub/blob/f716df86bbe7dc276c6596699fa9712b61ef974c/github/PullRequest.py#L404-L419
def create_issue_comment(self, body): """ :calls: `POST /repos/:owner/:repo/issues/:number/comments <http://developer.github.com/v3/issues/comments>`_ :param body: string :rtype: :class:`github.IssueComment.IssueComment` """ assert isinstance(body, (str, unicode)), body ...
[ "def", "create_issue_comment", "(", "self", ",", "body", ")", ":", "assert", "isinstance", "(", "body", ",", "(", "str", ",", "unicode", ")", ")", ",", "body", "post_parameters", "=", "{", "\"body\"", ":", "body", ",", "}", "headers", ",", "data", "=",...
:calls: `POST /repos/:owner/:repo/issues/:number/comments <http://developer.github.com/v3/issues/comments>`_ :param body: string :rtype: :class:`github.IssueComment.IssueComment`
[ ":", "calls", ":", "POST", "/", "repos", "/", ":", "owner", "/", ":", "repo", "/", "issues", "/", ":", "number", "/", "comments", "<http", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "issues", "/", "comments", ">", "_", ":"...
python
train
pantsbuild/pants
src/python/pants/build_graph/import_remote_sources_mixin.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/build_graph/import_remote_sources_mixin.py#L87-L107
def imported_targets(self): """ :returns: target instances for specs referenced by imported_target_specs. :rtype: list of Target """ libs = [] for spec in self.imported_target_specs(payload=self.payload): resolved_target = self._build_graph.get_target_from_spec(spec, ...
[ "def", "imported_targets", "(", "self", ")", ":", "libs", "=", "[", "]", "for", "spec", "in", "self", ".", "imported_target_specs", "(", "payload", "=", "self", ".", "payload", ")", ":", "resolved_target", "=", "self", ".", "_build_graph", ".", "get_target...
:returns: target instances for specs referenced by imported_target_specs. :rtype: list of Target
[ ":", "returns", ":", "target", "instances", "for", "specs", "referenced", "by", "imported_target_specs", ".", ":", "rtype", ":", "list", "of", "Target" ]
python
train
djgagne/hagelslag
hagelslag/processing/TrackModeler.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/TrackModeler.py#L193-L292
def fit_condition_threshold_models(self, model_names, model_objs, input_columns, output_column="Matched", output_threshold=0.5, num_folds=5, threshold_score="ets"): """ Fit models to predict hail/no-hail and use cross-validation to determine the probaility threshol...
[ "def", "fit_condition_threshold_models", "(", "self", ",", "model_names", ",", "model_objs", ",", "input_columns", ",", "output_column", "=", "\"Matched\"", ",", "output_threshold", "=", "0.5", ",", "num_folds", "=", "5", ",", "threshold_score", "=", "\"ets\"", ")...
Fit models to predict hail/no-hail and use cross-validation to determine the probaility threshold that maximizes a skill score. Args: model_names: List of machine learning model names model_objs: List of Scikit-learn ML models input_columns: List of input variables i...
[ "Fit", "models", "to", "predict", "hail", "/", "no", "-", "hail", "and", "use", "cross", "-", "validation", "to", "determine", "the", "probaility", "threshold", "that", "maximizes", "a", "skill", "score", "." ]
python
train
coghost/izen
izen/icfg.py
https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/icfg.py#L82-L95
def __spawn(self): """通过手动方式, 指定字段类型与默认值, - 如果配置文件有变动, 需要手动在这里添加 - 如果配置字段未在这里指出, 则默认为 string, 使用时需要手动转换 """ dat = { 'log.enabled': False, 'log.file_pth': '{}/{}.log'.format(self._pth, self._cfg_name), 'log.file_backups': 3, ...
[ "def", "__spawn", "(", "self", ")", ":", "dat", "=", "{", "'log.enabled'", ":", "False", ",", "'log.file_pth'", ":", "'{}/{}.log'", ".", "format", "(", "self", ".", "_pth", ",", "self", ".", "_cfg_name", ")", ",", "'log.file_backups'", ":", "3", ",", "...
通过手动方式, 指定字段类型与默认值, - 如果配置文件有变动, 需要手动在这里添加 - 如果配置字段未在这里指出, 则默认为 string, 使用时需要手动转换
[ "通过手动方式", "指定字段类型与默认值", "-", "如果配置文件有变动", "需要手动在这里添加", "-", "如果配置字段未在这里指出", "则默认为", "string", "使用时需要手动转换" ]
python
train
crossbario/txaio
txaio/tx.py
https://github.com/crossbario/txaio/blob/29c77ff1210cabd4cc03f16f34672612e7eef704/txaio/tx.py#L376-L387
def failure_message(self, fail): """ :param fail: must be an IFailedFuture returns a unicode error-message """ try: return u'{0}: {1}'.format( fail.value.__class__.__name__, fail.getErrorMessage(), ) except Exception...
[ "def", "failure_message", "(", "self", ",", "fail", ")", ":", "try", ":", "return", "u'{0}: {1}'", ".", "format", "(", "fail", ".", "value", ".", "__class__", ".", "__name__", ",", "fail", ".", "getErrorMessage", "(", ")", ",", ")", "except", "Exception"...
:param fail: must be an IFailedFuture returns a unicode error-message
[ ":", "param", "fail", ":", "must", "be", "an", "IFailedFuture", "returns", "a", "unicode", "error", "-", "message" ]
python
train
tensorflow/probability
tensorflow_probability/python/internal/dtype_util.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/internal/dtype_util.py#L98-L103
def is_floating(dtype): """Returns whether this is a (non-quantized, real) floating point type.""" dtype = tf.as_dtype(dtype) if hasattr(dtype, 'is_floating'): return dtype.is_floating return np.issubdtype(np.dtype(dtype), np.float)
[ "def", "is_floating", "(", "dtype", ")", ":", "dtype", "=", "tf", ".", "as_dtype", "(", "dtype", ")", "if", "hasattr", "(", "dtype", ",", "'is_floating'", ")", ":", "return", "dtype", ".", "is_floating", "return", "np", ".", "issubdtype", "(", "np", "....
Returns whether this is a (non-quantized, real) floating point type.
[ "Returns", "whether", "this", "is", "a", "(", "non", "-", "quantized", "real", ")", "floating", "point", "type", "." ]
python
test
manns/pyspread
pyspread/src/lib/_string_helpers.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/_string_helpers.py#L35-L57
def quote(code): """Returns quoted code if not already quoted and if possible Parameters ---------- code: String \tCode thta is quoted """ try: code = code.rstrip() except AttributeError: # code is not a string, may be None --> There is no code to quote retur...
[ "def", "quote", "(", "code", ")", ":", "try", ":", "code", "=", "code", ".", "rstrip", "(", ")", "except", "AttributeError", ":", "# code is not a string, may be None --> There is no code to quote", "return", "code", "if", "code", "and", "code", "[", "0", "]", ...
Returns quoted code if not already quoted and if possible Parameters ---------- code: String \tCode thta is quoted
[ "Returns", "quoted", "code", "if", "not", "already", "quoted", "and", "if", "possible" ]
python
train
JnyJny/Geometry
Geometry/ellipse.py
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/ellipse.py#L416-L446
def circumcircleForTriangle(cls, triangle): ''' :param: triangle - Triangle class :return: Circle class Returns the circle where every vertex in the input triangle is on the radius of that circle. ''' if triangle.isRight: # circumcircle origin is th...
[ "def", "circumcircleForTriangle", "(", "cls", ",", "triangle", ")", ":", "if", "triangle", ".", "isRight", ":", "# circumcircle origin is the midpoint of the hypotenues", "o", "=", "triangle", ".", "hypotenuse", ".", "midpoint", "r", "=", "o", ".", "distance", "("...
:param: triangle - Triangle class :return: Circle class Returns the circle where every vertex in the input triangle is on the radius of that circle.
[ ":", "param", ":", "triangle", "-", "Triangle", "class", ":", "return", ":", "Circle", "class" ]
python
train
log2timeline/dfdatetime
dfdatetime/cocoa_time.py
https://github.com/log2timeline/dfdatetime/blob/141ca4ef1eff3d354b5deaac3d81cb08506f98d6/dfdatetime/cocoa_time.py#L106-L126
def CopyToDateTimeString(self): """Copies the Cocoa timestamp to a date and time string. Returns: str: date and time value formatted as: YYYY-MM-DD hh:mm:ss.###### or None if the timestamp cannot be copied to a date and time string. """ if self._timestamp is None: return None ...
[ "def", "CopyToDateTimeString", "(", "self", ")", ":", "if", "self", ".", "_timestamp", "is", "None", ":", "return", "None", "number_of_days", ",", "hours", ",", "minutes", ",", "seconds", "=", "self", ".", "_GetTimeValues", "(", "int", "(", "self", ".", ...
Copies the Cocoa timestamp to a date and time string. Returns: str: date and time value formatted as: YYYY-MM-DD hh:mm:ss.###### or None if the timestamp cannot be copied to a date and time string.
[ "Copies", "the", "Cocoa", "timestamp", "to", "a", "date", "and", "time", "string", "." ]
python
train
project-rig/rig
rig/routing_table/utils.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/utils.py#L234-L282
def expand_entry(entry, ignore_xs=0x0): """Turn all Xs which are not marked in `ignore_xs` into ``0``\ s and ``1``\ s. The following will expand any Xs in bits ``1..3``\ :: >>> entry = RoutingTableEntry(set(), 0b0100, 0xfffffff0 | 0b1100) >>> list(expand_entry(entry, 0xfffffff1)) == [ ...
[ "def", "expand_entry", "(", "entry", ",", "ignore_xs", "=", "0x0", ")", ":", "# Get all the Xs in the entry that are not ignored", "xs", "=", "(", "~", "entry", ".", "key", "&", "~", "entry", ".", "mask", ")", "&", "~", "ignore_xs", "# Find the most significant ...
Turn all Xs which are not marked in `ignore_xs` into ``0``\ s and ``1``\ s. The following will expand any Xs in bits ``1..3``\ :: >>> entry = RoutingTableEntry(set(), 0b0100, 0xfffffff0 | 0b1100) >>> list(expand_entry(entry, 0xfffffff1)) == [ ... RoutingTableEntry(set(), 0b0100, 0x...
[ "Turn", "all", "Xs", "which", "are", "not", "marked", "in", "ignore_xs", "into", "0", "\\", "s", "and", "1", "\\", "s", "." ]
python
train
bodylabs/lace
lace/geometry.py
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/geometry.py#L52-L64
def predict_body_units(self): ''' There is no prediction for united states unit system. This may fail when a mesh is not axis-aligned ''' longest_dist = np.max(np.max(self.v, axis=0) - np.min(self.v, axis=0)) if round(longest_dist / 1000) > 0: return 'mm' ...
[ "def", "predict_body_units", "(", "self", ")", ":", "longest_dist", "=", "np", ".", "max", "(", "np", ".", "max", "(", "self", ".", "v", ",", "axis", "=", "0", ")", "-", "np", ".", "min", "(", "self", ".", "v", ",", "axis", "=", "0", ")", ")"...
There is no prediction for united states unit system. This may fail when a mesh is not axis-aligned
[ "There", "is", "no", "prediction", "for", "united", "states", "unit", "system", ".", "This", "may", "fail", "when", "a", "mesh", "is", "not", "axis", "-", "aligned" ]
python
train
xapple/fasta
fasta/__init__.py
https://github.com/xapple/fasta/blob/a827c3138812d555203be45187ffae1277dd0d76/fasta/__init__.py#L138-L142
def flush(self): """Empty the buffer.""" for seq in self.buffer: SeqIO.write(seq, self.handle, self.format) self.buffer = []
[ "def", "flush", "(", "self", ")", ":", "for", "seq", "in", "self", ".", "buffer", ":", "SeqIO", ".", "write", "(", "seq", ",", "self", ".", "handle", ",", "self", ".", "format", ")", "self", ".", "buffer", "=", "[", "]" ]
Empty the buffer.
[ "Empty", "the", "buffer", "." ]
python
train
mitsei/dlkit
dlkit/json_/cataloging/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L915-L935
def get_root_catalogs(self): """Gets the root catalogs in the catalog hierarchy. A node with no parents is an orphan. While all catalog ``Ids`` are known to the hierarchy, an orphan does not appear in the hierarchy unless explicitly added as a root node or child of another node....
[ "def", "get_root_catalogs", "(", "self", ")", ":", "# Implemented from template for", "# osid.resource.BinHierarchySession.get_root_bins", "if", "self", ".", "_catalog_session", "is", "not", "None", ":", "return", "self", ".", "_catalog_session", ".", "get_root_catalogs", ...
Gets the root catalogs in the catalog hierarchy. A node with no parents is an orphan. While all catalog ``Ids`` are known to the hierarchy, an orphan does not appear in the hierarchy unless explicitly added as a root node or child of another node. return: (osid.cataloging.Catal...
[ "Gets", "the", "root", "catalogs", "in", "the", "catalog", "hierarchy", "." ]
python
train
astraw38/lint
lint/validators/validation_factory.py
https://github.com/astraw38/lint/blob/162ceefcb812f07d18544aaa887b9ec4f102cfb1/lint/validators/validation_factory.py#L32-L42
def register_validator(validator): """ Register a Validator class for file verification. :param validator: :return: """ if hasattr(validator, "EXTS") and hasattr(validator, "run"): ValidatorFactory.PLUGINS.append(validator) else: raise Val...
[ "def", "register_validator", "(", "validator", ")", ":", "if", "hasattr", "(", "validator", ",", "\"EXTS\"", ")", "and", "hasattr", "(", "validator", ",", "\"run\"", ")", ":", "ValidatorFactory", ".", "PLUGINS", ".", "append", "(", "validator", ")", "else", ...
Register a Validator class for file verification. :param validator: :return:
[ "Register", "a", "Validator", "class", "for", "file", "verification", "." ]
python
train
roll/interest-py
interest/logger/logger.py
https://github.com/roll/interest-py/blob/e6e1def4f2999222aac2fb1d290ae94250673b89/interest/logger/logger.py#L91-L96
def debug(self, message, *args, **kwargs): """Log debug event. Compatible with logging.debug signature. """ self.system.debug(message, *args, **kwargs)
[ "def", "debug", "(", "self", ",", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "system", ".", "debug", "(", "message", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Log debug event. Compatible with logging.debug signature.
[ "Log", "debug", "event", "." ]
python
train
project-generator/project_generator
project_generator/project.py
https://github.com/project-generator/project_generator/blob/a361be16eeb5a8829ff5cd26850ddd4b264296fe/project_generator/project.py#L157-L171
def get_project_template(name="Default", output_type='exe', debugger=None, build_dir='build'): """ Project data (+ data) """ project_template = { 'build_dir' : build_dir, # Build output path 'debugger' : debugger, # Debugger 'export_dir': '', # Export dir...
[ "def", "get_project_template", "(", "name", "=", "\"Default\"", ",", "output_type", "=", "'exe'", ",", "debugger", "=", "None", ",", "build_dir", "=", "'build'", ")", ":", "project_template", "=", "{", "'build_dir'", ":", "build_dir", ",", "# Build output path",...
Project data (+ data)
[ "Project", "data", "(", "+", "data", ")" ]
python
train
aiogram/aiogram
aiogram/types/input_media.py
https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/input_media.py#L218-L248
def attach(self, media: typing.Union[InputMedia, typing.Dict]): """ Attach media :param media: """ if isinstance(media, dict): if 'type' not in media: raise ValueError(f"Invalid media!") media_type = media['type'] if media_typ...
[ "def", "attach", "(", "self", ",", "media", ":", "typing", ".", "Union", "[", "InputMedia", ",", "typing", ".", "Dict", "]", ")", ":", "if", "isinstance", "(", "media", ",", "dict", ")", ":", "if", "'type'", "not", "in", "media", ":", "raise", "Val...
Attach media :param media:
[ "Attach", "media" ]
python
train
nerdvegas/rez
src/rez/solver.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/solver.py#L956-L994
def intersect(self, range_): """Intersect this scope with a package range. Returns: A new copy of this scope, with variants whos version fall outside of the given range removed. If there were no removals, self is returned. If all variants were removed, None is return...
[ "def", "intersect", "(", "self", ",", "range_", ")", ":", "new_slice", "=", "None", "if", "self", ".", "package_request", ".", "conflict", ":", "if", "self", ".", "package_request", ".", "range", "is", "None", ":", "new_slice", "=", "self", ".", "solver"...
Intersect this scope with a package range. Returns: A new copy of this scope, with variants whos version fall outside of the given range removed. If there were no removals, self is returned. If all variants were removed, None is returned.
[ "Intersect", "this", "scope", "with", "a", "package", "range", "." ]
python
train
pantsbuild/pants
src/python/pants/util/contextutil.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/util/contextutil.py#L98-L107
def hermetic_environment_as(**kwargs): """Set the environment to the supplied values from an empty state.""" old_environment = os.environ.copy() if PY3 else _copy_and_decode_env(os.environ) _purge_env() try: with environment_as(**kwargs): yield finally: _purge_env() _restore_env(old_environm...
[ "def", "hermetic_environment_as", "(", "*", "*", "kwargs", ")", ":", "old_environment", "=", "os", ".", "environ", ".", "copy", "(", ")", "if", "PY3", "else", "_copy_and_decode_env", "(", "os", ".", "environ", ")", "_purge_env", "(", ")", "try", ":", "wi...
Set the environment to the supplied values from an empty state.
[ "Set", "the", "environment", "to", "the", "supplied", "values", "from", "an", "empty", "state", "." ]
python
train
gem/oq-engine
openquake/calculators/reportwriter.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/reportwriter.py#L119-L122
def save(self, fname): """Save the report""" with open(fname, 'wb') as f: f.write(encode(self.text))
[ "def", "save", "(", "self", ",", "fname", ")", ":", "with", "open", "(", "fname", ",", "'wb'", ")", "as", "f", ":", "f", ".", "write", "(", "encode", "(", "self", ".", "text", ")", ")" ]
Save the report
[ "Save", "the", "report" ]
python
train
seleniumbase/SeleniumBase
seleniumbase/fixtures/base_case.py
https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/base_case.py#L967-L985
def create_bootstrap_tour(self, name=None): """ Creates a Bootstrap tour for a website. @Params name - If creating multiple tours at the same time, use this to select the tour you wish to add steps to. """ if not name: name = "default" ...
[ "def", "create_bootstrap_tour", "(", "self", ",", "name", "=", "None", ")", ":", "if", "not", "name", ":", "name", "=", "\"default\"", "new_tour", "=", "(", "\"\"\"\n // Bootstrap Tour\n var tour = new Tour({\n });\n tour.addSteps([...
Creates a Bootstrap tour for a website. @Params name - If creating multiple tours at the same time, use this to select the tour you wish to add steps to.
[ "Creates", "a", "Bootstrap", "tour", "for", "a", "website", "." ]
python
train
andreikop/qutepart
qutepart/__init__.py
https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/__init__.py#L335-L348
def terminate(self): """ Terminate Qutepart instance. This method MUST be called before application stop to avoid crashes and some other interesting effects Call it on close to free memory and stop background highlighting """ self.text = '' self._completer.termina...
[ "def", "terminate", "(", "self", ")", ":", "self", ".", "text", "=", "''", "self", ".", "_completer", ".", "terminate", "(", ")", "if", "self", ".", "_highlighter", "is", "not", "None", ":", "self", ".", "_highlighter", ".", "terminate", "(", ")", "i...
Terminate Qutepart instance. This method MUST be called before application stop to avoid crashes and some other interesting effects Call it on close to free memory and stop background highlighting
[ "Terminate", "Qutepart", "instance", ".", "This", "method", "MUST", "be", "called", "before", "application", "stop", "to", "avoid", "crashes", "and", "some", "other", "interesting", "effects", "Call", "it", "on", "close", "to", "free", "memory", "and", "stop",...
python
train
wdecoster/nanoplotter
nanoplotter/nanoplotter_main.py
https://github.com/wdecoster/nanoplotter/blob/80908dd1be585f450da5a66989de9de4d544ec85/nanoplotter/nanoplotter_main.py#L209-L220
def contains_variance(arrays, names): """ Make sure both arrays for bivariate ("scatter") plot have a stddev > 0 """ for ar, name in zip(arrays, names): if np.std(ar) == 0: sys.stderr.write( "No variation in '{}', skipping bivariate plots.\n".format(name.lower())) ...
[ "def", "contains_variance", "(", "arrays", ",", "names", ")", ":", "for", "ar", ",", "name", "in", "zip", "(", "arrays", ",", "names", ")", ":", "if", "np", ".", "std", "(", "ar", ")", "==", "0", ":", "sys", ".", "stderr", ".", "write", "(", "\...
Make sure both arrays for bivariate ("scatter") plot have a stddev > 0
[ "Make", "sure", "both", "arrays", "for", "bivariate", "(", "scatter", ")", "plot", "have", "a", "stddev", ">", "0" ]
python
train
chaoss/grimoirelab-perceval
perceval/backends/core/launchpad.py
https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/launchpad.py#L192-L219
def _fetch_issues(self, from_date): """Fetch the issues from a project (distribution/package)""" issues_groups = self.client.issues(start=from_date) for raw_issues in issues_groups: issues = json.loads(raw_issues)['entries'] for issue in issues: issue =...
[ "def", "_fetch_issues", "(", "self", ",", "from_date", ")", ":", "issues_groups", "=", "self", ".", "client", ".", "issues", "(", "start", "=", "from_date", ")", "for", "raw_issues", "in", "issues_groups", ":", "issues", "=", "json", ".", "loads", "(", "...
Fetch the issues from a project (distribution/package)
[ "Fetch", "the", "issues", "from", "a", "project", "(", "distribution", "/", "package", ")" ]
python
test
opencobra/memote
memote/experimental/experimental_base.py
https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/experimental/experimental_base.py#L72-L88
def load(self, dtype_conversion=None): """ Load the data table and corresponding validation schema. Parameters ---------- dtype_conversion : dict Column names as keys and corresponding type for loading the data. Please take a look at the `pandas documenta...
[ "def", "load", "(", "self", ",", "dtype_conversion", "=", "None", ")", ":", "self", ".", "data", "=", "read_tabular", "(", "self", ".", "filename", ",", "dtype_conversion", ")", "with", "open_text", "(", "memote", ".", "experimental", ".", "schemata", ",",...
Load the data table and corresponding validation schema. Parameters ---------- dtype_conversion : dict Column names as keys and corresponding type for loading the data. Please take a look at the `pandas documentation <https://pandas.pydata.org/pandas-docs/sta...
[ "Load", "the", "data", "table", "and", "corresponding", "validation", "schema", "." ]
python
train
semente/django-smuggler
smuggler/views.py
https://github.com/semente/django-smuggler/blob/3be76f4e94e50e927a55a60741fac1a793df83de/smuggler/views.py#L63-L71
def dump_data(request): """Exports data from whole project. """ # Try to grab app_label data app_label = request.GET.get('app_label', []) if app_label: app_label = app_label.split(',') return dump_to_response(request, app_label=app_label, exclude=settings.SMUG...
[ "def", "dump_data", "(", "request", ")", ":", "# Try to grab app_label data", "app_label", "=", "request", ".", "GET", ".", "get", "(", "'app_label'", ",", "[", "]", ")", "if", "app_label", ":", "app_label", "=", "app_label", ".", "split", "(", "','", ")",...
Exports data from whole project.
[ "Exports", "data", "from", "whole", "project", "." ]
python
train
shad7/tvrenamer
tvrenamer/services/tvdb.py
https://github.com/shad7/tvrenamer/blob/7fb59cb02669357e73b7acb92dcb6d74fdff4654/tvrenamer/services/tvdb.py#L46-L57
def get_series_by_name(self, series_name): """Perform lookup for series :param str series_name: series name found within filename :returns: instance of series :rtype: object """ try: return self.api.search_series(name=series_name), None except excepti...
[ "def", "get_series_by_name", "(", "self", ",", "series_name", ")", ":", "try", ":", "return", "self", ".", "api", ".", "search_series", "(", "name", "=", "series_name", ")", ",", "None", "except", "exceptions", ".", "TVDBRequestException", "as", "err", ":", ...
Perform lookup for series :param str series_name: series name found within filename :returns: instance of series :rtype: object
[ "Perform", "lookup", "for", "series" ]
python
train
python-openxml/python-docx
docx/section.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/section.py#L419-L422
def _definition(self): """|HeaderPart| object containing content of this header.""" headerReference = self._sectPr.get_headerReference(self._hdrftr_index) return self._document_part.header_part(headerReference.rId)
[ "def", "_definition", "(", "self", ")", ":", "headerReference", "=", "self", ".", "_sectPr", ".", "get_headerReference", "(", "self", ".", "_hdrftr_index", ")", "return", "self", ".", "_document_part", ".", "header_part", "(", "headerReference", ".", "rId", ")...
|HeaderPart| object containing content of this header.
[ "|HeaderPart|", "object", "containing", "content", "of", "this", "header", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/core/inputsplitter.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/inputsplitter.py#L206-L227
def has_comment(src): """Indicate whether an input line has (i.e. ends in, or is) a comment. This uses tokenize, so it can distinguish comments from # inside strings. Parameters ---------- src : string A single line input string. Returns ------- Boolean: True if sour...
[ "def", "has_comment", "(", "src", ")", ":", "readline", "=", "StringIO", "(", "src", ")", ".", "readline", "toktypes", "=", "set", "(", ")", "try", ":", "for", "t", "in", "tokenize", ".", "generate_tokens", "(", "readline", ")", ":", "toktypes", ".", ...
Indicate whether an input line has (i.e. ends in, or is) a comment. This uses tokenize, so it can distinguish comments from # inside strings. Parameters ---------- src : string A single line input string. Returns ------- Boolean: True if source has a comment.
[ "Indicate", "whether", "an", "input", "line", "has", "(", "i", ".", "e", ".", "ends", "in", "or", "is", ")", "a", "comment", ".", "This", "uses", "tokenize", "so", "it", "can", "distinguish", "comments", "from", "#", "inside", "strings", ".", "Paramete...
python
test
danielperna84/pyhomematic
pyhomematic/devicetypes/generic.py
https://github.com/danielperna84/pyhomematic/blob/8b91f3e84c83f05d289c740d507293a0d6759d8e/pyhomematic/devicetypes/generic.py#L270-L278
def UNREACH(self): """ Returns true if the device or any children is not reachable """ if self._VALUES.get(PARAM_UNREACH, False): return True else: for device in self._hmchannels.values(): if device.UNREACH: return True return F...
[ "def", "UNREACH", "(", "self", ")", ":", "if", "self", ".", "_VALUES", ".", "get", "(", "PARAM_UNREACH", ",", "False", ")", ":", "return", "True", "else", ":", "for", "device", "in", "self", ".", "_hmchannels", ".", "values", "(", ")", ":", "if", "...
Returns true if the device or any children is not reachable
[ "Returns", "true", "if", "the", "device", "or", "any", "children", "is", "not", "reachable" ]
python
train
aestrivex/bctpy
bct/algorithms/core.py
https://github.com/aestrivex/bctpy/blob/4cb0e759eb4a038750b07e23bd29958c400684b8/bct/algorithms/core.py#L300-L365
def kcore_bu(CIJ, k, peel=False): ''' The k-core is the largest subnetwork comprising nodes of degree at least k. This function computes the k-core for a given binary undirected connection matrix by recursively peeling off nodes with degree lower than k, until no such nodes remain. Parameters ...
[ "def", "kcore_bu", "(", "CIJ", ",", "k", ",", "peel", "=", "False", ")", ":", "if", "peel", ":", "peelorder", ",", "peellevel", "=", "(", "[", "]", ",", "[", "]", ")", "iter", "=", "0", "CIJkcore", "=", "CIJ", ".", "copy", "(", ")", "while", ...
The k-core is the largest subnetwork comprising nodes of degree at least k. This function computes the k-core for a given binary undirected connection matrix by recursively peeling off nodes with degree lower than k, until no such nodes remain. Parameters ---------- CIJ : NxN np.ndarray ...
[ "The", "k", "-", "core", "is", "the", "largest", "subnetwork", "comprising", "nodes", "of", "degree", "at", "least", "k", ".", "This", "function", "computes", "the", "k", "-", "core", "for", "a", "given", "binary", "undirected", "connection", "matrix", "by...
python
train
kdeldycke/maildir-deduplicate
maildir_deduplicate/mail.py
https://github.com/kdeldycke/maildir-deduplicate/blob/f1c6ff25b80c6c1a4dc2dc7a65b34d808b0b7733/maildir_deduplicate/mail.py#L128-L138
def hash_key(self): """ Returns the canonical hash of a mail. """ if self.conf.message_id: message_id = self.message.get('Message-Id') if message_id: return message_id.strip() logger.error( "No Message-ID in {}: {}".format(self.path, se...
[ "def", "hash_key", "(", "self", ")", ":", "if", "self", ".", "conf", ".", "message_id", ":", "message_id", "=", "self", ".", "message", ".", "get", "(", "'Message-Id'", ")", "if", "message_id", ":", "return", "message_id", ".", "strip", "(", ")", "logg...
Returns the canonical hash of a mail.
[ "Returns", "the", "canonical", "hash", "of", "a", "mail", "." ]
python
train
python-openxml/python-docx
docx/oxml/table.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/oxml/table.py#L511-L517
def _add_width_of(self, other_tc): """ Add the width of *other_tc* to this cell. Does nothing if either this tc or *other_tc* does not have a specified width. """ if self.width and other_tc.width: self.width += other_tc.width
[ "def", "_add_width_of", "(", "self", ",", "other_tc", ")", ":", "if", "self", ".", "width", "and", "other_tc", ".", "width", ":", "self", ".", "width", "+=", "other_tc", ".", "width" ]
Add the width of *other_tc* to this cell. Does nothing if either this tc or *other_tc* does not have a specified width.
[ "Add", "the", "width", "of", "*", "other_tc", "*", "to", "this", "cell", ".", "Does", "nothing", "if", "either", "this", "tc", "or", "*", "other_tc", "*", "does", "not", "have", "a", "specified", "width", "." ]
python
train
candango/firenado
firenado/config.py
https://github.com/candango/firenado/blob/4b1f628e485b521e161d64169c46a9818f26949f/firenado/config.py#L124-L143
def process_config(config, config_data): """ Populates config with data from the configuration data dict. It handles components, data, log, management and session sections from the configuration data. :param config: The config reference of the object that will hold the configuration data from the c...
[ "def", "process_config", "(", "config", ",", "config_data", ")", ":", "if", "'components'", "in", "config_data", ":", "process_components_config_section", "(", "config", ",", "config_data", "[", "'components'", "]", ")", "if", "'data'", "in", "config_data", ":", ...
Populates config with data from the configuration data dict. It handles components, data, log, management and session sections from the configuration data. :param config: The config reference of the object that will hold the configuration data from the config_data. :param config_data: The configura...
[ "Populates", "config", "with", "data", "from", "the", "configuration", "data", "dict", ".", "It", "handles", "components", "data", "log", "management", "and", "session", "sections", "from", "the", "configuration", "data", "." ]
python
train
junzis/pyModeS
pyModeS/decoder/bds/bds44.py
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds44.py#L92-L118
def temp44(msg): """Static air temperature. Args: msg (String): 28 bytes hexadecimal message string Returns: float, float: temperature and alternative temperature in Celsius degree. Note: Two values returns due to what seems to be an inconsistancy error in ICAO 9871...
[ "def", "temp44", "(", "msg", ")", ":", "d", "=", "hex2bin", "(", "data", "(", "msg", ")", ")", "sign", "=", "int", "(", "d", "[", "23", "]", ")", "value", "=", "bin2int", "(", "d", "[", "24", ":", "34", "]", ")", "if", "sign", ":", "value",...
Static air temperature. Args: msg (String): 28 bytes hexadecimal message string Returns: float, float: temperature and alternative temperature in Celsius degree. Note: Two values returns due to what seems to be an inconsistancy error in ICAO 9871 (2008) Appendix A-67.
[ "Static", "air", "temperature", "." ]
python
train
6809/MC6809
MC6809/components/mc6809_base.py
https://github.com/6809/MC6809/blob/6ba2f5106df46689017b5d0b6d84d43b7ee6a240/MC6809/components/mc6809_base.py#L259-L265
def add_sync_callback(self, callback_cycles, callback): """ Add a CPU cycle triggered callback """ self.sync_callbacks_cyles[callback] = 0 self.sync_callbacks.append([callback_cycles, callback]) if self.quickest_sync_callback_cycles is None or \ self.quickest_sync...
[ "def", "add_sync_callback", "(", "self", ",", "callback_cycles", ",", "callback", ")", ":", "self", ".", "sync_callbacks_cyles", "[", "callback", "]", "=", "0", "self", ".", "sync_callbacks", ".", "append", "(", "[", "callback_cycles", ",", "callback", "]", ...
Add a CPU cycle triggered callback
[ "Add", "a", "CPU", "cycle", "triggered", "callback" ]
python
train
yamcs/yamcs-python
yamcs-client/yamcs/storage/client.py
https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/storage/client.py#L63-L73
def create_bucket(self, instance, bucket_name): """ Create a new bucket in the specified instance. :param str instance: A Yamcs instance name. :param str bucket_name: The name of the bucket. """ req = rest_pb2.CreateBucketRequest() req.name = bucket_name ...
[ "def", "create_bucket", "(", "self", ",", "instance", ",", "bucket_name", ")", ":", "req", "=", "rest_pb2", ".", "CreateBucketRequest", "(", ")", "req", ".", "name", "=", "bucket_name", "url", "=", "'/buckets/{}'", ".", "format", "(", "instance", ")", "sel...
Create a new bucket in the specified instance. :param str instance: A Yamcs instance name. :param str bucket_name: The name of the bucket.
[ "Create", "a", "new", "bucket", "in", "the", "specified", "instance", "." ]
python
train
thiagopbueno/rddl2tf
rddl2tf/compiler.py
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/compiler.py#L340-L377
def compile_action_bound_constraints(self, state: Sequence[tf.Tensor]) -> Dict[str, Bounds]: '''Compiles all actions bounds for the given `state`. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from action names to a pair of...
[ "def", "compile_action_bound_constraints", "(", "self", ",", "state", ":", "Sequence", "[", "tf", ".", "Tensor", "]", ")", "->", "Dict", "[", "str", ",", "Bounds", "]", ":", "scope", "=", "self", ".", "action_precondition_scope", "(", "state", ")", "lower_...
Compiles all actions bounds for the given `state`. Args: state (Sequence[tf.Tensor]): The current state fluents. Returns: A mapping from action names to a pair of :obj:`rddl2tf.fluent.TensorFluent` representing its lower and upper bounds.
[ "Compiles", "all", "actions", "bounds", "for", "the", "given", "state", "." ]
python
train
nutechsoftware/alarmdecoder
alarmdecoder/decoder.py
https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L483-L497
def _handle_expander_message(self, data): """ Handle expander messages. :param data: expander message to parse :type data: string :returns: :py:class:`~alarmdecoder.messages.ExpanderMessage` """ msg = ExpanderMessage(data) self._update_internal_states(m...
[ "def", "_handle_expander_message", "(", "self", ",", "data", ")", ":", "msg", "=", "ExpanderMessage", "(", "data", ")", "self", ".", "_update_internal_states", "(", "msg", ")", "self", ".", "on_expander_message", "(", "message", "=", "msg", ")", "return", "m...
Handle expander messages. :param data: expander message to parse :type data: string :returns: :py:class:`~alarmdecoder.messages.ExpanderMessage`
[ "Handle", "expander", "messages", "." ]
python
train
mediawiki-utilities/python-mwpersistence
mwpersistence/state.py
https://github.com/mediawiki-utilities/python-mwpersistence/blob/2b98847fb8acaca38b3cbf94bde3fd7e27d2b67d/mwpersistence/state.py#L113-L135
def update(self, text, revision=None): """ Modifies the internal state based a change to the content and returns the sets of words added and removed. :Parameters: text : str The text content of a revision revision : `mixed` Revisio...
[ "def", "update", "(", "self", ",", "text", ",", "revision", "=", "None", ")", ":", "return", "self", ".", "_update", "(", "text", "=", "text", ",", "revision", "=", "revision", ")" ]
Modifies the internal state based a change to the content and returns the sets of words added and removed. :Parameters: text : str The text content of a revision revision : `mixed` Revision metadata :Returns: A triple of lists...
[ "Modifies", "the", "internal", "state", "based", "a", "change", "to", "the", "content", "and", "returns", "the", "sets", "of", "words", "added", "and", "removed", "." ]
python
train
SmokinCaterpillar/pypet
pypet/storageservice.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/storageservice.py#L1929-L2014
def _trj_load_meta_data(self, traj, load_data, as_new, with_run_information, force): """Loads meta information about the trajectory Checks if the version number does not differ from current pypet version Loads, comment, timestamp, name, version from disk in case trajectory is not loaded ...
[ "def", "_trj_load_meta_data", "(", "self", ",", "traj", ",", "load_data", ",", "as_new", ",", "with_run_information", ",", "force", ")", ":", "metatable", "=", "self", ".", "_overview_group", ".", "info", "metarow", "=", "metatable", "[", "0", "]", "try", ...
Loads meta information about the trajectory Checks if the version number does not differ from current pypet version Loads, comment, timestamp, name, version from disk in case trajectory is not loaded as new. Updates the run information as well.
[ "Loads", "meta", "information", "about", "the", "trajectory" ]
python
test
raphaelvallat/pingouin
pingouin/correlation.py
https://github.com/raphaelvallat/pingouin/blob/58b19fa4fffbfe09d58b456e3926a148249e4d9b/pingouin/correlation.py#L664-L758
def rm_corr(data=None, x=None, y=None, subject=None, tail='two-sided'): """Repeated measures correlation. Parameters ---------- data : pd.DataFrame Dataframe. x, y : string Name of columns in ``data`` containing the two dependent variables. subject : string Name of colum...
[ "def", "rm_corr", "(", "data", "=", "None", ",", "x", "=", "None", ",", "y", "=", "None", ",", "subject", "=", "None", ",", "tail", "=", "'two-sided'", ")", ":", "from", "pingouin", "import", "ancova", ",", "power_corr", "# Safety checks", "assert", "i...
Repeated measures correlation. Parameters ---------- data : pd.DataFrame Dataframe. x, y : string Name of columns in ``data`` containing the two dependent variables. subject : string Name of column in ``data`` containing the subject indicator. tail : string Speci...
[ "Repeated", "measures", "correlation", "." ]
python
train
dsoprea/PyEasyArchive
libarchive/adapters/archive_read.py
https://github.com/dsoprea/PyEasyArchive/blob/50414b9fa9a1055435499b5b2e4b2a336a40dff6/libarchive/adapters/archive_read.py#L399-L406
def file_pour(filepath, block_size=10240, *args, **kwargs): """Write physical files from entries.""" def opener(archive_res): _LOGGER.debug("Opening from file (file_pour): %s", filepath) _archive_read_open_filename(archive_res, filepath, block_size) return _pour(opener, *args, flags=0, **k...
[ "def", "file_pour", "(", "filepath", ",", "block_size", "=", "10240", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "opener", "(", "archive_res", ")", ":", "_LOGGER", ".", "debug", "(", "\"Opening from file (file_pour): %s\"", ",", "filepath", ...
Write physical files from entries.
[ "Write", "physical", "files", "from", "entries", "." ]
python
train
inveniosoftware/invenio-stats
invenio_stats/contrib/registrations.py
https://github.com/inveniosoftware/invenio-stats/blob/d877ae5462084abb4a28a20f1ebb3d636769c1bc/invenio_stats/contrib/registrations.py#L87-L121
def register_queries(): """Register queries.""" return [ dict( query_name='bucket-file-download-histogram', query_class=ESDateHistogramQuery, query_config=dict( index='stats-file-download', doc_type='file-download-day-aggregation', ...
[ "def", "register_queries", "(", ")", ":", "return", "[", "dict", "(", "query_name", "=", "'bucket-file-download-histogram'", ",", "query_class", "=", "ESDateHistogramQuery", ",", "query_config", "=", "dict", "(", "index", "=", "'stats-file-download'", ",", "doc_type...
Register queries.
[ "Register", "queries", "." ]
python
valid
DataDog/integrations-core
openstack_controller/datadog_checks/openstack_controller/api.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/openstack_controller/datadog_checks/openstack_controller/api.py#L556-L572
def _get_user_identity(user): """ Parse user identity out of init_config To guarantee a uniquely identifiable user, expects {"user": {"name": "my_username", "password": "my_password", "domain": {"id": "my_domain_id"} } } """ if...
[ "def", "_get_user_identity", "(", "user", ")", ":", "if", "not", "(", "user", "and", "user", ".", "get", "(", "'name'", ")", "and", "user", ".", "get", "(", "'password'", ")", "and", "user", ".", "get", "(", "\"domain\"", ")", "and", "user", ".", "...
Parse user identity out of init_config To guarantee a uniquely identifiable user, expects {"user": {"name": "my_username", "password": "my_password", "domain": {"id": "my_domain_id"} } }
[ "Parse", "user", "identity", "out", "of", "init_config" ]
python
train
henzk/featuremonkey
featuremonkey/composer.py
https://github.com/henzk/featuremonkey/blob/e44414fc68427bcd71ad33ec2d816da0dd78eefa/featuremonkey/composer.py#L219-L228
def _compose_pair(self, role, base): ''' composes onto base by applying the role ''' # apply transformations in role to base for attrname in dir(role): transformation = getattr(role, attrname) self._apply_transformation(role, base, transformation, attrname...
[ "def", "_compose_pair", "(", "self", ",", "role", ",", "base", ")", ":", "# apply transformations in role to base", "for", "attrname", "in", "dir", "(", "role", ")", ":", "transformation", "=", "getattr", "(", "role", ",", "attrname", ")", "self", ".", "_app...
composes onto base by applying the role
[ "composes", "onto", "base", "by", "applying", "the", "role" ]
python
train
log2timeline/plaso
plaso/cli/storage_media_tool.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/cli/storage_media_tool.py#L902-L943
def _ScanEncryptedVolume(self, scan_context, scan_node): """Scans an encrypted volume scan node for volume and file systems. Args: scan_context (SourceScannerContext): source scanner context. scan_node (SourceScanNode): volume scan node. Raises: SourceScannerError: if the format of or wi...
[ "def", "_ScanEncryptedVolume", "(", "self", ",", "scan_context", ",", "scan_node", ")", ":", "if", "not", "scan_node", "or", "not", "scan_node", ".", "path_spec", ":", "raise", "errors", ".", "SourceScannerError", "(", "'Invalid or missing scan node.'", ")", "cred...
Scans an encrypted volume scan node for volume and file systems. Args: scan_context (SourceScannerContext): source scanner context. scan_node (SourceScanNode): volume scan node. Raises: SourceScannerError: if the format of or within the source is not supported, the scan node is inv...
[ "Scans", "an", "encrypted", "volume", "scan", "node", "for", "volume", "and", "file", "systems", "." ]
python
train
quintusdias/glymur
glymur/lib/openjp2.py
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/lib/openjp2.py#L1275-L1287
def stream_destroy(stream): """Wraps openjp2 library function opj_stream_destroy. Destroys the stream created by create_stream. Parameters ---------- stream : STREAM_TYPE_P The file stream. """ OPENJP2.opj_stream_destroy.argtypes = [STREAM_TYPE_P] OPENJP2.opj_stream_destroy.res...
[ "def", "stream_destroy", "(", "stream", ")", ":", "OPENJP2", ".", "opj_stream_destroy", ".", "argtypes", "=", "[", "STREAM_TYPE_P", "]", "OPENJP2", ".", "opj_stream_destroy", ".", "restype", "=", "ctypes", ".", "c_void_p", "OPENJP2", ".", "opj_stream_destroy", "...
Wraps openjp2 library function opj_stream_destroy. Destroys the stream created by create_stream. Parameters ---------- stream : STREAM_TYPE_P The file stream.
[ "Wraps", "openjp2", "library", "function", "opj_stream_destroy", "." ]
python
train
antevens/listen
listen/signal_handler.py
https://github.com/antevens/listen/blob/d3ddff8e7fbfb672c5bd7f6f4febeb5e921d8c67/listen/signal_handler.py#L65-L92
def default_handler(self, signum, frame): """ Default handler, a generic callback method for signal processing""" self.log.debug("Signal handler called with signal: {0}".format(signum)) # 1. If signal is HUP restart the python process # 2. If signal is TERM, INT or QUIT we try to cleanup...
[ "def", "default_handler", "(", "self", ",", "signum", ",", "frame", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Signal handler called with signal: {0}\"", ".", "format", "(", "signum", ")", ")", "# 1. If signal is HUP restart the python process", "# 2. If sign...
Default handler, a generic callback method for signal processing
[ "Default", "handler", "a", "generic", "callback", "method", "for", "signal", "processing" ]
python
test
ml4ai/delphi
delphi/translators/for2py/arrays.py
https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/delphi/translators/for2py/arrays.py#L165-L176
def idx2subs(idx_list): """Given a list idx_list of index values for each dimension of an array, idx2subs() returns a list of the tuples of subscripts for all of the array elements specified by those index values. Note: This code adapted from that posted by jfs at https://stackoverflo...
[ "def", "idx2subs", "(", "idx_list", ")", ":", "if", "not", "idx_list", ":", "return", "[", "(", ")", "]", "return", "[", "items", "+", "(", "item", ",", ")", "for", "items", "in", "idx2subs", "(", "idx_list", "[", ":", "-", "1", "]", ")", "for", ...
Given a list idx_list of index values for each dimension of an array, idx2subs() returns a list of the tuples of subscripts for all of the array elements specified by those index values. Note: This code adapted from that posted by jfs at https://stackoverflow.com/questions/533905/get-the-...
[ "Given", "a", "list", "idx_list", "of", "index", "values", "for", "each", "dimension", "of", "an", "array", "idx2subs", "()", "returns", "a", "list", "of", "the", "tuples", "of", "subscripts", "for", "all", "of", "the", "array", "elements", "specified", "b...
python
train
pandas-dev/pandas
pandas/io/packers.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/packers.py#L714-L725
def pack(o, default=encode, encoding='utf-8', unicode_errors='strict', use_single_float=False, autoreset=1, use_bin_type=1): """ Pack an object and return the packed bytes. """ return Packer(default=default, encoding=encoding, unicode_errors=unicode_errors, ...
[ "def", "pack", "(", "o", ",", "default", "=", "encode", ",", "encoding", "=", "'utf-8'", ",", "unicode_errors", "=", "'strict'", ",", "use_single_float", "=", "False", ",", "autoreset", "=", "1", ",", "use_bin_type", "=", "1", ")", ":", "return", "Packer...
Pack an object and return the packed bytes.
[ "Pack", "an", "object", "and", "return", "the", "packed", "bytes", "." ]
python
train
topic2k/pygcgen
pygcgen/generator.py
https://github.com/topic2k/pygcgen/blob/c41701815df2c8c3a57fd5f7b8babe702127c8a1/pygcgen/generator.py#L935-L948
def version_of_first_item(self): """ Try to detect the newest tag from self.options.base, otherwise return a special value indicating the creation of the repo. :rtype: str :return: Tag name to use as 'oldest' tag. May be special value, indicating the creation of...
[ "def", "version_of_first_item", "(", "self", ")", ":", "try", ":", "sections", "=", "read_changelog", "(", "self", ".", "options", ")", "return", "sections", "[", "0", "]", "[", "\"version\"", "]", "except", "(", "IOError", ",", "TypeError", ")", ":", "r...
Try to detect the newest tag from self.options.base, otherwise return a special value indicating the creation of the repo. :rtype: str :return: Tag name to use as 'oldest' tag. May be special value, indicating the creation of the repo.
[ "Try", "to", "detect", "the", "newest", "tag", "from", "self", ".", "options", ".", "base", "otherwise", "return", "a", "special", "value", "indicating", "the", "creation", "of", "the", "repo", "." ]
python
valid
RiotGames/cloud-inquisitor
plugins/public/cinq-auditor-vpc-flowlogs/cinq_auditor_vpc_flowlogs/__init__.py
https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/plugins/public/cinq-auditor-vpc-flowlogs/cinq_auditor_vpc_flowlogs/__init__.py#L185-L225
def create_vpc_flow_logs(self, account, region, vpc_id, iam_role_arn): """Create a new VPC Flow log Args: account (:obj:`Account`): Account to create the flow in region (`str`): Region to create the flow in vpc_id (`str`): ID of the VPC to create the flow for ...
[ "def", "create_vpc_flow_logs", "(", "self", ",", "account", ",", "region", ",", "vpc_id", ",", "iam_role_arn", ")", ":", "try", ":", "flow", "=", "self", ".", "session", ".", "client", "(", "'ec2'", ",", "region", ")", "flow", ".", "create_flow_logs", "(...
Create a new VPC Flow log Args: account (:obj:`Account`): Account to create the flow in region (`str`): Region to create the flow in vpc_id (`str`): ID of the VPC to create the flow for iam_role_arn (`str`): ARN of the IAM role used to post logs to the log group ...
[ "Create", "a", "new", "VPC", "Flow", "log" ]
python
train
mbedmicro/pyOCD
pyocd/probe/stlink/detect/darwin.py
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/darwin.py#L113-L123
def _mount_points(self): """ Returns map {volume_id: mount_point} """ diskutil_ls = subprocess.Popen( ["diskutil", "list", "-plist"], stdout=subprocess.PIPE ) disks = _plist_from_popen(diskutil_ls) return { disk["DeviceIdentifier"]: disk.get("MountPoint",...
[ "def", "_mount_points", "(", "self", ")", ":", "diskutil_ls", "=", "subprocess", ".", "Popen", "(", "[", "\"diskutil\"", ",", "\"list\"", ",", "\"-plist\"", "]", ",", "stdout", "=", "subprocess", ".", "PIPE", ")", "disks", "=", "_plist_from_popen", "(", "d...
Returns map {volume_id: mount_point}
[ "Returns", "map", "{", "volume_id", ":", "mount_point", "}" ]
python
train
GetBlimp/django-rest-framework-jwt
rest_framework_jwt/views.py
https://github.com/GetBlimp/django-rest-framework-jwt/blob/0a0bd402ec21fd6b9a5f715d114411836fbb2923/rest_framework_jwt/views.py#L45-L52
def get_serializer(self, *args, **kwargs): """ Return the serializer instance that should be used for validating and deserializing input, and for serializing output. """ serializer_class = self.get_serializer_class() kwargs['context'] = self.get_serializer_context() ...
[ "def", "get_serializer", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "serializer_class", "=", "self", ".", "get_serializer_class", "(", ")", "kwargs", "[", "'context'", "]", "=", "self", ".", "get_serializer_context", "(", ")", "retur...
Return the serializer instance that should be used for validating and deserializing input, and for serializing output.
[ "Return", "the", "serializer", "instance", "that", "should", "be", "used", "for", "validating", "and", "deserializing", "input", "and", "for", "serializing", "output", "." ]
python
train
pip-services3-python/pip-services3-commons-python
pip_services3_commons/data/AnyValueMap.py
https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/AnyValueMap.py#L395-L404
def get_as_array(self, key): """ Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible. :param key: an index of element to get. :return: AnyValueMap value of the element or empty AnyValueMap if conversion is not supported. """ ...
[ "def", "get_as_array", "(", "self", ",", "key", ")", ":", "value", "=", "self", ".", "get", "(", "key", ")", "return", "AnyValueMap", ".", "from_value", "(", "value", ")" ]
Converts map element into an AnyValueMap or returns empty AnyValueMap if conversion is not possible. :param key: an index of element to get. :return: AnyValueMap value of the element or empty AnyValueMap if conversion is not supported.
[ "Converts", "map", "element", "into", "an", "AnyValueMap", "or", "returns", "empty", "AnyValueMap", "if", "conversion", "is", "not", "possible", "." ]
python
train