repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
trailofbits/manticore
manticore/utils/emulate.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/utils/emulate.py#L179-L187
def _hook_syscall(self, uc, data): """ Unicorn hook that transfers control to Manticore so it can execute the syscall """ logger.debug(f"Stopping emulation at {hex(uc.reg_read(self._to_unicorn_id('RIP')))} to perform syscall") self.sync_unicorn_to_manticore() from ..nativ...
[ "def", "_hook_syscall", "(", "self", ",", "uc", ",", "data", ")", ":", "logger", ".", "debug", "(", "f\"Stopping emulation at {hex(uc.reg_read(self._to_unicorn_id('RIP')))} to perform syscall\"", ")", "self", ".", "sync_unicorn_to_manticore", "(", ")", "from", ".", ".",...
Unicorn hook that transfers control to Manticore so it can execute the syscall
[ "Unicorn", "hook", "that", "transfers", "control", "to", "Manticore", "so", "it", "can", "execute", "the", "syscall" ]
python
valid
44.555556
bloomreach/s4cmd
s4cmd.py
https://github.com/bloomreach/s4cmd/blob/bb51075bf43703e7cd95aa39288cf7732ec13a6d/s4cmd.py#L209-L213
def clean_tempfiles(): '''Clean up temp files''' for fn in TEMP_FILES: if os.path.exists(fn): os.unlink(fn)
[ "def", "clean_tempfiles", "(", ")", ":", "for", "fn", "in", "TEMP_FILES", ":", "if", "os", ".", "path", ".", "exists", "(", "fn", ")", ":", "os", ".", "unlink", "(", "fn", ")" ]
Clean up temp files
[ "Clean", "up", "temp", "files" ]
python
test
23.4
quodlibet/mutagen
mutagen/easyid3.py
https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/easyid3.py#L176-L199
def save(self, filething=None, v1=1, v2_version=4, v23_sep='/', padding=None): """save(filething=None, v1=1, v2_version=4, v23_sep='/', padding=None) Save changes to a file. See :meth:`mutagen.id3.ID3.save` for more info. """ if v2_version == 3: # EasyI...
[ "def", "save", "(", "self", ",", "filething", "=", "None", ",", "v1", "=", "1", ",", "v2_version", "=", "4", ",", "v23_sep", "=", "'/'", ",", "padding", "=", "None", ")", ":", "if", "v2_version", "==", "3", ":", "# EasyID3 only works with v2.4 frames, so...
save(filething=None, v1=1, v2_version=4, v23_sep='/', padding=None) Save changes to a file. See :meth:`mutagen.id3.ID3.save` for more info.
[ "save", "(", "filething", "=", "None", "v1", "=", "1", "v2_version", "=", "4", "v23_sep", "=", "/", "padding", "=", "None", ")" ]
python
train
42.291667
xzased/lvm2py
lvm2py/vg.py
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L82-L96
def close(self): """ Closes the lvm and vg_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError """ if self.handle: cl = lvm_vg_clo...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "handle", ":", "cl", "=", "lvm_vg_close", "(", "self", ".", "handle", ")", "if", "cl", "!=", "0", ":", "raise", "HandleError", "(", "\"Failed to close VG handle after init check.\"", ")", "self", "....
Closes the lvm and vg_t handle. Usually you would never need to use this method unless you are doing operations using the ctypes function wrappers in conversion.py *Raises:* * HandleError
[ "Closes", "the", "lvm", "and", "vg_t", "handle", ".", "Usually", "you", "would", "never", "need", "to", "use", "this", "method", "unless", "you", "are", "doing", "operations", "using", "the", "ctypes", "function", "wrappers", "in", "conversion", ".", "py" ]
python
train
32.333333
fboender/ansible-cmdb
src/ansible-cmdb.py
https://github.com/fboender/ansible-cmdb/blob/ebd960ac10684e8c9ec2b12751bba2c4c9504ab7/src/ansible-cmdb.py#L48-L65
def get_data_dir(): """ Find out our installation prefix and data directory. These can be in different places depending on how ansible-cmdb was installed. """ data_dir_paths = [ os.path.join(os.path.dirname(ansiblecmdb.__file__), 'data'), os.path.join(os.path.dirname(sys.argv[0]), '....
[ "def", "get_data_dir", "(", ")", ":", "data_dir_paths", "=", "[", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "ansiblecmdb", ".", "__file__", ")", ",", "'data'", ")", ",", "os", ".", "path", ".", "join", "(", "os", ...
Find out our installation prefix and data directory. These can be in different places depending on how ansible-cmdb was installed.
[ "Find", "out", "our", "installation", "prefix", "and", "data", "directory", ".", "These", "can", "be", "in", "different", "places", "depending", "on", "how", "ansible", "-", "cmdb", "was", "installed", "." ]
python
train
37.611111
saltstack/salt
salt/utils/vmware.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/vmware.py#L1426-L1447
def list_objects(service_instance, vim_object, properties=None): ''' Returns a simple list of objects from a given service instance. service_instance The Service Instance for which to obtain a list of objects. object_type The type of content for which to obtain information. proper...
[ "def", "list_objects", "(", "service_instance", ",", "vim_object", ",", "properties", "=", "None", ")", ":", "if", "properties", "is", "None", ":", "properties", "=", "[", "'name'", "]", "items", "=", "[", "]", "item_list", "=", "get_mors_with_properties", "...
Returns a simple list of objects from a given service instance. service_instance The Service Instance for which to obtain a list of objects. object_type The type of content for which to obtain information. properties An optional list of object properties used to return reference r...
[ "Returns", "a", "simple", "list", "of", "objects", "from", "a", "given", "service", "instance", "." ]
python
train
30.590909
yandex/yandex-tank
yandextank/stepper/mark.py
https://github.com/yandex/yandex-tank/blob/d71d63b6ab5de8b8a5ea2b728b6ab9ac0b1ba71b/yandextank/stepper/mark.py#L54-L98
def get_marker(marker_type, enum_ammo=False): ''' Returns a marker function of the requested marker_type >>> marker = get_marker('uniq')(__test_missile) >>> type(marker) <type 'str'> >>> len(marker) 32 >>> get_marker('uri')(__test_missile) '_example_search_hello_help_us' >>> m...
[ "def", "get_marker", "(", "marker_type", ",", "enum_ammo", "=", "False", ")", ":", "try", ":", "limit", "=", "int", "(", "marker_type", ")", "if", "limit", ":", "marker", "=", "__UriMarker", "(", "limit", ")", "else", ":", "def", "marker", "(", "m", ...
Returns a marker function of the requested marker_type >>> marker = get_marker('uniq')(__test_missile) >>> type(marker) <type 'str'> >>> len(marker) 32 >>> get_marker('uri')(__test_missile) '_example_search_hello_help_us' >>> marker = get_marker('non-existent')(__test_missile) Tra...
[ "Returns", "a", "marker", "function", "of", "the", "requested", "marker_type" ]
python
test
25.155556
google/pyringe
pyringe/payload/libpython.py
https://github.com/google/pyringe/blob/76dff5d1ac29cd5e7bf32677654a83291a15ad8a/pyringe/payload/libpython.py#L131-L163
def field(self, name): ''' Get the gdb.Value for the given field within the PyObject, coping with some python 2 versus python 3 differences. Various libpython types are defined using the "PyObject_HEAD" and "PyObject_VAR_HEAD" macros. In Python 2, this these are defined...
[ "def", "field", "(", "self", ",", "name", ")", ":", "if", "self", ".", "is_null", "(", ")", ":", "raise", "NullPyObjectPtr", "(", "self", ")", "if", "name", "==", "'ob_type'", ":", "pyo_ptr", "=", "self", ".", "_gdbval", ".", "cast", "(", "PyObjectPt...
Get the gdb.Value for the given field within the PyObject, coping with some python 2 versus python 3 differences. Various libpython types are defined using the "PyObject_HEAD" and "PyObject_VAR_HEAD" macros. In Python 2, this these are defined so that "ob_type" and (for a var o...
[ "Get", "the", "gdb", ".", "Value", "for", "the", "given", "field", "within", "the", "PyObject", "coping", "with", "some", "python", "2", "versus", "python", "3", "differences", "." ]
python
train
37.393939
dropbox/stone
stone/backend.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/backend.py#L381-L451
def generate_multiline_list( self, items, # type: typing.List[typing.Text] before='', # type: typing.Text after='', # type: typing.Text delim=('(', ')'), # type: DelimTuple compact=True, # type: bool sep=',', ...
[ "def", "generate_multiline_list", "(", "self", ",", "items", ",", "# type: typing.List[typing.Text]", "before", "=", "''", ",", "# type: typing.Text", "after", "=", "''", ",", "# type: typing.Text", "delim", "=", "(", "'('", ",", "')'", ")", ",", "# type: DelimTup...
Given a list of items, emits one item per line. This is convenient for function prototypes and invocations, as well as for instantiating arrays, sets, and maps in some languages. TODO(kelkabany): A backend that uses tabs cannot be used with this if compact is false. Args: ...
[ "Given", "a", "list", "of", "items", "emits", "one", "item", "per", "line", "." ]
python
train
42.267606
saltstack/salt
salt/modules/influxdbmod.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/influxdbmod.py#L554-L574
def continuous_query_exists(database, name, **client_args): ''' Check if continuous query with given name exists on the database. database Name of the database for which the continuous query was defined. name Name of the continuous query to check. CLI Example: .. code...
[ "def", "continuous_query_exists", "(", "database", ",", "name", ",", "*", "*", "client_args", ")", ":", "if", "get_continuous_query", "(", "database", ",", "name", ",", "*", "*", "client_args", ")", ":", "return", "True", "return", "False" ]
Check if continuous query with given name exists on the database. database Name of the database for which the continuous query was defined. name Name of the continuous query to check. CLI Example: .. code-block:: bash salt '*' influxdb.continuous_query_exists metrics...
[ "Check", "if", "continuous", "query", "with", "given", "name", "exists", "on", "the", "database", "." ]
python
train
23.142857
weso/CWR-DataApi
cwr/grammar/field/basic.py
https://github.com/weso/CWR-DataApi/blob/f3b6ba8308c901b6ab87073c155c08e30692333c/cwr/grammar/field/basic.py#L374-L401
def date(name=None): """ Creates the grammar for a Date (D) field, accepting only numbers in a certain pattern. :param name: name for the field :return: grammar for the date field """ if name is None: name = 'Date Field' # Basic field # This regex allows values from 000001...
[ "def", "date", "(", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "'Date Field'", "# Basic field", "# This regex allows values from 00000101 to 99991231", "field", "=", "pp", ".", "Regex", "(", "'[0-9][0-9][0-9][0-9](0[1-9]|1[0-2])'", ...
Creates the grammar for a Date (D) field, accepting only numbers in a certain pattern. :param name: name for the field :return: grammar for the date field
[ "Creates", "the", "grammar", "for", "a", "Date", "(", "D", ")", "field", "accepting", "only", "numbers", "in", "a", "certain", "pattern", "." ]
python
train
23.821429
markovmodel/msmtools
msmtools/estimation/dense/bootstrapping.py
https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/estimation/dense/bootstrapping.py#L35-L49
def number_of_states(dtrajs): r""" Determine the number of states from a set of discrete trajectories Parameters ---------- dtrajs : list of int-arrays discrete trajectories """ # determine number of states n nmax = 0 for dtraj in dtrajs: nmax = max(nmax, np.max(dtra...
[ "def", "number_of_states", "(", "dtrajs", ")", ":", "# determine number of states n", "nmax", "=", "0", "for", "dtraj", "in", "dtrajs", ":", "nmax", "=", "max", "(", "nmax", ",", "np", ".", "max", "(", "dtraj", ")", ")", "# return number of states", "return"...
r""" Determine the number of states from a set of discrete trajectories Parameters ---------- dtrajs : list of int-arrays discrete trajectories
[ "r", "Determine", "the", "number", "of", "states", "from", "a", "set", "of", "discrete", "trajectories" ]
python
train
23.933333
drj11/pypng
code/mkiccp.py
https://github.com/drj11/pypng/blob/b8220ca9f58e4c5bc1d507e713744fcb8c049225/code/mkiccp.py#L15-L26
def black(m): """Return a function that maps all values from [0.0,m] to 0, and maps the range [m,1.0] into [0.0, 1.0] linearly. """ m = float(m) def f(x): if x <= m: return 0.0 return (x - m) / (1.0 - m) return f
[ "def", "black", "(", "m", ")", ":", "m", "=", "float", "(", "m", ")", "def", "f", "(", "x", ")", ":", "if", "x", "<=", "m", ":", "return", "0.0", "return", "(", "x", "-", "m", ")", "/", "(", "1.0", "-", "m", ")", "return", "f" ]
Return a function that maps all values from [0.0,m] to 0, and maps the range [m,1.0] into [0.0, 1.0] linearly.
[ "Return", "a", "function", "that", "maps", "all", "values", "from", "[", "0", ".", "0", "m", "]", "to", "0", "and", "maps", "the", "range", "[", "m", "1", ".", "0", "]", "into", "[", "0", ".", "0", "1", ".", "0", "]", "linearly", "." ]
python
train
21.25
Chilipp/psy-simple
psy_simple/widgets/texts.py
https://github.com/Chilipp/psy-simple/blob/7d916406a6d3c3c27c0b7102f98fef07a4da0a61/psy_simple/widgets/texts.py#L66-L92
def mpl_weight2qt(weight): """Convert a weight from matplotlib definition to a Qt weight Parameters ---------- weight: int or string Either an integer between 1 and 1000 or a string out of :attr:`weights_mpl2qt` Returns ------- int One type of the PyQt5.QtGui.QFont....
[ "def", "mpl_weight2qt", "(", "weight", ")", ":", "try", ":", "weight", "=", "weights_mpl2qt", "[", "weight", "]", "except", "KeyError", ":", "try", ":", "weight", "=", "float", "(", "weight", ")", "/", "10", "except", "(", "ValueError", ",", "TypeError",...
Convert a weight from matplotlib definition to a Qt weight Parameters ---------- weight: int or string Either an integer between 1 and 1000 or a string out of :attr:`weights_mpl2qt` Returns ------- int One type of the PyQt5.QtGui.QFont.Weight
[ "Convert", "a", "weight", "from", "matplotlib", "definition", "to", "a", "Qt", "weight" ]
python
train
28.37037
icgood/pysasl
pysasl/__init__.py
https://github.com/icgood/pysasl/blob/241bdd349577cc99f05c4239755c307e6a46018c/pysasl/__init__.py#L326-L338
def plaintext(cls): """Uses only authentication mechanisms that provide the credentials in un-hashed form, typically meaning :attr:`~pysasl.AuthenticationCredentials.has_secret` is True. Returns: A new :class:`SASLAuth` object. """ builtin_mechs = cls._get_b...
[ "def", "plaintext", "(", "cls", ")", ":", "builtin_mechs", "=", "cls", ".", "_get_builtin_mechanisms", "(", ")", "plaintext_mechs", "=", "[", "mech", "for", "_", ",", "mech", "in", "builtin_mechs", ".", "items", "(", ")", "if", "mech", ".", "insecure", "...
Uses only authentication mechanisms that provide the credentials in un-hashed form, typically meaning :attr:`~pysasl.AuthenticationCredentials.has_secret` is True. Returns: A new :class:`SASLAuth` object.
[ "Uses", "only", "authentication", "mechanisms", "that", "provide", "the", "credentials", "in", "un", "-", "hashed", "form", "typically", "meaning", ":", "attr", ":", "~pysasl", ".", "AuthenticationCredentials", ".", "has_secret", "is", "True", "." ]
python
train
39.384615
biolink/ontobio
ontobio/ontol.py
https://github.com/biolink/ontobio/blob/4e512a7831cfe6bc1b32f2c3be2ba41bc5cf7345/ontobio/ontol.py#L832-L839
def add_xref(self, id, xref): """ Adds an xref to the xref graph """ # note: does not update meta object if self.xref_graph is None: self.xref_graph = nx.MultiGraph() self.xref_graph.add_edge(xref, id)
[ "def", "add_xref", "(", "self", ",", "id", ",", "xref", ")", ":", "# note: does not update meta object", "if", "self", ".", "xref_graph", "is", "None", ":", "self", ".", "xref_graph", "=", "nx", ".", "MultiGraph", "(", ")", "self", ".", "xref_graph", ".", ...
Adds an xref to the xref graph
[ "Adds", "an", "xref", "to", "the", "xref", "graph" ]
python
train
31.75
EliotBerriot/lifter
lifter/utils.py
https://github.com/EliotBerriot/lifter/blob/9b4394b476cddd952b2af9540affc03f2977163d/lifter/utils.py#L87-L91
def unique_everseen(seq): """Solution found here : http://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-python-whilst-preserving-order""" seen = set() seen_add = seen.add return [x for x in seq if not (x in seen or seen_add(x))]
[ "def", "unique_everseen", "(", "seq", ")", ":", "seen", "=", "set", "(", ")", "seen_add", "=", "seen", ".", "add", "return", "[", "x", "for", "x", "in", "seq", "if", "not", "(", "x", "in", "seen", "or", "seen_add", "(", "x", ")", ")", "]" ]
Solution found here : http://stackoverflow.com/questions/480214/how-do-you-remove-duplicates-from-a-list-in-python-whilst-preserving-order
[ "Solution", "found", "here", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "480214", "/", "how", "-", "do", "-", "you", "-", "remove", "-", "duplicates", "-", "from", "-", "a", "-", "list", "-", "in", "-", "python", "-...
python
train
54.6
Yubico/yubikey-manager
ykman/cli/config.py
https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/config.py#L101-L179
def set_lock_code(ctx, lock_code, new_lock_code, clear, generate, force): """ Set or change the configuration lock code. A lock code may be used to protect the application configuration. The lock code must be a 32 characters (16 bytes) hex value. """ dev = ctx.obj['dev'] def prompt_new_lo...
[ "def", "set_lock_code", "(", "ctx", ",", "lock_code", ",", "new_lock_code", ",", "clear", ",", "generate", ",", "force", ")", ":", "dev", "=", "ctx", ".", "obj", "[", "'dev'", "]", "def", "prompt_new_lock_code", "(", ")", ":", "return", "prompt_lock_code",...
Set or change the configuration lock code. A lock code may be used to protect the application configuration. The lock code must be a 32 characters (16 bytes) hex value.
[ "Set", "or", "change", "the", "configuration", "lock", "code", "." ]
python
train
35.658228
locationlabs/mockredis
mockredis/client.py
https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L1019-L1026
def sismember(self, name, value): """Emulate sismember.""" redis_set = self._get_set(name, 'SISMEMBER') if not redis_set: return 0 result = self._encode(value) in redis_set return 1 if result else 0
[ "def", "sismember", "(", "self", ",", "name", ",", "value", ")", ":", "redis_set", "=", "self", ".", "_get_set", "(", "name", ",", "'SISMEMBER'", ")", "if", "not", "redis_set", ":", "return", "0", "result", "=", "self", ".", "_encode", "(", "value", ...
Emulate sismember.
[ "Emulate", "sismember", "." ]
python
train
30.5
soimort/you-get
src/you_get/extractors/sina.py
https://github.com/soimort/you-get/blob/b746ac01c9f39de94cac2d56f665285b0523b974/src/you_get/extractors/sina.py#L94-L121
def sina_download(url, output_dir='.', merge=True, info_only=False, **kwargs): """Downloads Sina videos by URL. """ if 'news.sina.com.cn/zxt' in url: sina_zxt(url, output_dir=output_dir, merge=merge, info_only=info_only, **kwargs) return vid = match1(url, r'vid=(\d+)') if vid is Non...
[ "def", "sina_download", "(", "url", ",", "output_dir", "=", "'.'", ",", "merge", "=", "True", ",", "info_only", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "'news.sina.com.cn/zxt'", "in", "url", ":", "sina_zxt", "(", "url", ",", "output_dir", ...
Downloads Sina videos by URL.
[ "Downloads", "Sina", "videos", "by", "URL", "." ]
python
test
42.678571
gwpy/gwpy
gwpy/signal/spectral/_lal.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/signal/spectral/_lal.py#L48-L86
def generate_fft_plan(length, level=None, dtype='float64', forward=True): """Build a `REAL8FFTPlan` for a fast Fourier transform. Parameters ---------- length : `int` number of samples to plan for in each FFT. level : `int`, optional amount of work to do when planning the FFT, defa...
[ "def", "generate_fft_plan", "(", "length", ",", "level", "=", "None", ",", "dtype", "=", "'float64'", ",", "forward", "=", "True", ")", ":", "from", ".", ".", ".", "utils", ".", "lal", "import", "(", "find_typed_function", ",", "to_lal_type_str", ")", "#...
Build a `REAL8FFTPlan` for a fast Fourier transform. Parameters ---------- length : `int` number of samples to plan for in each FFT. level : `int`, optional amount of work to do when planning the FFT, default set by `LAL_FFTPLAN_LEVEL` module variable. dtype : :class:`nump...
[ "Build", "a", "REAL8FFTPlan", "for", "a", "fast", "Fourier", "transform", "." ]
python
train
30.230769
usc-isi-i2/etk
etk/ontology_api.py
https://github.com/usc-isi-i2/etk/blob/aab077c984ea20f5e8ae33af622fe11d3c4df866/etk/ontology_api.py#L718-L764
def is_valid(self, field_name: str, value, kg: dict) -> Optional[dict]: """ Check if this value is valid for the given name property according to input knowledge graph and ontology. If is valid, then return a dict with key @id or @value for ObjectProperty or DatatypeProperty. No schema c...
[ "def", "is_valid", "(", "self", ",", "field_name", ":", "str", ",", "value", ",", "kg", ":", "dict", ")", "->", "Optional", "[", "dict", "]", ":", "# property", "uri", "=", "self", ".", "__is_valid_uri_resolve", "(", "field_name", ",", "kg", ".", "get"...
Check if this value is valid for the given name property according to input knowledge graph and ontology. If is valid, then return a dict with key @id or @value for ObjectProperty or DatatypeProperty. No schema checked by this function. :param field_name: name of the property, if prefix is omit...
[ "Check", "if", "this", "value", "is", "valid", "for", "the", "given", "name", "property", "according", "to", "input", "knowledge", "graph", "and", "ontology", ".", "If", "is", "valid", "then", "return", "a", "dict", "with", "key", "@id", "or", "@value", ...
python
train
48.787234
epfl-lts2/pygsp
pygsp/plotting.py
https://github.com/epfl-lts2/pygsp/blob/8ce5bde39206129287375af24fdbcd7edddca8c5/pygsp/plotting.py#L291-L494
def _plot_graph(G, vertex_color, vertex_size, highlight, edges, edge_color, edge_width, indices, colorbar, limits, ax, title, backend): r"""Plot a graph with signals as color or vertex size. Parameters ---------- vertex_color : array_like or color Signal to plot ...
[ "def", "_plot_graph", "(", "G", ",", "vertex_color", ",", "vertex_size", ",", "highlight", ",", "edges", ",", "edge_color", ",", "edge_width", ",", "indices", ",", "colorbar", ",", "limits", ",", "ax", ",", "title", ",", "backend", ")", ":", "if", "not",...
r"""Plot a graph with signals as color or vertex size. Parameters ---------- vertex_color : array_like or color Signal to plot as vertex color (length is the number of vertices). If None, vertex color is set to `graph.plotting['vertex_color']`. Alternatively, a color can be set in a...
[ "r", "Plot", "a", "graph", "with", "signals", "as", "color", "or", "vertex", "size", "." ]
python
train
41.661765
delfick/venvstarter
venvstarter.py
https://github.com/delfick/venvstarter/blob/1573da3ad898c146b4ef6449d13ae8f570fdf5e8/venvstarter.py#L286-L301
def ignite(self, args=None): """ * Make the virtualenv * Install dependencies into that virtualenv * Start the program! """ if args is None: args = sys.argv[1:] if os.environ.get("MANAGED_VIRTUALENV", None) != "1": made = self.make_virtual...
[ "def", "ignite", "(", "self", ",", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", "if", "os", ".", "environ", ".", "get", "(", "\"MANAGED_VIRTUALENV\"", ",", "None", ")", "!=",...
* Make the virtualenv * Install dependencies into that virtualenv * Start the program!
[ "*", "Make", "the", "virtualenv", "*", "Install", "dependencies", "into", "that", "virtualenv", "*", "Start", "the", "program!" ]
python
train
28.75
honzajavorek/redis-collections
redis_collections/sortedsets.py
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sortedsets.py#L445-L455
def get_hash(self, place): """ Return the Geohash of *place*. If it's not present in the collection, ``None`` will be returned instead. """ pickled_place = self._pickle(place) try: return self.redis.geohash(self.key, pickled_place)[0] except (A...
[ "def", "get_hash", "(", "self", ",", "place", ")", ":", "pickled_place", "=", "self", ".", "_pickle", "(", "place", ")", "try", ":", "return", "self", ".", "redis", ".", "geohash", "(", "self", ".", "key", ",", "pickled_place", ")", "[", "0", "]", ...
Return the Geohash of *place*. If it's not present in the collection, ``None`` will be returned instead.
[ "Return", "the", "Geohash", "of", "*", "place", "*", ".", "If", "it", "s", "not", "present", "in", "the", "collection", "None", "will", "be", "returned", "instead", "." ]
python
train
32.727273
google/grumpy
third_party/stdlib/warnings.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/warnings.py#L16-L24
def warnpy3k(message, category=None, stacklevel=1): """Issue a deprecation warning for Python 3.x related changes. Warnings are omitted unless Python is started with the -3 option. """ if sys.py3kwarning: if category is None: category = DeprecationWarning warn(message, categ...
[ "def", "warnpy3k", "(", "message", ",", "category", "=", "None", ",", "stacklevel", "=", "1", ")", ":", "if", "sys", ".", "py3kwarning", ":", "if", "category", "is", "None", ":", "category", "=", "DeprecationWarning", "warn", "(", "message", ",", "catego...
Issue a deprecation warning for Python 3.x related changes. Warnings are omitted unless Python is started with the -3 option.
[ "Issue", "a", "deprecation", "warning", "for", "Python", "3", ".", "x", "related", "changes", "." ]
python
valid
36.666667
mlperf/training
reinforcement/tensorflow/minigo/ratings/ratings.py
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/ratings/ratings.py#L165-L208
def compute_ratings(data=None): """ Returns the tuples of (model_id, rating, sigma) N.B. that `model_id` here is NOT the model number in the run 'data' is tuples of (winner, loser) model_ids (not model numbers) """ if data is None: with sqlite3.connect("ratings.db") as db: data ...
[ "def", "compute_ratings", "(", "data", "=", "None", ")", ":", "if", "data", "is", "None", ":", "with", "sqlite3", ".", "connect", "(", "\"ratings.db\"", ")", "as", "db", ":", "data", "=", "db", ".", "execute", "(", "\"select model_winner, model_loser from wi...
Returns the tuples of (model_id, rating, sigma) N.B. that `model_id` here is NOT the model number in the run 'data' is tuples of (winner, loser) model_ids (not model numbers)
[ "Returns", "the", "tuples", "of", "(", "model_id", "rating", "sigma", ")", "N", ".", "B", ".", "that", "model_id", "here", "is", "NOT", "the", "model", "number", "in", "the", "run" ]
python
train
29.727273
ktbyers/netmiko
netmiko/vyos/vyos_ssh.py
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/vyos/vyos_ssh.py#L103-L122
def send_config_set( self, config_commands=None, exit_config_mode=False, delay_factor=1, max_loops=150, strip_prompt=False, strip_command=False, config_mode_command=None, ): """Remain in configuration mode.""" return super(VyOSSSH, self...
[ "def", "send_config_set", "(", "self", ",", "config_commands", "=", "None", ",", "exit_config_mode", "=", "False", ",", "delay_factor", "=", "1", ",", "max_loops", "=", "150", ",", "strip_prompt", "=", "False", ",", "strip_command", "=", "False", ",", "confi...
Remain in configuration mode.
[ "Remain", "in", "configuration", "mode", "." ]
python
train
31.3
saltstack/salt
salt/modules/elasticsearch.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/elasticsearch.py#L840-L863
def pipeline_delete(id, hosts=None, profile=None): ''' .. versionadded:: 2017.7.0 Delete Ingest pipeline. Available since Elasticsearch 5.0. id Pipeline id CLI example:: salt myminion elasticsearch.pipeline_delete mypipeline ''' es = _get_instance(hosts, profile) try...
[ "def", "pipeline_delete", "(", "id", ",", "hosts", "=", "None", ",", "profile", "=", "None", ")", ":", "es", "=", "_get_instance", "(", "hosts", ",", "profile", ")", "try", ":", "ret", "=", "es", ".", "ingest", ".", "delete_pipeline", "(", "id", "=",...
.. versionadded:: 2017.7.0 Delete Ingest pipeline. Available since Elasticsearch 5.0. id Pipeline id CLI example:: salt myminion elasticsearch.pipeline_delete mypipeline
[ "..", "versionadded", "::", "2017", ".", "7", ".", "0" ]
python
train
31.5
Unidata/MetPy
metpy/calc/indices.py
https://github.com/Unidata/MetPy/blob/16f68a94919b9a82dcf9cada2169cf039129e67b/metpy/calc/indices.py#L180-L217
def bulk_shear(pressure, u, v, heights=None, bottom=None, depth=None): r"""Calculate bulk shear through a layer. Layer top and bottom specified in meters or pressure. Parameters ---------- pressure : `pint.Quantity` Atmospheric pressure profile u : `pint.Quantity` U-component o...
[ "def", "bulk_shear", "(", "pressure", ",", "u", ",", "v", ",", "heights", "=", "None", ",", "bottom", "=", "None", ",", "depth", "=", "None", ")", ":", "_", ",", "u_layer", ",", "v_layer", "=", "get_layer", "(", "pressure", ",", "u", ",", "v", ",...
r"""Calculate bulk shear through a layer. Layer top and bottom specified in meters or pressure. Parameters ---------- pressure : `pint.Quantity` Atmospheric pressure profile u : `pint.Quantity` U-component of wind. v : `pint.Quantity` V-component of wind. height : `...
[ "r", "Calculate", "bulk", "shear", "through", "a", "layer", "." ]
python
train
32.894737
RJT1990/pyflux
pyflux/gpnarx/gpnarx.py
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/gpnarx/gpnarx.py#L209-L225
def expected_values(self, beta): """ Expected values of the function given the covariance matrix and hyperparameters Parameters ---------- beta : np.ndarray Contains untransformed values for latent variables Returns ---------- The exp...
[ "def", "expected_values", "(", "self", ",", "beta", ")", ":", "parm", "=", "np", ".", "array", "(", "[", "self", ".", "latent_variables", ".", "z_list", "[", "k", "]", ".", "prior", ".", "transform", "(", "beta", "[", "k", "]", ")", "for", "k", "...
Expected values of the function given the covariance matrix and hyperparameters Parameters ---------- beta : np.ndarray Contains untransformed values for latent variables Returns ---------- The expected values of the function
[ "Expected", "values", "of", "the", "function", "given", "the", "covariance", "matrix", "and", "hyperparameters", "Parameters", "----------", "beta", ":", "np", ".", "ndarray", "Contains", "untransformed", "values", "for", "latent", "variables", "Returns", "---------...
python
train
34.411765
tensorflow/tensor2tensor
tensor2tensor/models/video/basic_deterministic_params.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/video/basic_deterministic_params.py#L60-L66
def next_frame_pixel_noise(): """Basic 2-frame conv model with pixel noise.""" hparams = next_frame_basic_deterministic() hparams.add_hparam("video_modality_input_noise", 0.05) hparams.bottom["inputs"] = modalities.video_pixel_noise_bottom hparams.top["inputs"] = modalities.video_top return hparams
[ "def", "next_frame_pixel_noise", "(", ")", ":", "hparams", "=", "next_frame_basic_deterministic", "(", ")", "hparams", ".", "add_hparam", "(", "\"video_modality_input_noise\"", ",", "0.05", ")", "hparams", ".", "bottom", "[", "\"inputs\"", "]", "=", "modalities", ...
Basic 2-frame conv model with pixel noise.
[ "Basic", "2", "-", "frame", "conv", "model", "with", "pixel", "noise", "." ]
python
train
43.571429
RedHatQE/Sentaku
examples/todo_example/ux.py
https://github.com/RedHatQE/Sentaku/blob/b336cef5b6ee2db4e8dff28dcdb2be35a1f3d01c/examples/todo_example/ux.py#L9-L15
def get_by(self, name): """get a todo list ux by name :rtype: TodoListUX """ item = self.app.get_by(name) return TodoListUX(ux=self, controlled_list=item)
[ "def", "get_by", "(", "self", ",", "name", ")", ":", "item", "=", "self", ".", "app", ".", "get_by", "(", "name", ")", "return", "TodoListUX", "(", "ux", "=", "self", ",", "controlled_list", "=", "item", ")" ]
get a todo list ux by name :rtype: TodoListUX
[ "get", "a", "todo", "list", "ux", "by", "name" ]
python
train
27
sorgerlab/indra
indra/sources/biopax/processor.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/sources/biopax/processor.py#L53-L56
def print_statements(self): """Print all INDRA Statements collected by the processors.""" for i, stmt in enumerate(self.statements): print("%s: %s" % (i, stmt))
[ "def", "print_statements", "(", "self", ")", ":", "for", "i", ",", "stmt", "in", "enumerate", "(", "self", ".", "statements", ")", ":", "print", "(", "\"%s: %s\"", "%", "(", "i", ",", "stmt", ")", ")" ]
Print all INDRA Statements collected by the processors.
[ "Print", "all", "INDRA", "Statements", "collected", "by", "the", "processors", "." ]
python
train
46.25
roclark/sportsreference
sportsreference/nhl/boxscore.py
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/boxscore.py#L413-L435
def _find_player_id(self, row): """ Find the player's ID. Find the player's ID as embedded in the 'data-append-csv' attribute, such as 'zettehe01' for Henrik Zetterberg. Parameters ---------- row : PyQuery object A PyQuery object representing a singl...
[ "def", "_find_player_id", "(", "self", ",", "row", ")", ":", "player_id", "=", "row", "(", "'th'", ")", ".", "attr", "(", "'data-append-csv'", ")", "if", "not", "player_id", ":", "player_id", "=", "row", "(", "'td'", ")", ".", "attr", "(", "'data-appen...
Find the player's ID. Find the player's ID as embedded in the 'data-append-csv' attribute, such as 'zettehe01' for Henrik Zetterberg. Parameters ---------- row : PyQuery object A PyQuery object representing a single row in a boxscore table for a single p...
[ "Find", "the", "player", "s", "ID", "." ]
python
train
29.73913
honzajavorek/redis-collections
redis_collections/sets.py
https://github.com/honzajavorek/redis-collections/blob/07ca8efe88fb128f7dc7319dfa6a26cd39b3776b/redis_collections/sets.py#L466-L480
def update(self, *others): """ Update the set, adding elements from all *others*. :param others: Iterables, each one as a single positional argument. :rtype: None .. note:: If all *others* are :class:`Set` instances, the operation is performed completely...
[ "def", "update", "(", "self", ",", "*", "others", ")", ":", "return", "self", ".", "_op_update_helper", "(", "tuple", "(", "others", ")", ",", "operator", ".", "or_", ",", "'sunionstore'", ",", "update", "=", "True", ")" ]
Update the set, adding elements from all *others*. :param others: Iterables, each one as a single positional argument. :rtype: None .. note:: If all *others* are :class:`Set` instances, the operation is performed completely in Redis. Otherwise, values are retrieved ...
[ "Update", "the", "set", "adding", "elements", "from", "all", "*", "others", "*", "." ]
python
train
36.133333
googleapis/oauth2client
oauth2client/contrib/xsrfutil.py
https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/xsrfutil.py#L33-L57
def generate_token(key, user_id, action_id='', when=None): """Generates a URL-safe token for the given user, action, time tuple. Args: key: secret key to use. user_id: the user ID of the authenticated user. action_id: a string identifier of the action they requested a...
[ "def", "generate_token", "(", "key", ",", "user_id", ",", "action_id", "=", "''", ",", "when", "=", "None", ")", ":", "digester", "=", "hmac", ".", "new", "(", "_helpers", ".", "_to_bytes", "(", "key", ",", "encoding", "=", "'utf-8'", ")", ")", "dige...
Generates a URL-safe token for the given user, action, time tuple. Args: key: secret key to use. user_id: the user ID of the authenticated user. action_id: a string identifier of the action they requested authorization for. when: the time in seconds since the epoc...
[ "Generates", "a", "URL", "-", "safe", "token", "for", "the", "given", "user", "action", "time", "tuple", "." ]
python
valid
40.56
zero-os/0-core
client/py-client/zeroos/core0/client/client.py
https://github.com/zero-os/0-core/blob/69f6ce845ab8b8ad805a79a415227e7ac566c218/client/py-client/zeroos/core0/client/client.py#L1520-L1554
def create(self, name, hwaddr=None, network=None, nat=False, settings={}): """ Create a bridge with the given name, hwaddr and networking setup :param name: name of the bridge (must be unique), 15 characters or less, and not equal to "default". :param hwaddr: MAC address of the bridge. I...
[ "def", "create", "(", "self", ",", "name", ",", "hwaddr", "=", "None", ",", "network", "=", "None", ",", "nat", "=", "False", ",", "settings", "=", "{", "}", ")", ":", "args", "=", "{", "'name'", ":", "name", ",", "'hwaddr'", ":", "hwaddr", ",", ...
Create a bridge with the given name, hwaddr and networking setup :param name: name of the bridge (must be unique), 15 characters or less, and not equal to "default". :param hwaddr: MAC address of the bridge. If none, a one will be created for u :param network: Networking mode, options are none, ...
[ "Create", "a", "bridge", "with", "the", "given", "name", "hwaddr", "and", "networking", "setup", ":", "param", "name", ":", "name", "of", "the", "bridge", "(", "must", "be", "unique", ")", "15", "characters", "or", "less", "and", "not", "equal", "to", ...
python
train
52.514286
tdryer/hangups
hangups/conversation_event.py
https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/conversation_event.py#L34-L37
def user_id(self): """Who created the event (:class:`~hangups.user.UserID`).""" return user.UserID(chat_id=self._event.sender_id.chat_id, gaia_id=self._event.sender_id.gaia_id)
[ "def", "user_id", "(", "self", ")", ":", "return", "user", ".", "UserID", "(", "chat_id", "=", "self", ".", "_event", ".", "sender_id", ".", "chat_id", ",", "gaia_id", "=", "self", ".", "_event", ".", "sender_id", ".", "gaia_id", ")" ]
Who created the event (:class:`~hangups.user.UserID`).
[ "Who", "created", "the", "event", "(", ":", "class", ":", "~hangups", ".", "user", ".", "UserID", ")", "." ]
python
valid
54
cloud-custodian/cloud-custodian
tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py
https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/sandbox/c7n_sphere11/c7n_sphere11/cli.py#L38-L52
def list_locks(account_id, resource_type=None, resource_id=None): """Show extant locks and unlocks. """ locks = Client(BASE_URL, account_id).list_locks().json() for r in locks: if 'LockDate' in r: r['LockDate'] = datetime.fromtimestamp(r['LockDate']) if 'RevisionDate' in r: ...
[ "def", "list_locks", "(", "account_id", ",", "resource_type", "=", "None", ",", "resource_id", "=", "None", ")", ":", "locks", "=", "Client", "(", "BASE_URL", ",", "account_id", ")", ".", "list_locks", "(", ")", ".", "json", "(", ")", "for", "r", "in",...
Show extant locks and unlocks.
[ "Show", "extant", "locks", "and", "unlocks", "." ]
python
train
32
profitbricks/profitbricks-sdk-python
examples/pb_deleteServer.py
https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_deleteServer.py#L177-L205
def wait_for_server(pbclient=None, dc_id=None, serverid=None, indicator='state', state='AVAILABLE', timeout=300): ''' wait for a server/VM to reach a defined state for a specified time indicator := {state|vmstate} specifies if server or VM stat is tested state specifies the status th...
[ "def", "wait_for_server", "(", "pbclient", "=", "None", ",", "dc_id", "=", "None", ",", "serverid", "=", "None", ",", "indicator", "=", "'state'", ",", "state", "=", "'AVAILABLE'", ",", "timeout", "=", "300", ")", ":", "if", "pbclient", "is", "None", "...
wait for a server/VM to reach a defined state for a specified time indicator := {state|vmstate} specifies if server or VM stat is tested state specifies the status the indicator should have
[ "wait", "for", "a", "server", "/", "VM", "to", "reach", "a", "defined", "state", "for", "a", "specified", "time", "indicator", ":", "=", "{", "state|vmstate", "}", "specifies", "if", "server", "or", "VM", "stat", "is", "tested", "state", "specifies", "th...
python
valid
39.172414
christian-oudard/htmltreediff
htmltreediff/diff_core.py
https://github.com/christian-oudard/htmltreediff/blob/0e28f56492ae7e69bb0f74f9a79a8909a5ad588d/htmltreediff/diff_core.py#L246-L253
def match_blocks(hash_func, old_children, new_children): """Use difflib to find matching blocks.""" sm = difflib.SequenceMatcher( _is_junk, a=[hash_func(c) for c in old_children], b=[hash_func(c) for c in new_children], ) return sm
[ "def", "match_blocks", "(", "hash_func", ",", "old_children", ",", "new_children", ")", ":", "sm", "=", "difflib", ".", "SequenceMatcher", "(", "_is_junk", ",", "a", "=", "[", "hash_func", "(", "c", ")", "for", "c", "in", "old_children", "]", ",", "b", ...
Use difflib to find matching blocks.
[ "Use", "difflib", "to", "find", "matching", "blocks", "." ]
python
train
33
Esri/ArcREST
src/arcrest/common/general.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/common/general.py#L162-L168
def get_value(self, field_name): """ returns a value for a given field name """ if field_name in self.fields: return self._dict['attributes'][field_name] elif field_name.upper() in ['SHAPE', 'SHAPE@', "GEOMETRY"]: return self._dict['geometry'] return None
[ "def", "get_value", "(", "self", ",", "field_name", ")", ":", "if", "field_name", "in", "self", ".", "fields", ":", "return", "self", ".", "_dict", "[", "'attributes'", "]", "[", "field_name", "]", "elif", "field_name", ".", "upper", "(", ")", "in", "[...
returns a value for a given field name
[ "returns", "a", "value", "for", "a", "given", "field", "name" ]
python
train
43.571429
f3at/feat
src/feat/models/setter.py
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/models/setter.py#L121-L133
def action_set(method_name): """ Creates a setter that will call the action method with the context's key as first parameter and the value as second parameter. @param method_name: the name of a method belonging to the action. @type method_name: str """ def action_set(value, context, **_para...
[ "def", "action_set", "(", "method_name", ")", ":", "def", "action_set", "(", "value", ",", "context", ",", "*", "*", "_params", ")", ":", "method", "=", "getattr", "(", "context", "[", "\"action\"", "]", ",", "method_name", ")", "return", "_set", "(", ...
Creates a setter that will call the action method with the context's key as first parameter and the value as second parameter. @param method_name: the name of a method belonging to the action. @type method_name: str
[ "Creates", "a", "setter", "that", "will", "call", "the", "action", "method", "with", "the", "context", "s", "key", "as", "first", "parameter", "and", "the", "value", "as", "second", "parameter", "." ]
python
train
34.692308
angr/angr
angr/storage/memory.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/storage/memory.py#L47-L54
def to_valueset(self, state): """ Convert to a ValueSet instance :param state: A state :return: The converted ValueSet instance """ return state.solver.VS(state.arch.bits, self.region, self.region_base_addr, self.address)
[ "def", "to_valueset", "(", "self", ",", "state", ")", ":", "return", "state", ".", "solver", ".", "VS", "(", "state", ".", "arch", ".", "bits", ",", "self", ".", "region", ",", "self", ".", "region_base_addr", ",", "self", ".", "address", ")" ]
Convert to a ValueSet instance :param state: A state :return: The converted ValueSet instance
[ "Convert", "to", "a", "ValueSet", "instance" ]
python
train
32.875
pypa/pipenv
pipenv/vendor/delegator.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/delegator.py#L208-L217
def expect(self, pattern, timeout=-1): """Waits on the given pattern to appear in std_out""" if self.blocking: raise RuntimeError("expect can only be used on non-blocking commands.") try: self.subprocess.expect(pattern=pattern, timeout=timeout) except pexpect.EO...
[ "def", "expect", "(", "self", ",", "pattern", ",", "timeout", "=", "-", "1", ")", ":", "if", "self", ".", "blocking", ":", "raise", "RuntimeError", "(", "\"expect can only be used on non-blocking commands.\"", ")", "try", ":", "self", ".", "subprocess", ".", ...
Waits on the given pattern to appear in std_out
[ "Waits", "on", "the", "given", "pattern", "to", "appear", "in", "std_out" ]
python
train
33
couchbase/couchbase-python-client
txcouchbase/bucket.py
https://github.com/couchbase/couchbase-python-client/blob/a7bada167785bf79a29c39f820d932a433a6a535/txcouchbase/bucket.py#L313-L345
def n1qlQueryAll(self, *args, **kwargs): """ Execute a N1QL query, retrieving all rows. This method returns a :class:`Deferred` object which is executed with a :class:`~.N1QLRequest` object. The object may be iterated over to yield the rows in the result set. This metho...
[ "def", "n1qlQueryAll", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "connected", ":", "cb", "=", "lambda", "x", ":", "self", ".", "n1qlQueryAll", "(", "*", "args", ",", "*", "*", "kwargs", ")", "retu...
Execute a N1QL query, retrieving all rows. This method returns a :class:`Deferred` object which is executed with a :class:`~.N1QLRequest` object. The object may be iterated over to yield the rows in the result set. This method is similar to :meth:`~couchbase.bucket.Bucket.n1ql_query` ...
[ "Execute", "a", "N1QL", "query", "retrieving", "all", "rows", "." ]
python
train
32.212121
nateshmbhat/pyttsx3
pyttsx3/driver.py
https://github.com/nateshmbhat/pyttsx3/blob/0f304bff4812d50937393f1e3d7f89c9862a1623/pyttsx3/driver.py#L106-L119
def _pump(self): ''' Attempts to process the next command in the queue if one exists and the driver is not currently busy. ''' while (not self._busy) and len(self._queue): cmd = self._queue.pop(0) self._name = cmd[2] try: cmd[0]...
[ "def", "_pump", "(", "self", ")", ":", "while", "(", "not", "self", ".", "_busy", ")", "and", "len", "(", "self", ".", "_queue", ")", ":", "cmd", "=", "self", ".", "_queue", ".", "pop", "(", "0", ")", "self", ".", "_name", "=", "cmd", "[", "2...
Attempts to process the next command in the queue if one exists and the driver is not currently busy.
[ "Attempts", "to", "process", "the", "next", "command", "in", "the", "queue", "if", "one", "exists", "and", "the", "driver", "is", "not", "currently", "busy", "." ]
python
train
33.928571
SheffieldML/GPy
GPy/inference/latent_function_inference/posterior.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/inference/latent_function_inference/posterior.py#L133-L142
def precision(self): """ Inverse of posterior covariance """ if self._precision is None: cov = np.atleast_3d(self.covariance) self._precision = np.zeros(cov.shape) # if one covariance per dimension for p in range(cov.shape[-1]): self._...
[ "def", "precision", "(", "self", ")", ":", "if", "self", ".", "_precision", "is", "None", ":", "cov", "=", "np", ".", "atleast_3d", "(", "self", ".", "covariance", ")", "self", ".", "_precision", "=", "np", ".", "zeros", "(", "cov", ".", "shape", "...
Inverse of posterior covariance
[ "Inverse", "of", "posterior", "covariance" ]
python
train
38.5
mitsei/dlkit
dlkit/json_/utilities.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/utilities.py#L697-L714
def handle_simple_sequencing(func): """decorator, deal with simple sequencing cases""" from .assessment import assessment_utilities def wrapper(*args, **kwargs): # re-order these things because have to delete the part after # removing it from the parent sequence map if 'create_asses...
[ "def", "handle_simple_sequencing", "(", "func", ")", ":", "from", ".", "assessment", "import", "assessment_utilities", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# re-order these things because have to delete the part after", "# removing it ...
decorator, deal with simple sequencing cases
[ "decorator", "deal", "with", "simple", "sequencing", "cases" ]
python
train
42.222222
gbiggs/rtsprofile
rtsprofile/rts_profile.py
https://github.com/gbiggs/rtsprofile/blob/fded6eddcb0b25fe9808b1b12336a4413ea00905/rtsprofile/rts_profile.py#L647-L666
def optional_service_connections(self): '''Finds all service connections in which one or more components are not required. If all the components involved in a connection are required, that connection is also required. If one or more are not required, that connection is optional....
[ "def", "optional_service_connections", "(", "self", ")", ":", "result", "=", "[", "]", "for", "conn", "in", "self", ".", "_service_port_connectors", ":", "source_comp", "=", "self", ".", "find_comp_by_target", "(", "conn", ".", "source_service_port", ")", "targe...
Finds all service connections in which one or more components are not required. If all the components involved in a connection are required, that connection is also required. If one or more are not required, that connection is optional. Example: >>> s = RtsProfile(xml_s...
[ "Finds", "all", "service", "connections", "in", "which", "one", "or", "more", "components", "are", "not", "required", "." ]
python
train
40.95
nerdvegas/rez
src/rez/packages_.py
https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/packages_.py#L607-L625
def get_variant(variant_handle, context=None): """Create a variant given its handle (or serialized dict equivalent) Args: variant_handle (`ResourceHandle` or dict): Resource handle, or equivalent serialized dict representation from ResourceHandle.to_dict context (`Resolv...
[ "def", "get_variant", "(", "variant_handle", ",", "context", "=", "None", ")", ":", "if", "isinstance", "(", "variant_handle", ",", "dict", ")", ":", "variant_handle", "=", "ResourceHandle", ".", "from_dict", "(", "variant_handle", ")", "variant_resource", "=", ...
Create a variant given its handle (or serialized dict equivalent) Args: variant_handle (`ResourceHandle` or dict): Resource handle, or equivalent serialized dict representation from ResourceHandle.to_dict context (`ResolvedContext`): The context this variant is associated ...
[ "Create", "a", "variant", "given", "its", "handle", "(", "or", "serialized", "dict", "equivalent", ")" ]
python
train
36.578947
humilis/humilis-lambdautils
lambdautils/utils.py
https://github.com/humilis/humilis-lambdautils/blob/58f75eb5ace23523c283708d56a9193181ea7e8e/lambdautils/utils.py#L127-L133
def replace_event_annotations(event, newanns): """Replace event annotations with the provided ones.""" _humilis = event.get("_humilis", {}) if not _humilis: event["_humilis"] = {"annotation": newanns} else: event["_humilis"]["annotation"] = newanns
[ "def", "replace_event_annotations", "(", "event", ",", "newanns", ")", ":", "_humilis", "=", "event", ".", "get", "(", "\"_humilis\"", ",", "{", "}", ")", "if", "not", "_humilis", ":", "event", "[", "\"_humilis\"", "]", "=", "{", "\"annotation\"", ":", "...
Replace event annotations with the provided ones.
[ "Replace", "event", "annotations", "with", "the", "provided", "ones", "." ]
python
train
39.142857
saltstack/salt
salt/cloud/clouds/vmware.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/vmware.py#L1729-L1745
def list_networks(kwargs=None, call=None): ''' List all the standard networks for this VMware environment CLI Example: .. code-block:: bash salt-cloud -f list_networks my-vmware-config ''' if call != 'function': raise SaltCloudSystemExit( 'The list_networks functio...
[ "def", "list_networks", "(", "kwargs", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The list_networks function must be called with '", "'-f or --function.'", ")", "return", "{", "'Netw...
List all the standard networks for this VMware environment CLI Example: .. code-block:: bash salt-cloud -f list_networks my-vmware-config
[ "List", "all", "the", "standard", "networks", "for", "this", "VMware", "environment" ]
python
train
25.764706
saltstack/salt
salt/modules/libcloud_dns.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/libcloud_dns.py#L379-L391
def _string_to_record_type(string): ''' Return a string representation of a DNS record type to a libcloud RecordType ENUM. :param string: A record type, e.g. A, TXT, NS :type string: ``str`` :rtype: :class:`RecordType` ''' string = string.upper() record_type = getattr(RecordType, ...
[ "def", "_string_to_record_type", "(", "string", ")", ":", "string", "=", "string", ".", "upper", "(", ")", "record_type", "=", "getattr", "(", "RecordType", ",", "string", ")", "return", "record_type" ]
Return a string representation of a DNS record type to a libcloud RecordType ENUM. :param string: A record type, e.g. A, TXT, NS :type string: ``str`` :rtype: :class:`RecordType`
[ "Return", "a", "string", "representation", "of", "a", "DNS", "record", "type", "to", "a", "libcloud", "RecordType", "ENUM", "." ]
python
train
26
wummel/patool
patoolib/programs/flac.py
https://github.com/wummel/patool/blob/d7e64d9fd60faaa4b3f824bd97c43ce59b185c40/patoolib/programs/flac.py#L19-L23
def extract_flac (archive, compression, cmd, verbosity, interactive, outdir): """Decompress a FLAC archive to a WAV file.""" outfile = util.get_single_outfile(outdir, archive, extension=".wav") cmdlist = [cmd, '--decode', archive, '--output-name', outfile] return cmdlist
[ "def", "extract_flac", "(", "archive", ",", "compression", ",", "cmd", ",", "verbosity", ",", "interactive", ",", "outdir", ")", ":", "outfile", "=", "util", ".", "get_single_outfile", "(", "outdir", ",", "archive", ",", "extension", "=", "\".wav\"", ")", ...
Decompress a FLAC archive to a WAV file.
[ "Decompress", "a", "FLAC", "archive", "to", "a", "WAV", "file", "." ]
python
train
56.6
coin-or/GiMPy
src/gimpy/graph.py
https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1406-L1426
def relabel(self, i): ''' API: relabel(self, i) Description: Used by max_flow_preflowpush() method for relabelling node i. Input: i: Node that is being relabelled. Post: 'distance' attribute of node i is updated. ''' min_distance = ...
[ "def", "relabel", "(", "self", ",", "i", ")", ":", "min_distance", "=", "2", "*", "len", "(", "self", ".", "get_node_list", "(", ")", ")", "+", "1", "for", "j", "in", "self", ".", "get_neighbors", "(", "i", ")", ":", "if", "(", "self", ".", "ge...
API: relabel(self, i) Description: Used by max_flow_preflowpush() method for relabelling node i. Input: i: Node that is being relabelled. Post: 'distance' attribute of node i is updated.
[ "API", ":", "relabel", "(", "self", "i", ")", "Description", ":", "Used", "by", "max_flow_preflowpush", "()", "method", "for", "relabelling", "node", "i", ".", "Input", ":", "i", ":", "Node", "that", "is", "being", "relabelled", ".", "Post", ":", "distan...
python
train
43.142857
PatrikValkovic/grammpy
grammpy/representation/support/_RulesSet.py
https://github.com/PatrikValkovic/grammpy/blob/879ce0ef794ac2823acc19314fcd7a8aba53e50f/grammpy/representation/support/_RulesSet.py#L161-L175
def _get(self, *rules): # type: (Iterable[Type[Rule]]) -> Generator[Type[Rule]] """ Get rules representing parameters. The return rules can be different from parameters, in case parameter define multiple rules in one class. :param rules: For which rules get the representation. ...
[ "def", "_get", "(", "self", ",", "*", "rules", ")", ":", "# type: (Iterable[Type[Rule]]) -> Generator[Type[Rule]]", "for", "rule", "in", "rules", ":", "if", "not", "inspect", ".", "isclass", "(", "rule", ")", "or", "not", "issubclass", "(", "rule", ",", "Rul...
Get rules representing parameters. The return rules can be different from parameters, in case parameter define multiple rules in one class. :param rules: For which rules get the representation. :return: List of rules representing parameters. :raise NotRuleException: If the parameter does...
[ "Get", "rules", "representing", "parameters", ".", "The", "return", "rules", "can", "be", "different", "from", "parameters", "in", "case", "parameter", "define", "multiple", "rules", "in", "one", "class", ".", ":", "param", "rules", ":", "For", "which", "rul...
python
train
49.8
xenadevel/PyXenaManager
xenamanager/xena_stream.py
https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/xena_stream.py#L80-L107
def set_packet_headers(self, headers): """ Set packet header. The method will try to set ps_headerprotocol to inform the Xena GUI and tester how to interpret the packet header byte sequence specified with PS_PACKETHEADER. This is mainly for information purposes, and the stream will tran...
[ "def", "set_packet_headers", "(", "self", ",", "headers", ")", ":", "bin_headers", "=", "'0x'", "+", "binascii", ".", "hexlify", "(", "headers", ".", "bin", "(", ")", ")", ".", "decode", "(", "'utf-8'", ")", "self", ".", "set_attributes", "(", "ps_packet...
Set packet header. The method will try to set ps_headerprotocol to inform the Xena GUI and tester how to interpret the packet header byte sequence specified with PS_PACKETHEADER. This is mainly for information purposes, and the stream will transmit the packet header bytes even if no pro...
[ "Set", "packet", "header", "." ]
python
train
47.571429
smarie/python-valid8
valid8/entry_points_inline.py
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_inline.py#L125-L305
def validate(name, # type: str value, # type: Any enforce_not_none=True, # type: bool equals=None, # type: Any instance_of=None, # type: Union[Type, Tuple[Type]] subclass_of=None, # type: Union[Ty...
[ "def", "validate", "(", "name", ",", "# type: str", "value", ",", "# type: Any", "enforce_not_none", "=", "True", ",", "# type: bool", "equals", "=", "None", ",", "# type: Any", "instance_of", "=", "None", ",", "# type: Union[Type, Tuple[Type]]", "subclass_of", "=",...
A validation function for quick inline validation of `value`, with minimal capabilities: * None handling: reject None (enforce_not_none=True, default), or accept None silently (enforce_not_none=False) * Type validation: `value` should be an instance of any of `var_types` if provided * Value validation: ...
[ "A", "validation", "function", "for", "quick", "inline", "validation", "of", "value", "with", "minimal", "capabilities", ":" ]
python
train
56.707182
google/grr
grr/server/grr_response_server/authorization/auth_manager.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/authorization/auth_manager.py#L94-L100
def AuthorizeGroup(self, group, subject): """Allow given group access to a given subject.""" # Add the subject to the dict if is isn't present, so it will get checked in # CheckPermissions self.authorized_users.setdefault(subject, set()) self.group_access_manager.AuthorizeGroup(group, subject)
[ "def", "AuthorizeGroup", "(", "self", ",", "group", ",", "subject", ")", ":", "# Add the subject to the dict if is isn't present, so it will get checked in", "# CheckPermissions", "self", ".", "authorized_users", ".", "setdefault", "(", "subject", ",", "set", "(", ")", ...
Allow given group access to a given subject.
[ "Allow", "given", "group", "access", "to", "a", "given", "subject", "." ]
python
train
44.142857
jbaiter/gphoto2-cffi
gphoto2cffi/backend.py
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/backend.py#L75-L90
def _logging_callback(level, domain, message, data): """ Callback that outputs libgphoto2's logging message via Python's standard logging facilities. :param level: libgphoto2 logging level :param domain: component the message originates from :param message: logging message :param data: ...
[ "def", "_logging_callback", "(", "level", ",", "domain", ",", "message", ",", "data", ")", ":", "domain", "=", "ffi", ".", "string", "(", "domain", ")", ".", "decode", "(", ")", "message", "=", "ffi", ".", "string", "(", "message", ")", ".", "decode"...
Callback that outputs libgphoto2's logging message via Python's standard logging facilities. :param level: libgphoto2 logging level :param domain: component the message originates from :param message: logging message :param data: Other data in the logging record (unused)
[ "Callback", "that", "outputs", "libgphoto2", "s", "logging", "message", "via", "Python", "s", "standard", "logging", "facilities", "." ]
python
train
35.5
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L732-L736
def setMimeTypeByName(self, name): " Guess the mime type " mimetype = mimetypes.guess_type(name)[0] if mimetype is not None: self.mimetype = mimetypes.guess_type(name)[0].split(";")[0]
[ "def", "setMimeTypeByName", "(", "self", ",", "name", ")", ":", "mimetype", "=", "mimetypes", ".", "guess_type", "(", "name", ")", "[", "0", "]", "if", "mimetype", "is", "not", "None", ":", "self", ".", "mimetype", "=", "mimetypes", ".", "guess_type", ...
Guess the mime type
[ "Guess", "the", "mime", "type" ]
python
train
43.2
flo-compbio/genometools
genometools/ontology/ontology.py
https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ontology/ontology.py#L159-L184
def write_pickle(self, path, compress=False): """Serialize the current `GOParser` object and store it in a pickle file. Parameters ---------- path: str Path of the output file. compress: bool, optional Whether to compress the file using gzip. Ret...
[ "def", "write_pickle", "(", "self", ",", "path", ",", "compress", "=", "False", ")", ":", "logger", ".", "info", "(", "'Writing pickle to \"%s\"...'", ",", "path", ")", "if", "compress", ":", "with", "gzip", ".", "open", "(", "path", ",", "'wb'", ")", ...
Serialize the current `GOParser` object and store it in a pickle file. Parameters ---------- path: str Path of the output file. compress: bool, optional Whether to compress the file using gzip. Returns ------- None Notes ...
[ "Serialize", "the", "current", "GOParser", "object", "and", "store", "it", "in", "a", "pickle", "file", "." ]
python
train
30.076923
SmokinCaterpillar/pypet
pypet/pypetlogging.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/pypetlogging.py#L359-L364
def extract_replacements(self, trajectory): """Extracts the wildcards and file replacements from the `trajectory`""" self.env_name = trajectory.v_environment_name self.traj_name = trajectory.v_name self.set_name = trajectory.f_wildcard('$set') self.run_name = trajectory.f_wildca...
[ "def", "extract_replacements", "(", "self", ",", "trajectory", ")", ":", "self", ".", "env_name", "=", "trajectory", ".", "v_environment_name", "self", ".", "traj_name", "=", "trajectory", ".", "v_name", "self", ".", "set_name", "=", "trajectory", ".", "f_wild...
Extracts the wildcards and file replacements from the `trajectory`
[ "Extracts", "the", "wildcards", "and", "file", "replacements", "from", "the", "trajectory" ]
python
test
53.666667
OpenTreeOfLife/peyotl
tutorials/ot-taxo-mrca-to-root.py
https://github.com/OpenTreeOfLife/peyotl/blob/5e4e52a0fdbd17f490aa644ad79fda6ea2eda7c0/tutorials/ot-taxo-mrca-to-root.py#L23-L46
def main(argv): """This function sets up a command-line option parser and then calls to do all of the real work. """ import argparse import codecs # have to be ready to deal with utf-8 names out = codecs.getwriter('utf-8')(sys.stdout) description = '''Takes a series of at least 2 OTT ids...
[ "def", "main", "(", "argv", ")", ":", "import", "argparse", "import", "codecs", "# have to be ready to deal with utf-8 names", "out", "=", "codecs", ".", "getwriter", "(", "'utf-8'", ")", "(", "sys", ".", "stdout", ")", "description", "=", "'''Takes a series of at...
This function sets up a command-line option parser and then calls to do all of the real work.
[ "This", "function", "sets", "up", "a", "command", "-", "line", "option", "parser", "and", "then", "calls", "to", "do", "all", "of", "the", "real", "work", "." ]
python
train
41.541667
troeger/opensubmit
web/opensubmit/cmdline.py
https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/web/opensubmit/cmdline.py#L111-L148
def apache_config(config, outputfile): ''' Generate a valid Apache configuration file, based on the given settings. ''' if os.path.exists(outputfile): os.rename(outputfile, outputfile + ".old") print("Renamed existing Apache config file to " + outputfile + ".old") from django.co...
[ "def", "apache_config", "(", "config", ",", "outputfile", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "outputfile", ")", ":", "os", ".", "rename", "(", "outputfile", ",", "outputfile", "+", "\".old\"", ")", "print", "(", "\"Renamed existing Apac...
Generate a valid Apache configuration file, based on the given settings.
[ "Generate", "a", "valid", "Apache", "configuration", "file", "based", "on", "the", "given", "settings", "." ]
python
train
35.368421
stevelittlefish/littlefish
littlefish/viewutil.py
https://github.com/stevelittlefish/littlefish/blob/6deee7f81fab30716c743efe2e94e786c6e17016/littlefish/viewutil.py#L15-L63
def internal_error(exception, template_path, is_admin, db=None): """ Render an "internal error" page. The following variables will be populated when rendering the template: title: The page title message: The body of the error message to display to the user preformat: Boolean stating whethe...
[ "def", "internal_error", "(", "exception", ",", "template_path", ",", "is_admin", ",", "db", "=", "None", ")", ":", "if", "db", ":", "try", ":", "db", ".", "session", ".", "rollback", "(", ")", "except", ":", "# noqa: E722", "pass", "title", "=", "str"...
Render an "internal error" page. The following variables will be populated when rendering the template: title: The page title message: The body of the error message to display to the user preformat: Boolean stating whether to wrap the error message in a pre As well as rendering the error mess...
[ "Render", "an", "internal", "error", "page", ".", "The", "following", "variables", "will", "be", "populated", "when", "rendering", "the", "template", ":", "title", ":", "The", "page", "title", "message", ":", "The", "body", "of", "the", "error", "message", ...
python
test
38.530612
phaethon/kamene
kamene/contrib/gsm_um.py
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L180-L195
def additionalAssignment(MobileAllocation_presence=0, StartingTime_presence=0): """ADDITIONAL ASSIGNMENT Section 9.1.1""" # Mandatory a = TpPd(pd=0x6) b = MessageType(mesType=0x3B) # 00111011 c = ChannelDescription() packet = a / b / c # Not Mandatory if MobileA...
[ "def", "additionalAssignment", "(", "MobileAllocation_presence", "=", "0", ",", "StartingTime_presence", "=", "0", ")", ":", "# Mandatory", "a", "=", "TpPd", "(", "pd", "=", "0x6", ")", "b", "=", "MessageType", "(", "mesType", "=", "0x3B", ")", "# 00111011",...
ADDITIONAL ASSIGNMENT Section 9.1.1
[ "ADDITIONAL", "ASSIGNMENT", "Section", "9", ".", "1", ".", "1" ]
python
train
34.625
collectiveacuity/labPack
labpack/events/meetup.py
https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/events/meetup.py#L1136-L1176
def get_member_profile(self, member_id): ''' a method to retrieve member profile details :param member_id: integer with member id from member profile :return: dictionary with member profile details inside [json] key profile_details = self.objects.profile.schema ''' ...
[ "def", "get_member_profile", "(", "self", ",", "member_id", ")", ":", "# https://www.meetup.com/meetup_api/docs/members/:member_id/#get\r", "title", "=", "'%s.get_member_profile'", "%", "self", ".", "__class__", ".", "__name__", "# validate inputs\r", "input_fields", "=", "...
a method to retrieve member profile details :param member_id: integer with member id from member profile :return: dictionary with member profile details inside [json] key profile_details = self.objects.profile.schema
[ "a", "method", "to", "retrieve", "member", "profile", "details", ":", "param", "member_id", ":", "integer", "with", "member", "id", "from", "member", "profile", ":", "return", ":", "dictionary", "with", "member", "profile", "details", "inside", "[", "json", ...
python
train
33.658537
numenta/nupic
src/nupic/data/generators/data_generator.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/data/generators/data_generator.py#L444-L453
def encodeValue(self, value, toBeAdded=True): """Value is encoded as a sdr using the encoding parameters of the Field""" encodedValue = np.array(self.encoder.encode(value), dtype=realDType) if toBeAdded: self.encodings.append(encodedValue) self.numEncodings+=1 return encodedValue
[ "def", "encodeValue", "(", "self", ",", "value", ",", "toBeAdded", "=", "True", ")", ":", "encodedValue", "=", "np", ".", "array", "(", "self", ".", "encoder", ".", "encode", "(", "value", ")", ",", "dtype", "=", "realDType", ")", "if", "toBeAdded", ...
Value is encoded as a sdr using the encoding parameters of the Field
[ "Value", "is", "encoded", "as", "a", "sdr", "using", "the", "encoding", "parameters", "of", "the", "Field" ]
python
valid
30.2
monarch-initiative/dipper
dipper/sources/ClinVarXML_alpha.py
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/ClinVarXML_alpha.py#L348-L370
def resolve(label): ''' composite mapping given f(x) and g(x) here: GLOBALTT & LOCALTT respectivly in order of preference return g(f(x))|f(x)|g(x) | x TODO consider returning x on fall through : return label's mapping ''' term_id = label if label is not None and label in LOC...
[ "def", "resolve", "(", "label", ")", ":", "term_id", "=", "label", "if", "label", "is", "not", "None", "and", "label", "in", "LOCALTT", ":", "term_id", "=", "LOCALTT", "[", "label", "]", "if", "term_id", "in", "GLOBALTT", ":", "term_id", "=", "GLOBALTT...
composite mapping given f(x) and g(x) here: GLOBALTT & LOCALTT respectivly in order of preference return g(f(x))|f(x)|g(x) | x TODO consider returning x on fall through : return label's mapping
[ "composite", "mapping", "given", "f", "(", "x", ")", "and", "g", "(", "x", ")", "here", ":", "GLOBALTT", "&", "LOCALTT", "respectivly", "in", "order", "of", "preference", "return", "g", "(", "f", "(", "x", "))", "|f", "(", "x", ")", "|g", "(", "x...
python
train
30.826087
twilio/twilio-python
twilio/jwt/compat.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/jwt/compat.py#L1-L25
def compare_digest(a, b): """ PyJWT expects hmac.compare_digest to exist for all Python 3.x, however it was added in Python > 3.3 It has a fallback for Python 2.x but not for Pythons between 2.x and 3.3 Copied from: https://github.com/python/cpython/commit/6cea65555caf2716b4633827715004ab0291a282#diff-c...
[ "def", "compare_digest", "(", "a", ",", "b", ")", ":", "# Consistent timing matters more here than data type flexibility", "if", "not", "(", "isinstance", "(", "a", ",", "bytes", ")", "and", "isinstance", "(", "b", ",", "bytes", ")", ")", ":", "raise", "TypeEr...
PyJWT expects hmac.compare_digest to exist for all Python 3.x, however it was added in Python > 3.3 It has a fallback for Python 2.x but not for Pythons between 2.x and 3.3 Copied from: https://github.com/python/cpython/commit/6cea65555caf2716b4633827715004ab0291a282#diff-c49659257ec1b129707ce47a98adc96eL16 ...
[ "PyJWT", "expects", "hmac", ".", "compare_digest", "to", "exist", "for", "all", "Python", "3", ".", "x", "however", "it", "was", "added", "in", "Python", ">", "3", ".", "3", "It", "has", "a", "fallback", "for", "Python", "2", ".", "x", "but", "not", ...
python
train
43.72
isislovecruft/python-gnupg
pretty_bad_protocol/_parsers.py
https://github.com/isislovecruft/python-gnupg/blob/784571449032e811587249743e183fc5e908a673/pretty_bad_protocol/_parsers.py#L1015-L1024
def _handle_status(self, key, value): """Parse a status code from the attached GnuPG process. :raises: :exc:`~exceptions.ValueError` if the status message is unknown. """ if key in ("DELETE_PROBLEM", "KEY_CONSIDERED"): self.status = self.problem_reason.get(value, "Unknown er...
[ "def", "_handle_status", "(", "self", ",", "key", ",", "value", ")", ":", "if", "key", "in", "(", "\"DELETE_PROBLEM\"", ",", "\"KEY_CONSIDERED\"", ")", ":", "self", ".", "status", "=", "self", ".", "problem_reason", ".", "get", "(", "value", ",", "\"Unkn...
Parse a status code from the attached GnuPG process. :raises: :exc:`~exceptions.ValueError` if the status message is unknown.
[ "Parse", "a", "status", "code", "from", "the", "attached", "GnuPG", "process", "." ]
python
train
45.7
aparo/pyes
pyes/managers.py
https://github.com/aparo/pyes/blob/712eb6095961755067b2b5baa262008ade6584b3/pyes/managers.py#L470-L477
def delete_mapping(self, index, doc_type): """ Delete a typed JSON document type from a specific index. (See :ref:`es-guide-reference-api-admin-indices-delete-mapping`) """ path = make_path(index, doc_type) return self.conn._send_request('DELETE', path)
[ "def", "delete_mapping", "(", "self", ",", "index", ",", "doc_type", ")", ":", "path", "=", "make_path", "(", "index", ",", "doc_type", ")", "return", "self", ".", "conn", ".", "_send_request", "(", "'DELETE'", ",", "path", ")" ]
Delete a typed JSON document type from a specific index. (See :ref:`es-guide-reference-api-admin-indices-delete-mapping`)
[ "Delete", "a", "typed", "JSON", "document", "type", "from", "a", "specific", "index", ".", "(", "See", ":", "ref", ":", "es", "-", "guide", "-", "reference", "-", "api", "-", "admin", "-", "indices", "-", "delete", "-", "mapping", ")" ]
python
train
36.875
klen/makesite
makesite/site.py
https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/site.py#L38-L44
def run_check(self, template_name=None, service_dir=None): " Run checking scripts. " print_header('Check requirements', sep='-') map(lambda cmd: call("bash %s" % cmd), self._gen_scripts( 'check', template_name=template_name, service_dir=service_dir)) return True
[ "def", "run_check", "(", "self", ",", "template_name", "=", "None", ",", "service_dir", "=", "None", ")", ":", "print_header", "(", "'Check requirements'", ",", "sep", "=", "'-'", ")", "map", "(", "lambda", "cmd", ":", "call", "(", "\"bash %s\"", "%", "c...
Run checking scripts.
[ "Run", "checking", "scripts", "." ]
python
train
43
a1ezzz/wasp-general
wasp_general/task/scheduler/scheduler.py
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/scheduler/scheduler.py#L488-L505
def __update(self, task_source): """ Recheck next start of tasks from the given one only :param task_source: source to check :return: None """ next_start = task_source.next_start() if next_start is not None: if next_start.tzinfo is None or next_start.tzinfo != timezone.utc: raise ValueError('Inval...
[ "def", "__update", "(", "self", ",", "task_source", ")", ":", "next_start", "=", "task_source", ".", "next_start", "(", ")", "if", "next_start", "is", "not", "None", ":", "if", "next_start", ".", "tzinfo", "is", "None", "or", "next_start", ".", "tzinfo", ...
Recheck next start of tasks from the given one only :param task_source: source to check :return: None
[ "Recheck", "next", "start", "of", "tasks", "from", "the", "given", "one", "only" ]
python
train
30.888889
OLC-Bioinformatics/sipprverse
cgecore/alignment.py
https://github.com/OLC-Bioinformatics/sipprverse/blob/d4f10cdf8e1a39dac0953db61c21c97efc6006de/cgecore/alignment.py#L448-L473
def calculate_new_length(gene_split, gene_results, hit): ''' Function for calcualting new length if the gene is split on several contigs ''' # Looping over splitted hits and calculate new length first = 1 for split in gene_split[hit['sbjct_header']]: new_start = int(gene_results[split]['sbjct_st...
[ "def", "calculate_new_length", "(", "gene_split", ",", "gene_results", ",", "hit", ")", ":", "# Looping over splitted hits and calculate new length", "first", "=", "1", "for", "split", "in", "gene_split", "[", "hit", "[", "'sbjct_header'", "]", "]", ":", "new_start"...
Function for calcualting new length if the gene is split on several contigs
[ "Function", "for", "calcualting", "new", "length", "if", "the", "gene", "is", "split", "on", "several", "contigs" ]
python
train
31.923077
gwastro/pycbc-glue
pycbc_glue/pipeline.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/pipeline.py#L2481-L2491
def set_start(self,time,pass_to_command_line=True): """ Set the GPS start time of the analysis node by setting a --gps-start-time option to the node when it is executed. @param time: GPS start time of job. @bool pass_to_command_line: add gps-start-time as variable option. """ if pass_to_comm...
[ "def", "set_start", "(", "self", ",", "time", ",", "pass_to_command_line", "=", "True", ")", ":", "if", "pass_to_command_line", ":", "self", ".", "add_var_opt", "(", "'gps-start-time'", ",", "time", ")", "self", ".", "__start", "=", "time", "self", ".", "_...
Set the GPS start time of the analysis node by setting a --gps-start-time option to the node when it is executed. @param time: GPS start time of job. @bool pass_to_command_line: add gps-start-time as variable option.
[ "Set", "the", "GPS", "start", "time", "of", "the", "analysis", "node", "by", "setting", "a", "--", "gps", "-", "start", "-", "time", "option", "to", "the", "node", "when", "it", "is", "executed", "." ]
python
train
38
oceanprotocol/aquarius
aquarius/app/assets.py
https://github.com/oceanprotocol/aquarius/blob/9fb094b1ac01f0604d0c854166dd324e476a010e/aquarius/app/assets.py#L530-L572
def query_text(): """Get a list of DDOs that match with the given text. --- tags: - ddo parameters: - name: text in: query description: ID of the asset. required: true type: string - name: sort in: query type: object description: ...
[ "def", "query_text", "(", ")", ":", "data", "=", "request", ".", "args", "assert", "isinstance", "(", "data", ",", "dict", ")", ",", "'invalid `args` type, should already formatted into a dict.'", "search_model", "=", "FullTextModel", "(", "text", "=", "data", "."...
Get a list of DDOs that match with the given text. --- tags: - ddo parameters: - name: text in: query description: ID of the asset. required: true type: string - name: sort in: query type: object description: Key or list of keys to so...
[ "Get", "a", "list", "of", "DDOs", "that", "match", "with", "the", "given", "text", ".", "---", "tags", ":", "-", "ddo", "parameters", ":", "-", "name", ":", "text", "in", ":", "query", "description", ":", "ID", "of", "the", "asset", ".", "required", ...
python
train
32.883721
ibis-project/ibis
ibis/expr/api.py
https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/expr/api.py#L1659-L1675
def geo_max_distance(left, right): """Returns the 2-dimensional maximum distance between two geometries in projected units. If g1 and g2 is the same geometry the function will return the distance between the two vertices most far from each other in that geometry Parameters ---------- left :...
[ "def", "geo_max_distance", "(", "left", ",", "right", ")", ":", "op", "=", "ops", ".", "GeoMaxDistance", "(", "left", ",", "right", ")", "return", "op", ".", "to_expr", "(", ")" ]
Returns the 2-dimensional maximum distance between two geometries in projected units. If g1 and g2 is the same geometry the function will return the distance between the two vertices most far from each other in that geometry Parameters ---------- left : geometry right : geometry Return...
[ "Returns", "the", "2", "-", "dimensional", "maximum", "distance", "between", "two", "geometries", "in", "projected", "units", ".", "If", "g1", "and", "g2", "is", "the", "same", "geometry", "the", "function", "will", "return", "the", "distance", "between", "t...
python
train
27.294118
goshuirc/irc
girc/ircreactor/events.py
https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/ircreactor/events.py#L80-L87
def register(self, event, callable, priority=10): """Register interest in an event. event: name of the event (str) callable: the callable to be used as a callback function Returns an EventReceiver object. To unregister interest, simply delete the object.""" ...
[ "def", "register", "(", "self", ",", "event", ",", "callable", ",", "priority", "=", "10", ")", ":", "logger", ".", "debug", "(", "'registered: '", "+", "event", "+", "': '", "+", "repr", "(", "callable", ")", "+", "' ['", "+", "repr", "(", "self", ...
Register interest in an event. event: name of the event (str) callable: the callable to be used as a callback function Returns an EventReceiver object. To unregister interest, simply delete the object.
[ "Register", "interest", "in", "an", "event", ".", "event", ":", "name", "of", "the", "event", "(", "str", ")", "callable", ":", "the", "callable", "to", "be", "used", "as", "a", "callback", "function", "Returns", "an", "EventReceiver", "object", ".", "To...
python
train
60.625
Shizmob/pydle
pydle/features/ctcp.py
https://github.com/Shizmob/pydle/blob/7ec7d65d097318ed0bcdc5d8401470287d8c7cf7/pydle/features/ctcp.py#L80-L96
async def on_raw_notice(self, message): """ Modify NOTICE to redirect CTCP messages. """ nick, metadata = self._parse_user(message.source) target, msg = message.params if is_ctcp(msg): self._sync_user(nick, metadata) type, response = parse_ctcp(msg) ...
[ "async", "def", "on_raw_notice", "(", "self", ",", "message", ")", ":", "nick", ",", "metadata", "=", "self", ".", "_parse_user", "(", "message", ".", "source", ")", "target", ",", "msg", "=", "message", ".", "params", "if", "is_ctcp", "(", "msg", ")",...
Modify NOTICE to redirect CTCP messages.
[ "Modify", "NOTICE", "to", "redirect", "CTCP", "messages", "." ]
python
train
40.529412
cga-harvard/Hypermap-Registry
hypermap/aggregator/tasks.py
https://github.com/cga-harvard/Hypermap-Registry/blob/899a5385b15af7fba190ab4fae1d41e47d155a1b/hypermap/aggregator/tasks.py#L195-L205
def remove_service_checks(self, service_id): """ Remove all checks from a service. """ from hypermap.aggregator.models import Service service = Service.objects.get(id=service_id) service.check_set.all().delete() layer_to_process = service.layer_set.all() for layer in layer_to_process: ...
[ "def", "remove_service_checks", "(", "self", ",", "service_id", ")", ":", "from", "hypermap", ".", "aggregator", ".", "models", "import", "Service", "service", "=", "Service", ".", "objects", ".", "get", "(", "id", "=", "service_id", ")", "service", ".", "...
Remove all checks from a service.
[ "Remove", "all", "checks", "from", "a", "service", "." ]
python
train
31.545455
briancappello/flask-sqlalchemy-bundle
flask_sqlalchemy_bundle/base_model.py
https://github.com/briancappello/flask-sqlalchemy-bundle/blob/8150896787907ef0001839b5a6ef303edccb9b6c/flask_sqlalchemy_bundle/base_model.py#L87-L107
def validate(cls, partial=True, **kwargs): """ Validate kwargs before setting attributes on the model """ data = kwargs if not partial: data = dict(**kwargs, **{col.name: None for col in cls.__table__.c if col.name not in kwargs}) ...
[ "def", "validate", "(", "cls", ",", "partial", "=", "True", ",", "*", "*", "kwargs", ")", ":", "data", "=", "kwargs", "if", "not", "partial", ":", "data", "=", "dict", "(", "*", "*", "kwargs", ",", "*", "*", "{", "col", ".", "name", ":", "None"...
Validate kwargs before setting attributes on the model
[ "Validate", "kwargs", "before", "setting", "attributes", "on", "the", "model" ]
python
train
34.095238
getnikola/coil
coil/web.py
https://github.com/getnikola/coil/blob/80ef1827460b0691cf2c98351a14d88e235c9899/coil/web.py#L529-L542
def write_user(user): """Write an user ot the database. :param User user: User to write """ udata = {} for f in USER_FIELDS: udata[f] = getattr(user, f) for p in PERMISSIONS: udata[p] = '1' if getattr(user, p) else '0' db.hmset('user:{0}'.format(user.uid), udata)
[ "def", "write_user", "(", "user", ")", ":", "udata", "=", "{", "}", "for", "f", "in", "USER_FIELDS", ":", "udata", "[", "f", "]", "=", "getattr", "(", "user", ",", "f", ")", "for", "p", "in", "PERMISSIONS", ":", "udata", "[", "p", "]", "=", "'1...
Write an user ot the database. :param User user: User to write
[ "Write", "an", "user", "ot", "the", "database", "." ]
python
train
21.285714
gpoulter/python-ngram
ngram.py
https://github.com/gpoulter/python-ngram/blob/f8543bdc84a4d24ac60a48b36c4034f881664491/ngram.py#L127-L148
def copy(self, items=None): """Return a new NGram object with the same settings, and referencing the same items. Copy is shallow in that each item is not recursively copied. Optionally specify alternate items to populate the copy. >>> from ngram import NGram >>> from ...
[ "def", "copy", "(", "self", ",", "items", "=", "None", ")", ":", "return", "NGram", "(", "items", "if", "items", "is", "not", "None", "else", "self", ",", "self", ".", "threshold", ",", "self", ".", "warp", ",", "self", ".", "_key", ",", "self", ...
Return a new NGram object with the same settings, and referencing the same items. Copy is shallow in that each item is not recursively copied. Optionally specify alternate items to populate the copy. >>> from ngram import NGram >>> from copy import deepcopy >>> n = NG...
[ "Return", "a", "new", "NGram", "object", "with", "the", "same", "settings", "and", "referencing", "the", "same", "items", ".", "Copy", "is", "shallow", "in", "that", "each", "item", "is", "not", "recursively", "copied", ".", "Optionally", "specify", "alterna...
python
train
36.454545
raamana/mrivis
mrivis/workflow.py
https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/workflow.py#L597-L632
def _generic_mixer(slice1, slice2, mixer_name, **kwargs): """ Generic mixer to process two slices with appropriate mixer and return the composite to be displayed. """ mixer_name = mixer_name.lower() if mixer_name in ['color_mix', 'rgb']: mixed = _mix_color(slice1, slice2, **kwargs) ...
[ "def", "_generic_mixer", "(", "slice1", ",", "slice2", ",", "mixer_name", ",", "*", "*", "kwargs", ")", ":", "mixer_name", "=", "mixer_name", ".", "lower", "(", ")", "if", "mixer_name", "in", "[", "'color_mix'", ",", "'rgb'", "]", ":", "mixed", "=", "_...
Generic mixer to process two slices with appropriate mixer and return the composite to be displayed.
[ "Generic", "mixer", "to", "process", "two", "slices", "with", "appropriate", "mixer", "and", "return", "the", "composite", "to", "be", "displayed", "." ]
python
train
36.805556
TkTech/Jawa
jawa/constants.py
https://github.com/TkTech/Jawa/blob/94c8424e699029ac33fbc0e866fff0ecb2742289/jawa/constants.py#L523-L538
def create_interface_method_ref(self, class_: str, if_method: str, descriptor: str) -> InterfaceMethodRef: """ Creates a new :class:`ConstantInterfaceMethodRef`, adding it to the pool and returning it. :param class_: The name of the class to which `if...
[ "def", "create_interface_method_ref", "(", "self", ",", "class_", ":", "str", ",", "if_method", ":", "str", ",", "descriptor", ":", "str", ")", "->", "InterfaceMethodRef", ":", "self", ".", "append", "(", "(", "11", ",", "self", ".", "create_class", "(", ...
Creates a new :class:`ConstantInterfaceMethodRef`, adding it to the pool and returning it. :param class_: The name of the class to which `if_method` belongs. :param if_method: The name of the interface method. :param descriptor: The descriptor for `if_method`.
[ "Creates", "a", "new", ":", "class", ":", "ConstantInterfaceMethodRef", "adding", "it", "to", "the", "pool", "and", "returning", "it", "." ]
python
train
41.125
IdentityPython/pysaml2
src/saml2/client_base.py
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/client_base.py#L560-L593
def create_authz_decision_query_using_assertion(self, destination, assertion, action=None, resource=None, subject=None, message_id=0, consent=None, extensions=None, sign=False, nsprefix=None): """ Makes an authz decision query based on a pr...
[ "def", "create_authz_decision_query_using_assertion", "(", "self", ",", "destination", ",", "assertion", ",", "action", "=", "None", ",", "resource", "=", "None", ",", "subject", "=", "None", ",", "message_id", "=", "0", ",", "consent", "=", "None", ",", "ex...
Makes an authz decision query based on a previously received Assertion. :param destination: The IdP endpoint to send the request to :param assertion: An Assertion instance :param action: The action you want to perform (has to be at least one) :param resource: The resource you wa...
[ "Makes", "an", "authz", "decision", "query", "based", "on", "a", "previously", "received", "Assertion", "." ]
python
train
42.823529
gwpy/gwpy
gwpy/io/datafind.py
https://github.com/gwpy/gwpy/blob/7a92b917e7dd2d99b15895293a1fa1d66cdb210a/gwpy/io/datafind.py#L343-L543
def find_frametype(channel, gpstime=None, frametype_match=None, host=None, port=None, return_all=False, allow_tape=False, connection=None, on_gaps='error'): """Find the frametype(s) that hold data for a given channel Parameters ---------- channel : `str`, `~gwpy.de...
[ "def", "find_frametype", "(", "channel", ",", "gpstime", "=", "None", ",", "frametype_match", "=", "None", ",", "host", "=", "None", ",", "port", "=", "None", ",", "return_all", "=", "False", ",", "allow_tape", "=", "False", ",", "connection", "=", "None...
Find the frametype(s) that hold data for a given channel Parameters ---------- channel : `str`, `~gwpy.detector.Channel` the channel to be found gpstime : `int`, optional target GPS time at which to find correct type frametype_match : `str`, optional regular expression to ...
[ "Find", "the", "frametype", "(", "s", ")", "that", "hold", "data", "for", "a", "given", "channel" ]
python
train
35.522388
hover2pi/svo_filters
svo_filters/svo.py
https://github.com/hover2pi/svo_filters/blob/f0587c4908baf636d4bdf030fa95029e8f31b975/svo_filters/svo.py#L232-L324
def apply(self, spectrum, plot=False): """ Apply the filter to the given [W, F], or [W, F, E] spectrum Parameters ---------- spectrum: array-like The wavelength [um] and flux of the spectrum to apply the filter to plot: bool Plot the o...
[ "def", "apply", "(", "self", ",", "spectrum", ",", "plot", "=", "False", ")", ":", "# Convert to filter units if possible", "f_units", "=", "1.", "if", "hasattr", "(", "spectrum", "[", "0", "]", ",", "'unit'", ")", ":", "spectrum", "[", "0", "]", "=", ...
Apply the filter to the given [W, F], or [W, F, E] spectrum Parameters ---------- spectrum: array-like The wavelength [um] and flux of the spectrum to apply the filter to plot: bool Plot the original and filtered spectrum Returns ----...
[ "Apply", "the", "filter", "to", "the", "given", "[", "W", "F", "]", "or", "[", "W", "F", "E", "]", "spectrum" ]
python
train
34.892473
treasure-data/pandas-td
pandas_td/td.py
https://github.com/treasure-data/pandas-td/blob/0f4e1ee726f593dbb9cc74312c286e62afdf7de2/pandas_td/td.py#L439-L486
def create_engine(url, con=None, header=True, show_progress=5.0, clear_progress=True): '''Create a handler for query engine based on a URL. The following environment variables are used for default connection: TD_API_KEY API key TD_API_SERVER API server (default: api.treasuredata.com) HT...
[ "def", "create_engine", "(", "url", ",", "con", "=", "None", ",", "header", "=", "True", ",", "show_progress", "=", "5.0", ",", "clear_progress", "=", "True", ")", ":", "url", "=", "urlparse", "(", "url", ")", "engine_type", "=", "url", ".", "scheme", ...
Create a handler for query engine based on a URL. The following environment variables are used for default connection: TD_API_KEY API key TD_API_SERVER API server (default: api.treasuredata.com) HTTP_PROXY HTTP proxy (optional) Parameters ---------- url : string Eng...
[ "Create", "a", "handler", "for", "query", "engine", "based", "on", "a", "URL", "." ]
python
train
37.770833
IBM/pyxcli
pyxcli/mirroring/cg_recovery_manager.py
https://github.com/IBM/pyxcli/blob/7d8ece1dcc16f50246740a447aa81b94a0dbced4/pyxcli/mirroring/cg_recovery_manager.py#L206-L210
def get_cg_volumes(self, group_id): """ return all non snapshots volumes in cg """ for volume in self.xcli_client.cmd.vol_list(cg=group_id): if volume.snapshot_of == '': yield volume.name
[ "def", "get_cg_volumes", "(", "self", ",", "group_id", ")", ":", "for", "volume", "in", "self", ".", "xcli_client", ".", "cmd", ".", "vol_list", "(", "cg", "=", "group_id", ")", ":", "if", "volume", ".", "snapshot_of", "==", "''", ":", "yield", "volume...
return all non snapshots volumes in cg
[ "return", "all", "non", "snapshots", "volumes", "in", "cg" ]
python
train
46.2
dossier/dossier.store
dossier/store/store.py
https://github.com/dossier/dossier.store/blob/b22ffe2470bba9fcc98a30cb55b437bfa1521e7f/dossier/store/store.py#L490-L501
def _index(self, name): '''Returns index transforms for ``name``. :type name: unicode :rtype: ``{ create |--> function, transform |--> function }`` ''' name = name.decode('utf-8') try: return self._indexes[name] except KeyError: raise KeyE...
[ "def", "_index", "(", "self", ",", "name", ")", ":", "name", "=", "name", ".", "decode", "(", "'utf-8'", ")", "try", ":", "return", "self", ".", "_indexes", "[", "name", "]", "except", "KeyError", ":", "raise", "KeyError", "(", "'Index \"%s\" has not bee...
Returns index transforms for ``name``. :type name: unicode :rtype: ``{ create |--> function, transform |--> function }``
[ "Returns", "index", "transforms", "for", "name", "." ]
python
test
34
saltstack/salt
salt/utils/process.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/process.py#L113-L124
def daemonize_if(opts): ''' Daemonize a module function process if multiprocessing is True and the process is not being called by salt-call ''' if 'salt-call' in sys.argv[0]: return if not opts.get('multiprocessing', True): return if sys.platform.startswith('win'): re...
[ "def", "daemonize_if", "(", "opts", ")", ":", "if", "'salt-call'", "in", "sys", ".", "argv", "[", "0", "]", ":", "return", "if", "not", "opts", ".", "get", "(", "'multiprocessing'", ",", "True", ")", ":", "return", "if", "sys", ".", "platform", ".", ...
Daemonize a module function process if multiprocessing is True and the process is not being called by salt-call
[ "Daemonize", "a", "module", "function", "process", "if", "multiprocessing", "is", "True", "and", "the", "process", "is", "not", "being", "called", "by", "salt", "-", "call" ]
python
train
27.833333
bslatkin/dpxdt
dpxdt/server/work_queue.py
https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L100-L145
def add(queue_name, payload=None, content_type=None, source=None, task_id=None, build_id=None, release_id=None, run_id=None): """Adds a work item to a queue. Args: queue_name: Name of the queue to add the work item to. payload: Optional. Payload that describes the work to do as a string...
[ "def", "add", "(", "queue_name", ",", "payload", "=", "None", ",", "content_type", "=", "None", ",", "source", "=", "None", ",", "task_id", "=", "None", ",", "build_id", "=", "None", ",", "release_id", "=", "None", ",", "run_id", "=", "None", ")", ":...
Adds a work item to a queue. Args: queue_name: Name of the queue to add the work item to. payload: Optional. Payload that describes the work to do as a string. If not a string and content_type is not provided, then this function assumes the payload is a JSON-able Python obje...
[ "Adds", "a", "work", "item", "to", "a", "queue", "." ]
python
train
37.108696
python-gitlab/python-gitlab
gitlab/v4/objects.py
https://github.com/python-gitlab/python-gitlab/blob/16de1b03fde3dbbe8f851614dd1d8c09de102fe5/gitlab/v4/objects.py#L768-L793
def issues(self, **kwargs): """List issues related to this milestone. Args: all (bool): If True, return all the items, without pagination per_page (int): Number of items to retrieve per request page (int): ID of the page to return (starts with page 1) as_...
[ "def", "issues", "(", "self", ",", "*", "*", "kwargs", ")", ":", "path", "=", "'%s/%s/issues'", "%", "(", "self", ".", "manager", ".", "path", ",", "self", ".", "get_id", "(", ")", ")", "data_list", "=", "self", ".", "manager", ".", "gitlab", ".", ...
List issues related to this milestone. Args: all (bool): If True, return all the items, without pagination per_page (int): Number of items to retrieve per request page (int): ID of the page to return (starts with page 1) as_list (bool): If set to False and no pag...
[ "List", "issues", "related", "to", "this", "milestone", "." ]
python
train
44.807692
Jaymon/prom
prom/interface/base.py
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L599-L639
def _query(self, query_str, query_args=None, **query_options): """ **query_options -- dict ignore_result -- boolean -- true to not attempt to fetch results fetchone -- boolean -- true to only fetch one result count_result -- boolean -- true to return the int count of ...
[ "def", "_query", "(", "self", ",", "query_str", ",", "query_args", "=", "None", ",", "*", "*", "query_options", ")", ":", "ret", "=", "True", "# http://stackoverflow.com/questions/6739355/dictcursor-doesnt-seem-to-work-under-psycopg2", "connection", "=", "query_options", ...
**query_options -- dict ignore_result -- boolean -- true to not attempt to fetch results fetchone -- boolean -- true to only fetch one result count_result -- boolean -- true to return the int count of rows affected
[ "**", "query_options", "--", "dict", "ignore_result", "--", "boolean", "--", "true", "to", "not", "attempt", "to", "fetch", "results", "fetchone", "--", "boolean", "--", "true", "to", "only", "fetch", "one", "result", "count_result", "--", "boolean", "--", "...
python
train
40.707317
Cito/DBUtils
DBUtils/SteadyDB.py
https://github.com/Cito/DBUtils/blob/90e8825e038f08c82044b8e50831480175fa026a/DBUtils/SteadyDB.py#L111-L139
def connect( creator, maxusage=None, setsession=None, failures=None, ping=1, closeable=True, *args, **kwargs): """A tough version of the connection constructor of a DB-API 2 module. creator: either an arbitrary function returning new DB-API 2 compliant connection objects or a DB-API 2 c...
[ "def", "connect", "(", "creator", ",", "maxusage", "=", "None", ",", "setsession", "=", "None", ",", "failures", "=", "None", ",", "ping", "=", "1", ",", "closeable", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "Stea...
A tough version of the connection constructor of a DB-API 2 module. creator: either an arbitrary function returning new DB-API 2 compliant connection objects or a DB-API 2 compliant database module maxusage: maximum usage limit for the underlying DB-API 2 connection (number of database operatio...
[ "A", "tough", "version", "of", "the", "connection", "constructor", "of", "a", "DB", "-", "API", "2", "module", "." ]
python
train
57.310345