repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
pytroll/posttroll
posttroll/message_broadcaster.py
https://github.com/pytroll/posttroll/blob/8e811a0544b5182c4a72aed074b2ff8c4324e94d/posttroll/message_broadcaster.py#L127-L150
def _run(self): """Broadcasts forever. """ self._is_running = True network_fail = False try: while self._do_run: try: if network_fail is True: LOGGER.info("Network connection re-established!") ...
[ "def", "_run", "(", "self", ")", ":", "self", ".", "_is_running", "=", "True", "network_fail", "=", "False", "try", ":", "while", "self", ".", "_do_run", ":", "try", ":", "if", "network_fail", "is", "True", ":", "LOGGER", ".", "info", "(", "\"Network c...
Broadcasts forever.
[ "Broadcasts", "forever", "." ]
python
train
PMEAL/OpenPNM
openpnm/core/ModelsMixin.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/core/ModelsMixin.py#L307-L335
def remove_model(self, propname=None, mode=['model', 'data']): r""" Removes model and data from object. Parameters ---------- propname : string or list of strings The property or list of properties to remove mode : list of strings Controls what i...
[ "def", "remove_model", "(", "self", ",", "propname", "=", "None", ",", "mode", "=", "[", "'model'", ",", "'data'", "]", ")", ":", "if", "type", "(", "propname", ")", "is", "str", ":", "propname", "=", "[", "propname", "]", "for", "item", "in", "pro...
r""" Removes model and data from object. Parameters ---------- propname : string or list of strings The property or list of properties to remove mode : list of strings Controls what is removed. Options are: *'model'* : Removes the model but...
[ "r", "Removes", "model", "and", "data", "from", "object", "." ]
python
train
tanghaibao/goatools
goatools/grouper/read_goids.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/read_goids.py#L94-L107
def _read_finish(self, goids_fin, prt): """Get one of: {'goids':...} or {'sections':...} from reading a file.""" # Report unused sections, if any if len(self.section2goids) != len(self.sections_seen): self._rpt_unused_sections(prt) # If there are no sections, then goids_fin h...
[ "def", "_read_finish", "(", "self", ",", "goids_fin", ",", "prt", ")", ":", "# Report unused sections, if any", "if", "len", "(", "self", ".", "section2goids", ")", "!=", "len", "(", "self", ".", "sections_seen", ")", ":", "self", ".", "_rpt_unused_sections", ...
Get one of: {'goids':...} or {'sections':...} from reading a file.
[ "Get", "one", "of", ":", "{", "goids", ":", "...", "}", "or", "{", "sections", ":", "...", "}", "from", "reading", "a", "file", "." ]
python
train
StanfordVL/robosuite
robosuite/devices/spacemouse.py
https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/devices/spacemouse.py#L138-L153
def get_controller_state(self): """Returns the current state of the 3d mouse, a dictionary of pos, orn, grasp, and reset.""" dpos = self.control[:3] * 0.005 roll, pitch, yaw = self.control[3:] * 0.005 self.grasp = self.control_gripper # convert RPY to an absolute orientation ...
[ "def", "get_controller_state", "(", "self", ")", ":", "dpos", "=", "self", ".", "control", "[", ":", "3", "]", "*", "0.005", "roll", ",", "pitch", ",", "yaw", "=", "self", ".", "control", "[", "3", ":", "]", "*", "0.005", "self", ".", "grasp", "=...
Returns the current state of the 3d mouse, a dictionary of pos, orn, grasp, and reset.
[ "Returns", "the", "current", "state", "of", "the", "3d", "mouse", "a", "dictionary", "of", "pos", "orn", "grasp", "and", "reset", "." ]
python
train
fermiPy/fermipy
fermipy/roi_model.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L2087-L2099
def _build_src_index(self): """Build an indices for fast lookup of a source given its name or coordinates.""" self._srcs = sorted(self._srcs, key=lambda t: t['offset']) nsrc = len(self._srcs) radec = np.zeros((2, nsrc)) for i, src in enumerate(self._srcs): r...
[ "def", "_build_src_index", "(", "self", ")", ":", "self", ".", "_srcs", "=", "sorted", "(", "self", ".", "_srcs", ",", "key", "=", "lambda", "t", ":", "t", "[", "'offset'", "]", ")", "nsrc", "=", "len", "(", "self", ".", "_srcs", ")", "radec", "=...
Build an indices for fast lookup of a source given its name or coordinates.
[ "Build", "an", "indices", "for", "fast", "lookup", "of", "a", "source", "given", "its", "name", "or", "coordinates", "." ]
python
train
pavlov99/jsonapi
jsonapi/django_utils.py
https://github.com/pavlov99/jsonapi/blob/c27943f22f1f1d30d651fe267a99d2b38f69d604/jsonapi/django_utils.py#L38-L52
def get_model_name(model): """ Get model name for the field. Django 1.5 uses module_name, does not support model_name Django 1.6 uses module_name and model_name DJango 1.7 uses model_name, module_name raises RemovedInDjango18Warning """ opts = model._meta if django.VERSION[:2] < (1, 7): ...
[ "def", "get_model_name", "(", "model", ")", ":", "opts", "=", "model", ".", "_meta", "if", "django", ".", "VERSION", "[", ":", "2", "]", "<", "(", "1", ",", "7", ")", ":", "model_name", "=", "opts", ".", "module_name", "else", ":", "model_name", "=...
Get model name for the field. Django 1.5 uses module_name, does not support model_name Django 1.6 uses module_name and model_name DJango 1.7 uses model_name, module_name raises RemovedInDjango18Warning
[ "Get", "model", "name", "for", "the", "field", "." ]
python
train
mosesschwartz/scrypture
scrypture/scrypture.py
https://github.com/mosesschwartz/scrypture/blob/d51eb0c9835a5122a655078268185ce8ab9ec86a/scrypture/scrypture.py#L145-L183
def run_script_api(module_name): '''API handler. Take script input (from script_input above), run the run() function, and return the results''' filename = '' file_stream = '' #form = {k : try_json(v) for k,v in request.values.items()} form = request.values.to_dict(flat=False) if request.json...
[ "def", "run_script_api", "(", "module_name", ")", ":", "filename", "=", "''", "file_stream", "=", "''", "#form = {k : try_json(v) for k,v in request.values.items()}", "form", "=", "request", ".", "values", ".", "to_dict", "(", "flat", "=", "False", ")", "if", "req...
API handler. Take script input (from script_input above), run the run() function, and return the results
[ "API", "handler", ".", "Take", "script", "input", "(", "from", "script_input", "above", ")", "run", "the", "run", "()", "function", "and", "return", "the", "results" ]
python
train
ungarj/tilematrix
tilematrix/_tilepyramid.py
https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L82-L90
def matrix_height(self, zoom): """ Tile matrix height (number of rows) at zoom level. - zoom: zoom level """ validate_zoom(zoom) height = int(math.ceil(self.grid.shape.height * 2**(zoom) / self.metatiling)) return 1 if height < 1 else height
[ "def", "matrix_height", "(", "self", ",", "zoom", ")", ":", "validate_zoom", "(", "zoom", ")", "height", "=", "int", "(", "math", ".", "ceil", "(", "self", ".", "grid", ".", "shape", ".", "height", "*", "2", "**", "(", "zoom", ")", "/", "self", "...
Tile matrix height (number of rows) at zoom level. - zoom: zoom level
[ "Tile", "matrix", "height", "(", "number", "of", "rows", ")", "at", "zoom", "level", "." ]
python
train
rdussurget/py-altimetry
altimetry/tools/spectrum.py
https://github.com/rdussurget/py-altimetry/blob/57ce7f2d63c6bbc4993821af0bbe46929e3a2d98/altimetry/tools/spectrum.py#L1075-L1094
def optimal_AR_spectrum(dx, Y, ndegrees=None,return_min=True): ''' Get the optimal order AR spectrum by minimizing the BIC. ''' if ndegrees is None : ndegrees=len(Y)-ndegrees aicc=np.arange(ndegrees) aic=aicc.copy() bic=aicc.copy() tmpStr=[] for i in np.arange(1,...
[ "def", "optimal_AR_spectrum", "(", "dx", ",", "Y", ",", "ndegrees", "=", "None", ",", "return_min", "=", "True", ")", ":", "if", "ndegrees", "is", "None", ":", "ndegrees", "=", "len", "(", "Y", ")", "-", "ndegrees", "aicc", "=", "np", ".", "arange", ...
Get the optimal order AR spectrum by minimizing the BIC.
[ "Get", "the", "optimal", "order", "AR", "spectrum", "by", "minimizing", "the", "BIC", "." ]
python
train
bachya/regenmaschine
regenmaschine/zone.py
https://github.com/bachya/regenmaschine/blob/99afb648fe454dc4a7d5db85a02a8b3b5d26f8bc/regenmaschine/zone.py#L17-L25
async def all( self, *, details: bool = False, include_inactive: bool = False) -> list: """Return all zones (with optional advanced properties).""" endpoint = 'zone' if details: endpoint += '/properties' data = await self._request('get', endpoint) ...
[ "async", "def", "all", "(", "self", ",", "*", ",", "details", ":", "bool", "=", "False", ",", "include_inactive", ":", "bool", "=", "False", ")", "->", "list", ":", "endpoint", "=", "'zone'", "if", "details", ":", "endpoint", "+=", "'/properties'", "da...
Return all zones (with optional advanced properties).
[ "Return", "all", "zones", "(", "with", "optional", "advanced", "properties", ")", "." ]
python
train
square/pylink
pylink/util.py
https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/util.py#L159-L182
def calculate_parity(n): """Calculates and returns the parity of a number. The parity of a number is ``1`` if the number has an odd number of ones in its binary representation, otherwise ``0``. Args: n (int): the number whose parity to calculate Returns: ``1`` if the number has an odd...
[ "def", "calculate_parity", "(", "n", ")", ":", "if", "not", "is_natural", "(", "n", ")", ":", "raise", "ValueError", "(", "'Expected n to be a positive integer.'", ")", "y", "=", "0", "n", "=", "abs", "(", "n", ")", "while", "n", ":", "y", "+=", "n", ...
Calculates and returns the parity of a number. The parity of a number is ``1`` if the number has an odd number of ones in its binary representation, otherwise ``0``. Args: n (int): the number whose parity to calculate Returns: ``1`` if the number has an odd number of ones, otherwise ``0``...
[ "Calculates", "and", "returns", "the", "parity", "of", "a", "number", "." ]
python
train
DLR-RM/RAFCON
source/rafcon/gui/mygaphas/items/ports.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/items/ports.py#L570-L586
def _draw_rectangle(context, width, height): """Draw a rectangle Assertion: The current point is the center point of the rectangle :param context: Cairo context :param width: Width of the rectangle :param height: Height of the rectangle """ c = context #...
[ "def", "_draw_rectangle", "(", "context", ",", "width", ",", "height", ")", ":", "c", "=", "context", "# First move to upper left corner", "c", ".", "rel_move_to", "(", "-", "width", "/", "2.", ",", "-", "height", "/", "2.", ")", "# Draw closed rectangle", "...
Draw a rectangle Assertion: The current point is the center point of the rectangle :param context: Cairo context :param width: Width of the rectangle :param height: Height of the rectangle
[ "Draw", "a", "rectangle" ]
python
train
draios/python-sdc-client
sdcclient/_secure.py
https://github.com/draios/python-sdc-client/blob/47f83415842048778939b90944f64386a3bcb205/sdcclient/_secure.py#L932-L948
def get_command_audit(self, id, metrics=[]): '''**Description** Get a command audit. **Arguments** - id: the id of the command audit to get. **Success Return Value** A JSON representation of the command audit. ''' url = "{url}/api/commands/{i...
[ "def", "get_command_audit", "(", "self", ",", "id", ",", "metrics", "=", "[", "]", ")", ":", "url", "=", "\"{url}/api/commands/{id}?from=0&to={to}{metrics}\"", ".", "format", "(", "url", "=", "self", ".", "url", ",", "id", "=", "id", ",", "to", "=", "int...
**Description** Get a command audit. **Arguments** - id: the id of the command audit to get. **Success Return Value** A JSON representation of the command audit.
[ "**", "Description", "**", "Get", "a", "command", "audit", "." ]
python
test
Fantomas42/django-blog-zinnia
zinnia/search.py
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/search.py#L90-L113
def union_q(token): """ Appends all the Q() objects. """ query = Q() operation = 'and' negation = False for t in token: if type(t) is ParseResults: # See tokens recursively query &= union_q(t) else: if t in ('or', 'and'): # Set the new op and go to ...
[ "def", "union_q", "(", "token", ")", ":", "query", "=", "Q", "(", ")", "operation", "=", "'and'", "negation", "=", "False", "for", "t", "in", "token", ":", "if", "type", "(", "t", ")", "is", "ParseResults", ":", "# See tokens recursively", "query", "&=...
Appends all the Q() objects.
[ "Appends", "all", "the", "Q", "()", "objects", "." ]
python
train
nesaro/pydsl
pydsl/extract.py
https://github.com/nesaro/pydsl/blob/00b4fffd72036b80335e1a44a888fac57917ab41/pydsl/extract.py#L76-L111
def extract(grammar, inputdata, fixed_start = False, return_first=False): """ Receives a sequence and a grammar, returns a list of PositionTokens with all of the parts of the sequence that are recognized by the grammar """ if not inputdata: return [] checker = checker_factory(gramm...
[ "def", "extract", "(", "grammar", ",", "inputdata", ",", "fixed_start", "=", "False", ",", "return_first", "=", "False", ")", ":", "if", "not", "inputdata", ":", "return", "[", "]", "checker", "=", "checker_factory", "(", "grammar", ")", "totallen", "=", ...
Receives a sequence and a grammar, returns a list of PositionTokens with all of the parts of the sequence that are recognized by the grammar
[ "Receives", "a", "sequence", "and", "a", "grammar", "returns", "a", "list", "of", "PositionTokens", "with", "all", "of", "the", "parts", "of", "the", "sequence", "that", "are", "recognized", "by", "the", "grammar" ]
python
train
ansible/tower-cli
tower_cli/conf.py
https://github.com/ansible/tower-cli/blob/a2b151fed93c47725018d3034848cb3a1814bed7/tower_cli/conf.py#L337-L347
def config_from_environment(): """Read tower-cli config values from the environment if present, being careful not to override config values that were explicitly passed in. """ kwargs = {} for k in CONFIG_OPTIONS: env = 'TOWER_' + k.upper() v = os.getenv(env, None) if v is not...
[ "def", "config_from_environment", "(", ")", ":", "kwargs", "=", "{", "}", "for", "k", "in", "CONFIG_OPTIONS", ":", "env", "=", "'TOWER_'", "+", "k", ".", "upper", "(", ")", "v", "=", "os", ".", "getenv", "(", "env", ",", "None", ")", "if", "v", "...
Read tower-cli config values from the environment if present, being careful not to override config values that were explicitly passed in.
[ "Read", "tower", "-", "cli", "config", "values", "from", "the", "environment", "if", "present", "being", "careful", "not", "to", "override", "config", "values", "that", "were", "explicitly", "passed", "in", "." ]
python
valid
autokey/autokey
lib/autokey/qtui/configwindow.py
https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/configwindow.py#L146-L163
def _set_platform_specific_keyboard_shortcuts(self): """ QtDesigner does not support QKeySequence::StandardKey enum based default keyboard shortcuts. This means that all default key combinations ("Save", "Quit", etc) have to be defined in code. """ self.action_new_phrase.setShort...
[ "def", "_set_platform_specific_keyboard_shortcuts", "(", "self", ")", ":", "self", ".", "action_new_phrase", ".", "setShortcuts", "(", "QKeySequence", ".", "New", ")", "self", ".", "action_save", ".", "setShortcuts", "(", "QKeySequence", ".", "Save", ")", "self", ...
QtDesigner does not support QKeySequence::StandardKey enum based default keyboard shortcuts. This means that all default key combinations ("Save", "Quit", etc) have to be defined in code.
[ "QtDesigner", "does", "not", "support", "QKeySequence", "::", "StandardKey", "enum", "based", "default", "keyboard", "shortcuts", ".", "This", "means", "that", "all", "default", "key", "combinations", "(", "Save", "Quit", "etc", ")", "have", "to", "be", "defin...
python
train
estnltk/estnltk
estnltk/mw_verbs/utils.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/mw_verbs/utils.py#L166-L200
def matchingAnalyses(self, tokenJson): '''Determines whether given token (tokenJson) satisfies all the rules listed in the WordTemplate and returns a list of analyses (elements of tokenJson[ANALYSIS]) that are matching all the rules. An empty list is returned if none of t...
[ "def", "matchingAnalyses", "(", "self", ",", "tokenJson", ")", ":", "matchingResults", "=", "[", "]", "if", "self", ".", "otherRules", "!=", "None", ":", "otherMatches", "=", "[", "]", "for", "field", "in", "self", ".", "otherRules", ":", "match", "=", ...
Determines whether given token (tokenJson) satisfies all the rules listed in the WordTemplate and returns a list of analyses (elements of tokenJson[ANALYSIS]) that are matching all the rules. An empty list is returned if none of the analyses match (all the rules), or (!) if none o...
[ "Determines", "whether", "given", "token", "(", "tokenJson", ")", "satisfies", "all", "the", "rules", "listed", "in", "the", "WordTemplate", "and", "returns", "a", "list", "of", "analyses", "(", "elements", "of", "tokenJson", "[", "ANALYSIS", "]", ")", "that...
python
train
Gandi/gandi.cli
gandi/cli/core/conf.py
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/core/conf.py#L191-L202
def configure(cls, global_, key, val): """ Update and save configuration value to file. """ # first retrieve current configuration scope = 'global' if global_ else 'local' if scope not in cls._conffiles: cls._conffiles[scope] = {} config = cls._conffiles.get(scope, {}...
[ "def", "configure", "(", "cls", ",", "global_", ",", "key", ",", "val", ")", ":", "# first retrieve current configuration", "scope", "=", "'global'", "if", "global_", "else", "'local'", "if", "scope", "not", "in", "cls", ".", "_conffiles", ":", "cls", ".", ...
Update and save configuration value to file.
[ "Update", "and", "save", "configuration", "value", "to", "file", "." ]
python
train
pywbem/pywbem
pywbem_mock/_wbemconnection_mock.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/pywbem_mock/_wbemconnection_mock.py#L416-L451
def add_namespace(self, namespace): """ Add a CIM namespace to the mock repository. The namespace must not yet exist in the mock repository. Note that the default connection namespace is automatically added to the mock repository upon creation of this object. Parameter...
[ "def", "add_namespace", "(", "self", ",", "namespace", ")", ":", "if", "namespace", "is", "None", ":", "raise", "ValueError", "(", "\"Namespace argument must not be None\"", ")", "# Normalize the namespace name", "namespace", "=", "namespace", ".", "strip", "(", "'/...
Add a CIM namespace to the mock repository. The namespace must not yet exist in the mock repository. Note that the default connection namespace is automatically added to the mock repository upon creation of this object. Parameters: namespace (:term:`string`): Th...
[ "Add", "a", "CIM", "namespace", "to", "the", "mock", "repository", "." ]
python
train
jspricke/python-icstask
icstask.py
https://github.com/jspricke/python-icstask/blob/0802233cca569c2174bd96aed0682d04a2a63790/icstask.py#L316-L326
def replace_vobject(self, uuid, vtodo, project=None): """Update the task with the UID from the vObject uuid -- the UID of the task vtodo -- the iCalendar to add project -- the project to add (see get_filesnames() as well) """ self._update() uuid = uuid.split('@')[...
[ "def", "replace_vobject", "(", "self", ",", "uuid", ",", "vtodo", ",", "project", "=", "None", ")", ":", "self", ".", "_update", "(", ")", "uuid", "=", "uuid", ".", "split", "(", "'@'", ")", "[", "0", "]", "if", "project", ":", "project", "=", "b...
Update the task with the UID from the vObject uuid -- the UID of the task vtodo -- the iCalendar to add project -- the project to add (see get_filesnames() as well)
[ "Update", "the", "task", "with", "the", "UID", "from", "the", "vObject", "uuid", "--", "the", "UID", "of", "the", "task", "vtodo", "--", "the", "iCalendar", "to", "add", "project", "--", "the", "project", "to", "add", "(", "see", "get_filesnames", "()", ...
python
train
Nekroze/partpy
partpy/sourcestring.py
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L61-L69
def eol_distance_next(self, offset=0): """Return the amount of characters until the next newline.""" distance = 0 for char in self.string[self.pos + offset:]: if char == '\n': break else: distance += 1 return distance
[ "def", "eol_distance_next", "(", "self", ",", "offset", "=", "0", ")", ":", "distance", "=", "0", "for", "char", "in", "self", ".", "string", "[", "self", ".", "pos", "+", "offset", ":", "]", ":", "if", "char", "==", "'\\n'", ":", "break", "else", ...
Return the amount of characters until the next newline.
[ "Return", "the", "amount", "of", "characters", "until", "the", "next", "newline", "." ]
python
train
Qiskit/qiskit-terra
qiskit/quantum_info/operators/predicates.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/quantum_info/operators/predicates.py#L110-L123
def is_positive_semidefinite_matrix(mat, rtol=RTOL_DEFAULT, atol=ATOL_DEFAULT): """Test if a matrix is positive semidefinite""" if atol is None: atol = ATOL_DEFAULT if rtol is None: rtol = RTOL_DEFAULT if not is_hermitian_matrix(mat, rtol=rtol, atol=atol): return False # Chec...
[ "def", "is_positive_semidefinite_matrix", "(", "mat", ",", "rtol", "=", "RTOL_DEFAULT", ",", "atol", "=", "ATOL_DEFAULT", ")", ":", "if", "atol", "is", "None", ":", "atol", "=", "ATOL_DEFAULT", "if", "rtol", "is", "None", ":", "rtol", "=", "RTOL_DEFAULT", ...
Test if a matrix is positive semidefinite
[ "Test", "if", "a", "matrix", "is", "positive", "semidefinite" ]
python
test
crypto101/arthur
arthur/ui.py
https://github.com/crypto101/arthur/blob/c32e693fb5af17eac010e3b20f7653ed6e11eb6a/arthur/ui.py#L306-L311
def _makeTextWidgets(self): """Makes an editable prompt widget. """ self.prompt = urwid.Edit(self.promptText, multiline=False) return [self.prompt]
[ "def", "_makeTextWidgets", "(", "self", ")", ":", "self", ".", "prompt", "=", "urwid", ".", "Edit", "(", "self", ".", "promptText", ",", "multiline", "=", "False", ")", "return", "[", "self", ".", "prompt", "]" ]
Makes an editable prompt widget.
[ "Makes", "an", "editable", "prompt", "widget", "." ]
python
train
EmbodiedCognition/py-c3d
c3d.py
https://github.com/EmbodiedCognition/py-c3d/blob/391493d9cb4c6b4aaeee4de2930685e3a67f5845/c3d.py#L239-L260
def write(self, group_id, handle): '''Write binary data for this parameter to a file handle. Parameters ---------- group_id : int The numerical ID of the group that holds this parameter. handle : file handle An open, writable, binary file handle. ...
[ "def", "write", "(", "self", ",", "group_id", ",", "handle", ")", ":", "name", "=", "self", ".", "name", ".", "encode", "(", "'utf-8'", ")", "handle", ".", "write", "(", "struct", ".", "pack", "(", "'bb'", ",", "len", "(", "name", ")", ",", "grou...
Write binary data for this parameter to a file handle. Parameters ---------- group_id : int The numerical ID of the group that holds this parameter. handle : file handle An open, writable, binary file handle.
[ "Write", "binary", "data", "for", "this", "parameter", "to", "a", "file", "handle", "." ]
python
train
mabuchilab/QNET
src/qnet/printing/_unicode_mappings.py
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/_unicode_mappings.py#L44-L120
def render_unicode_sub_super( name, subs=None, supers=None, sub_first=True, translate_symbols=True, unicode_sub_super=True, sep=',', subscript_max_len=1): """Assemble a string from the primary name and the given sub- and superscripts:: >>> render_unicode_sub_super(name='alpha', subs=['mu', ...
[ "def", "render_unicode_sub_super", "(", "name", ",", "subs", "=", "None", ",", "supers", "=", "None", ",", "sub_first", "=", "True", ",", "translate_symbols", "=", "True", ",", "unicode_sub_super", "=", "True", ",", "sep", "=", "','", ",", "subscript_max_len...
Assemble a string from the primary name and the given sub- and superscripts:: >>> render_unicode_sub_super(name='alpha', subs=['mu', 'nu'], supers=[2]) 'α_μ,ν^2' >>> render_unicode_sub_super( ... name='alpha', subs=['1', '2'], supers=['(1)'], sep='') 'α₁₂⁽¹⁾' >>> render_unicode_sub_su...
[ "Assemble", "a", "string", "from", "the", "primary", "name", "and", "the", "given", "sub", "-", "and", "superscripts", "::" ]
python
train
nion-software/nionswift
nion/swift/model/Profile.py
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/Profile.py#L99-L117
def _migrate_library(workspace_dir: pathlib.Path, do_logging: bool=True) -> pathlib.Path: """ Migrate library to latest version. """ library_path_11 = workspace_dir / "Nion Swift Workspace.nslib" library_path_12 = workspace_dir / "Nion Swift Library 12.nslib" library_path_13 = workspace_dir / "Nion Swi...
[ "def", "_migrate_library", "(", "workspace_dir", ":", "pathlib", ".", "Path", ",", "do_logging", ":", "bool", "=", "True", ")", "->", "pathlib", ".", "Path", ":", "library_path_11", "=", "workspace_dir", "/", "\"Nion Swift Workspace.nslib\"", "library_path_12", "=...
Migrate library to latest version.
[ "Migrate", "library", "to", "latest", "version", "." ]
python
train
dourvaris/nano-python
src/nano/rpc.py
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/rpc.py#L2667-L2695
def wallet_work_get(self, wallet): """ Returns a list of pairs of account and work from **wallet** .. enable_control required .. version 8.0 required :param wallet: Wallet to return work for :type wallet: str :raises: :py:exc:`nano.rpc.RPCException` >>...
[ "def", "wallet_work_get", "(", "self", ",", "wallet", ")", ":", "wallet", "=", "self", ".", "_process_value", "(", "wallet", ",", "'wallet'", ")", "payload", "=", "{", "\"wallet\"", ":", "wallet", "}", "resp", "=", "self", ".", "call", "(", "'wallet_work...
Returns a list of pairs of account and work from **wallet** .. enable_control required .. version 8.0 required :param wallet: Wallet to return work for :type wallet: str :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.wallet_work_get( ... wallet="000D1BAE...
[ "Returns", "a", "list", "of", "pairs", "of", "account", "and", "work", "from", "**", "wallet", "**" ]
python
train
ralphhaygood/sklearn-gbmi
sklearn_gbmi/sklearn_gbmi.py
https://github.com/ralphhaygood/sklearn-gbmi/blob/23a1e7fd50e53d6261379f22a337d8fa4ee6aabe/sklearn_gbmi/sklearn_gbmi.py#L16-L95
def h(gbm, array_or_frame, indices_or_columns = 'all'): """ PURPOSE Compute Friedman and Popescu's H statistic, in order to look for an interaction in the passed gradient-boosting model among the variables represented by the elements of the passed array or frame and specified by the passed indices ...
[ "def", "h", "(", "gbm", ",", "array_or_frame", ",", "indices_or_columns", "=", "'all'", ")", ":", "if", "indices_or_columns", "==", "'all'", ":", "if", "gbm", ".", "max_depth", "<", "array_or_frame", ".", "shape", "[", "1", "]", ":", "raise", "Exception", ...
PURPOSE Compute Friedman and Popescu's H statistic, in order to look for an interaction in the passed gradient-boosting model among the variables represented by the elements of the passed array or frame and specified by the passed indices or columns. See Jerome H. Friedman and Bogdan E. Popescu, 2008,...
[ "PURPOSE" ]
python
train
mikedh/trimesh
trimesh/util.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/util.py#L1067-L1106
def array_to_encoded(array, dtype=None, encoding='base64'): """ Export a numpy array to a compact serializable dictionary. Parameters ------------ array : array Any numpy array dtype : str or None Optional dtype to encode array encoding : str 'base64' or 'binary' Retu...
[ "def", "array_to_encoded", "(", "array", ",", "dtype", "=", "None", ",", "encoding", "=", "'base64'", ")", ":", "array", "=", "np", ".", "asanyarray", "(", "array", ")", "shape", "=", "array", ".", "shape", "# ravel also forces contiguous", "flat", "=", "n...
Export a numpy array to a compact serializable dictionary. Parameters ------------ array : array Any numpy array dtype : str or None Optional dtype to encode array encoding : str 'base64' or 'binary' Returns --------- encoded : dict Has keys: 'dtype': str...
[ "Export", "a", "numpy", "array", "to", "a", "compact", "serializable", "dictionary", "." ]
python
train
rvswift/EB
EB/builder/postanalysis/postanalysis.py
https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/postanalysis/postanalysis.py#L106-L133
def evaluate_list(molecules, ensemble_lookup, options): """ Evaluate a list of ensembles and return statistics and ROC plots if appropriate """ # create stats dictionaries to store results from each ensemble stats = {} # {file name : metric_List} # print progress messages if options.write...
[ "def", "evaluate_list", "(", "molecules", ",", "ensemble_lookup", ",", "options", ")", ":", "# create stats dictionaries to store results from each ensemble", "stats", "=", "{", "}", "# {file name : metric_List}", "# print progress messages", "if", "options", ".", "write_roc"...
Evaluate a list of ensembles and return statistics and ROC plots if appropriate
[ "Evaluate", "a", "list", "of", "ensembles", "and", "return", "statistics", "and", "ROC", "plots", "if", "appropriate" ]
python
train
evolbioinfo/pastml
pastml/ml.py
https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/ml.py#L476-L493
def convert_likelihoods_to_probabilities(tree, feature, states): """ Normalizes each node marginal likelihoods to convert them to marginal probabilities. :param states: numpy array of states in the order corresponding to the marginal likelihood arrays :param tree: ete3.Tree, the tree of interest :p...
[ "def", "convert_likelihoods_to_probabilities", "(", "tree", ",", "feature", ",", "states", ")", ":", "lh_feature", "=", "get_personalized_feature_name", "(", "feature", ",", "LH", ")", "name2probs", "=", "{", "}", "for", "node", "in", "tree", ".", "traverse", ...
Normalizes each node marginal likelihoods to convert them to marginal probabilities. :param states: numpy array of states in the order corresponding to the marginal likelihood arrays :param tree: ete3.Tree, the tree of interest :param feature: str, character for which the probabilities are calculated :...
[ "Normalizes", "each", "node", "marginal", "likelihoods", "to", "convert", "them", "to", "marginal", "probabilities", "." ]
python
train
MisterY/gnucash-portfolio
gnucash_portfolio/model/price_model.py
https://github.com/MisterY/gnucash-portfolio/blob/bfaad8345a5479d1cd111acee1939e25c2a638c2/gnucash_portfolio/model/price_model.py#L27-L32
def parse_value(self, value_string: str): """ Parses the amount string. """ self.value = Decimal(value_string) return self.value
[ "def", "parse_value", "(", "self", ",", "value_string", ":", "str", ")", ":", "self", ".", "value", "=", "Decimal", "(", "value_string", ")", "return", "self", ".", "value" ]
Parses the amount string.
[ "Parses", "the", "amount", "string", "." ]
python
train
annoviko/pyclustering
pyclustering/cluster/birch.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/birch.py#L175-L187
def __decode_data(self): """! @brief Decodes data from CF-tree features. """ self.__clusters = [ [] for _ in range(self.__number_clusters) ]; self.__noise = []; for index_point in range(0, len(self.__pointer_data)): (_, clu...
[ "def", "__decode_data", "(", "self", ")", ":", "self", ".", "__clusters", "=", "[", "[", "]", "for", "_", "in", "range", "(", "self", ".", "__number_clusters", ")", "]", "self", ".", "__noise", "=", "[", "]", "for", "index_point", "in", "range", "(",...
! @brief Decodes data from CF-tree features.
[ "!" ]
python
valid
amelchio/pysonos
pysonos/core.py
https://github.com/amelchio/pysonos/blob/23527c445a00e198fbb94d44b92f7f99d139e325/pysonos/core.py#L705-L716
def mute(self): """bool: The speaker's mute state. True if muted, False otherwise. """ response = self.renderingControl.GetMute([ ('InstanceID', 0), ('Channel', 'Master') ]) mute_state = response['CurrentMute'] return bool(int(mute_state)...
[ "def", "mute", "(", "self", ")", ":", "response", "=", "self", ".", "renderingControl", ".", "GetMute", "(", "[", "(", "'InstanceID'", ",", "0", ")", ",", "(", "'Channel'", ",", "'Master'", ")", "]", ")", "mute_state", "=", "response", "[", "'CurrentMu...
bool: The speaker's mute state. True if muted, False otherwise.
[ "bool", ":", "The", "speaker", "s", "mute", "state", "." ]
python
train
saltstack/salt
salt/modules/bcache.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/bcache.py#L267-L357
def cache_make(dev, reserved=None, force=False, block_size=None, bucket_size=None, attach=True): ''' Create BCache cache on a block device. If blkdiscard is available the entire device will be properly cleared in advance. CLI example: .. code-block:: bash salt '*' bcache.cache_make sdb re...
[ "def", "cache_make", "(", "dev", ",", "reserved", "=", "None", ",", "force", "=", "False", ",", "block_size", "=", "None", ",", "bucket_size", "=", "None", ",", "attach", "=", "True", ")", ":", "# TODO: multiple devs == md jbod", "# pylint: disable=too-many-retu...
Create BCache cache on a block device. If blkdiscard is available the entire device will be properly cleared in advance. CLI example: .. code-block:: bash salt '*' bcache.cache_make sdb reserved=10% block_size=4096 :param reserved: if dev is a full device, create a partition table with this...
[ "Create", "BCache", "cache", "on", "a", "block", "device", ".", "If", "blkdiscard", "is", "available", "the", "entire", "device", "will", "be", "properly", "cleared", "in", "advance", "." ]
python
train
hsharrison/pyglet2d
src/pyglet2d.py
https://github.com/hsharrison/pyglet2d/blob/46f610b3c76221bff19e5c0cf3d35d7875ce37a0/src/pyglet2d.py#L336-L343
def draw(self): """Draw the shape in the current OpenGL context. """ if self.enabled: self._vertex_list.colors = self._gl_colors self._vertex_list.vertices = self._gl_vertices self._vertex_list.draw(pyglet.gl.GL_TRIANGLES)
[ "def", "draw", "(", "self", ")", ":", "if", "self", ".", "enabled", ":", "self", ".", "_vertex_list", ".", "colors", "=", "self", ".", "_gl_colors", "self", ".", "_vertex_list", ".", "vertices", "=", "self", ".", "_gl_vertices", "self", ".", "_vertex_lis...
Draw the shape in the current OpenGL context.
[ "Draw", "the", "shape", "in", "the", "current", "OpenGL", "context", "." ]
python
valid
django-userena-ce/django-userena-ce
userena/managers.py
https://github.com/django-userena-ce/django-userena-ce/blob/2d8b745eed25128134e961ca96c270802e730256/userena/managers.py#L220-L234
def delete_expired_users(self): """ Checks for expired users and delete's the ``User`` associated with it. Skips if the user ``is_staff``. :return: A list containing the deleted users. """ deleted_users = [] for user in get_user_model().objects.filter(is_staff=F...
[ "def", "delete_expired_users", "(", "self", ")", ":", "deleted_users", "=", "[", "]", "for", "user", "in", "get_user_model", "(", ")", ".", "objects", ".", "filter", "(", "is_staff", "=", "False", ",", "is_active", "=", "False", ")", ":", "if", "user", ...
Checks for expired users and delete's the ``User`` associated with it. Skips if the user ``is_staff``. :return: A list containing the deleted users.
[ "Checks", "for", "expired", "users", "and", "delete", "s", "the", "User", "associated", "with", "it", ".", "Skips", "if", "the", "user", "is_staff", "." ]
python
train
pip-services3-python/pip-services3-components-python
pip_services3_components/count/CachedCounters.py
https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/count/CachedCounters.py#L142-L167
def get(self, name, typ): """ Gets a counter specified by its name. It counter does not exist or its type doesn't match the specified type it creates a new one. :param name: a counter name to retrieve. :param typ: a counter type. :return: an existing or newly c...
[ "def", "get", "(", "self", ",", "name", ",", "typ", ")", ":", "if", "name", "==", "None", "or", "len", "(", "name", ")", "==", "0", ":", "raise", "Exception", "(", "\"Counter name was not set\"", ")", "self", ".", "_lock", ".", "acquire", "(", ")", ...
Gets a counter specified by its name. It counter does not exist or its type doesn't match the specified type it creates a new one. :param name: a counter name to retrieve. :param typ: a counter type. :return: an existing or newly created counter of the specified type.
[ "Gets", "a", "counter", "specified", "by", "its", "name", ".", "It", "counter", "does", "not", "exist", "or", "its", "type", "doesn", "t", "match", "the", "specified", "type", "it", "creates", "a", "new", "one", "." ]
python
train
markchil/gptools
gptools/utils.py
https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L520-L554
def random_draw(self, size=None): """Draw random samples of the hyperparameters. Parameters ---------- size : None, int or array-like, optional The number/shape of samples to draw. If None, only one sample is returned. Default is None. """ ...
[ "def", "random_draw", "(", "self", ",", "size", "=", "None", ")", ":", "if", "size", "is", "None", ":", "size", "=", "1", "single_val", "=", "True", "else", ":", "single_val", "=", "False", "out_shape", "=", "[", "len", "(", "self", ".", "bounds", ...
Draw random samples of the hyperparameters. Parameters ---------- size : None, int or array-like, optional The number/shape of samples to draw. If None, only one sample is returned. Default is None.
[ "Draw", "random", "samples", "of", "the", "hyperparameters", ".", "Parameters", "----------", "size", ":", "None", "int", "or", "array", "-", "like", "optional", "The", "number", "/", "shape", "of", "samples", "to", "draw", ".", "If", "None", "only", "one"...
python
train
72squared/redpipe
redpipe/keyspaces.py
https://github.com/72squared/redpipe/blob/e6ee518bc9f3e2fee323c8c53d08997799bd9b1b/redpipe/keyspaces.py#L235-L244
def restorenx(self, name, value, pttl=0): """ Restore serialized dump of a key back into redis :param name: str the name of the redis key :param value: redis RDB-like serialization :param pttl: milliseconds till key expires :return: Future() """ retur...
[ "def", "restorenx", "(", "self", ",", "name", ",", "value", ",", "pttl", "=", "0", ")", ":", "return", "self", ".", "eval", "(", "lua_restorenx", ",", "1", ",", "name", ",", "pttl", ",", "value", ")" ]
Restore serialized dump of a key back into redis :param name: str the name of the redis key :param value: redis RDB-like serialization :param pttl: milliseconds till key expires :return: Future()
[ "Restore", "serialized", "dump", "of", "a", "key", "back", "into", "redis" ]
python
train
blockstack/blockstack-files
blockstack_file/blockstack_file.py
https://github.com/blockstack/blockstack-files/blob/8d88cc48bdf8ed57f17d4bba860e972bde321921/blockstack_file/blockstack_file.py#L442-L470
def file_verify( sender_blockchain_id, sender_key_id, input_path, sig, config_path=CONFIG_PATH, wallet_keys=None ): """ Verify that a file was signed with the given blockchain ID @config_path should be for the *client*, not blockstack-file Return {'status': True} on succes Return {'error': ...} on e...
[ "def", "file_verify", "(", "sender_blockchain_id", ",", "sender_key_id", ",", "input_path", ",", "sig", ",", "config_path", "=", "CONFIG_PATH", ",", "wallet_keys", "=", "None", ")", ":", "config_dir", "=", "os", ".", "path", ".", "dirname", "(", "config_path",...
Verify that a file was signed with the given blockchain ID @config_path should be for the *client*, not blockstack-file Return {'status': True} on succes Return {'error': ...} on error
[ "Verify", "that", "a", "file", "was", "signed", "with", "the", "given", "blockchain", "ID" ]
python
train
lucasmaystre/choix
choix/lsr.py
https://github.com/lucasmaystre/choix/blob/05a57a10bb707338113a9d91601ca528ead7a881/choix/lsr.py#L279-L314
def ilsr_rankings( n_items, data, alpha=0.0, initial_params=None, max_iter=100, tol=1e-8): """Compute the ML estimate of model parameters using I-LSR. This function computes the maximum-likelihood (ML) estimate of model parameters given ranking data (see :ref:`data-rankings`), using the iterati...
[ "def", "ilsr_rankings", "(", "n_items", ",", "data", ",", "alpha", "=", "0.0", ",", "initial_params", "=", "None", ",", "max_iter", "=", "100", ",", "tol", "=", "1e-8", ")", ":", "fun", "=", "functools", ".", "partial", "(", "lsr_rankings", ",", "n_ite...
Compute the ML estimate of model parameters using I-LSR. This function computes the maximum-likelihood (ML) estimate of model parameters given ranking data (see :ref:`data-rankings`), using the iterative Luce Spectral Ranking algorithm [MG15]_. The transition rates of the LSR Markov chain are initiali...
[ "Compute", "the", "ML", "estimate", "of", "model", "parameters", "using", "I", "-", "LSR", "." ]
python
train
openstack/networking-cisco
networking_cisco/ml2_drivers/ucsm/deprecated_network_driver.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/ml2_drivers/ucsm/deprecated_network_driver.py#L1009-L1020
def ucs_manager_disconnect(self, handle, ucsm_ip): """Disconnects from the UCS Manager. After the disconnect, the handle associated with this connection is no longer valid. """ try: handle.Logout() except Exception as e: # Raise a Neutron exceptio...
[ "def", "ucs_manager_disconnect", "(", "self", ",", "handle", ",", "ucsm_ip", ")", ":", "try", ":", "handle", ".", "Logout", "(", ")", "except", "Exception", "as", "e", ":", "# Raise a Neutron exception. Include a description of", "# the original exception.", "raise",...
Disconnects from the UCS Manager. After the disconnect, the handle associated with this connection is no longer valid.
[ "Disconnects", "from", "the", "UCS", "Manager", "." ]
python
train
hyperledger/indy-plenum
plenum/server/monitor.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L308-L326
def reset(self): """ Reset the monitor. Sets all monitored values to defaults. """ logger.debug("{}'s Monitor being reset".format(self)) instances_ids = self.instances.started.keys() self.numOrderedRequests = {inst_id: (0, 0) for inst_id in instances_ids} self.req...
[ "def", "reset", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"{}'s Monitor being reset\"", ".", "format", "(", "self", ")", ")", "instances_ids", "=", "self", ".", "instances", ".", "started", ".", "keys", "(", ")", "self", ".", "numOrderedRequest...
Reset the monitor. Sets all monitored values to defaults.
[ "Reset", "the", "monitor", ".", "Sets", "all", "monitored", "values", "to", "defaults", "." ]
python
train
saltstack/salt
salt/modules/parallels.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/parallels.py#L358-L374
def reset(name, runas=None): ''' Reset a VM by performing a hard shutdown and then a restart :param str name: Name/ID of VM to reset :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.reset macvm runas=m...
[ "def", "reset", "(", "name", ",", "runas", "=", "None", ")", ":", "return", "prlctl", "(", "'reset'", ",", "salt", ".", "utils", ".", "data", ".", "decode", "(", "name", ")", ",", "runas", "=", "runas", ")" ]
Reset a VM by performing a hard shutdown and then a restart :param str name: Name/ID of VM to reset :param str runas: The user that the prlctl command will be run as Example: .. code-block:: bash salt '*' parallels.reset macvm runas=macdev
[ "Reset", "a", "VM", "by", "performing", "a", "hard", "shutdown", "and", "then", "a", "restart" ]
python
train
aholkner/bacon
native/Vendor/FreeType/src/tools/docmaker/tohtml.py
https://github.com/aholkner/bacon/blob/edf3810dcb211942d392a8637945871399b0650d/native/Vendor/FreeType/src/tools/docmaker/tohtml.py#L287-L301
def make_html_para( self, words ): """ convert words of a paragraph into tagged HTML text, handle xrefs """ line = "" if words: line = self.make_html_word( words[0] ) for word in words[1:]: line = line + " " + self.make_html_word( word ) # con...
[ "def", "make_html_para", "(", "self", ",", "words", ")", ":", "line", "=", "\"\"", "if", "words", ":", "line", "=", "self", ".", "make_html_word", "(", "words", "[", "0", "]", ")", "for", "word", "in", "words", "[", "1", ":", "]", ":", "line", "=...
convert words of a paragraph into tagged HTML text, handle xrefs
[ "convert", "words", "of", "a", "paragraph", "into", "tagged", "HTML", "text", "handle", "xrefs" ]
python
test
onelogin/python3-saml
src/onelogin/saml2/settings.py
https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/settings.py#L45-L59
def validate_url(url): """ Auxiliary method to validate an urllib :param url: An url to be validated :type url: string :returns: True if the url is valid :rtype: bool """ scheme = url.split('://')[0].lower() if scheme not in url_schemes: return False if not bool(url_rege...
[ "def", "validate_url", "(", "url", ")", ":", "scheme", "=", "url", ".", "split", "(", "'://'", ")", "[", "0", "]", ".", "lower", "(", ")", "if", "scheme", "not", "in", "url_schemes", ":", "return", "False", "if", "not", "bool", "(", "url_regex", "....
Auxiliary method to validate an urllib :param url: An url to be validated :type url: string :returns: True if the url is valid :rtype: bool
[ "Auxiliary", "method", "to", "validate", "an", "urllib", ":", "param", "url", ":", "An", "url", "to", "be", "validated", ":", "type", "url", ":", "string", ":", "returns", ":", "True", "if", "the", "url", "is", "valid", ":", "rtype", ":", "bool" ]
python
train
Jaza/flask-restplus-patched
flask_restplus_patched/resource.py
https://github.com/Jaza/flask-restplus-patched/blob/38b4a030f28e6aec374d105173aa5e9b6bd51e5e/flask_restplus_patched/resource.py#L16-L30
def _apply_decorator_to_methods(cls, decorator): """ This helper can apply a given decorator to all methods on the current Resource. NOTE: In contrast to ``Resource.method_decorators``, which has a similar use-case, this method applies decorators directly and override me...
[ "def", "_apply_decorator_to_methods", "(", "cls", ",", "decorator", ")", ":", "for", "method", "in", "cls", ".", "methods", ":", "method_name", "=", "method", ".", "lower", "(", ")", "decorated_method_func", "=", "decorator", "(", "getattr", "(", "cls", ",",...
This helper can apply a given decorator to all methods on the current Resource. NOTE: In contrast to ``Resource.method_decorators``, which has a similar use-case, this method applies decorators directly and override methods in-place, while the decorators listed in ``Resource.met...
[ "This", "helper", "can", "apply", "a", "given", "decorator", "to", "all", "methods", "on", "the", "current", "Resource", "." ]
python
train
joshblum/beanstalk-dispatch
beanstalk_dispatch/safe_task.py
https://github.com/joshblum/beanstalk-dispatch/blob/1cc57e5496bb7114dba6de7c7988e5680d791603/beanstalk_dispatch/safe_task.py#L53-L73
def process(self, *args, **kwargs): """ args: list of arguments for the `runnable` kwargs: dictionary of arguments for the `runnable` """ try: timeout_seconds = self.timeout_timedelta.total_seconds() with timeout(self.run, timeout_seconds) as run: ...
[ "def", "process", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "timeout_seconds", "=", "self", ".", "timeout_timedelta", ".", "total_seconds", "(", ")", "with", "timeout", "(", "self", ".", "run", ",", "timeout_seconds", ...
args: list of arguments for the `runnable` kwargs: dictionary of arguments for the `runnable`
[ "args", ":", "list", "of", "arguments", "for", "the", "runnable", "kwargs", ":", "dictionary", "of", "arguments", "for", "the", "runnable" ]
python
train
mckib2/rawdatarinator
rawdatarinator/quickview.py
https://github.com/mckib2/rawdatarinator/blob/03a85fd8f5e380b424027d28e97972bd7a6a3f1b/rawdatarinator/quickview.py#L7-L53
def quickview(filename, noIFFT=False): ''' Display processed MRI data from `.hdf5`, `.npz`, or `.dat` files. No arguments displays the IFFT of the k-space data. The type of file is guessed by the file extension (i.e., if extension is `.dat` then readMeasData15 will be run to get the data). ...
[ "def", "quickview", "(", "filename", ",", "noIFFT", "=", "False", ")", ":", "if", "filename", ".", "endswith", "(", "'.npz'", ")", ":", "data", "=", "np", ".", "load", "(", "filename", ")", "elif", "filename", ".", "endswith", "(", "'.dat'", ")", ":"...
Display processed MRI data from `.hdf5`, `.npz`, or `.dat` files. No arguments displays the IFFT of the k-space data. The type of file is guessed by the file extension (i.e., if extension is `.dat` then readMeasData15 will be run to get the data). Command-line Options: -nifft (no IFFT) Displ...
[ "Display", "processed", "MRI", "data", "from", ".", "hdf5", ".", "npz", "or", ".", "dat", "files", ".", "No", "arguments", "displays", "the", "IFFT", "of", "the", "k", "-", "space", "data", ".", "The", "type", "of", "file", "is", "guessed", "by", "th...
python
train
googleapis/google-cloud-python
logging/google/cloud/logging/sink.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/logging/google/cloud/logging/sink.py#L182-L206
def update(self, client=None, unique_writer_identity=False): """API call: update sink configuration via a PUT request See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update :type client: :class:`~google.cloud.logging.client.Client` or ...
[ "def", "update", "(", "self", ",", "client", "=", "None", ",", "unique_writer_identity", "=", "False", ")", ":", "client", "=", "self", ".", "_require_client", "(", "client", ")", "resource", "=", "client", ".", "sinks_api", ".", "sink_update", "(", "self"...
API call: update sink configuration via a PUT request See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.sinks/update :type client: :class:`~google.cloud.logging.client.Client` or ``NoneType`` :param client: the client to use. If not passed,...
[ "API", "call", ":", "update", "sink", "configuration", "via", "a", "PUT", "request" ]
python
train
apple/turicreate
deps/src/cmake-3.13.4/Source/cmConvertMSBuildXMLToJSON.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/cmake-3.13.4/Source/cmConvertMSBuildXMLToJSON.py#L100-L168
def main(): """Script entrypoint.""" # Parse the arguments parser = argparse.ArgumentParser( description='Convert MSBuild XML to JSON format') parser.add_argument( '-t', '--toolchain', help='The name of the toolchain', required=True) parser.add_argument( '-o', '--output', he...
[ "def", "main", "(", ")", ":", "# Parse the arguments", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Convert MSBuild XML to JSON format'", ")", "parser", ".", "add_argument", "(", "'-t'", ",", "'--toolchain'", ",", "help", "=", "'The...
Script entrypoint.
[ "Script", "entrypoint", "." ]
python
train
abarker/pdfCropMargins
src/pdfCropMargins/main_pdfCropMargins.py
https://github.com/abarker/pdfCropMargins/blob/55aca874613750ebf4ae69fd8851bdbb7696d6ac/src/pdfCropMargins/main_pdfCropMargins.py#L148-L205
def get_full_page_box_assigning_media_and_crop(page): """This returns whatever PDF box was selected (by the user option '--fullPageBox') to represent the full page size. All cropping is done relative to this box. The default selection option is the MediaBox intersected with the CropBox so multiple cro...
[ "def", "get_full_page_box_assigning_media_and_crop", "(", "page", ")", ":", "# Find the page rotation angle (degrees).", "# Note rotation is clockwise, and four values are allowed: 0 90 180 270", "try", ":", "rotation", "=", "page", "[", "\"/Rotate\"", "]", ".", "getObject", "(",...
This returns whatever PDF box was selected (by the user option '--fullPageBox') to represent the full page size. All cropping is done relative to this box. The default selection option is the MediaBox intersected with the CropBox so multiple crops work as expected. The argument page should be a pyPdf...
[ "This", "returns", "whatever", "PDF", "box", "was", "selected", "(", "by", "the", "user", "option", "--", "fullPageBox", ")", "to", "represent", "the", "full", "page", "size", ".", "All", "cropping", "is", "done", "relative", "to", "this", "box", ".", "T...
python
train
twitterdev/twitter-python-ads-sdk
twitter_ads/client.py
https://github.com/twitterdev/twitter-python-ads-sdk/blob/b4488333ac2a794b85b7f16ded71e98b60e51c74/twitter_ads/client.py#L72-L80
def trace(): """Enables and disables request tracing.""" def fget(self): return self._options.get('trace', None) def fset(self, value): self._options['trace'] = value return locals()
[ "def", "trace", "(", ")", ":", "def", "fget", "(", "self", ")", ":", "return", "self", ".", "_options", ".", "get", "(", "'trace'", ",", "None", ")", "def", "fset", "(", "self", ",", "value", ")", ":", "self", ".", "_options", "[", "'trace'", "]"...
Enables and disables request tracing.
[ "Enables", "and", "disables", "request", "tracing", "." ]
python
train
maas/python-libmaas
maas/client/viscera/__init__.py
https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/viscera/__init__.py#L488-L518
def ManagedCreate(super_cls): """Dynamically creates a `create` method for a `ObjectSet.Managed` class that calls the `super_cls.create`. The first positional argument that is passed to the `super_cls.create` is the `_manager` that was set using `ObjectSet.Managed`. The created object is added to t...
[ "def", "ManagedCreate", "(", "super_cls", ")", ":", "@", "wraps", "(", "super_cls", ".", "create", ")", "async", "def", "_create", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cls", "=", "type", "(", "self", ")", "manager", "=...
Dynamically creates a `create` method for a `ObjectSet.Managed` class that calls the `super_cls.create`. The first positional argument that is passed to the `super_cls.create` is the `_manager` that was set using `ObjectSet.Managed`. The created object is added to the `ObjectSet.Managed` also placed in...
[ "Dynamically", "creates", "a", "create", "method", "for", "a", "ObjectSet", ".", "Managed", "class", "that", "calls", "the", "super_cls", ".", "create", "." ]
python
train
phaethon/kamene
kamene/crypto/cert.py
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L509-L570
def verify(self, M, S, t=None, h=None, mgf=None, sLen=None): """ Verify alleged signature 'S' is indeed the signature of message 'M' using 't' signature scheme where 't' can be: - None: the alleged signature 'S' is directly applied the RSAVP1 signature primitive, as desc...
[ "def", "verify", "(", "self", ",", "M", ",", "S", ",", "t", "=", "None", ",", "h", "=", "None", ",", "mgf", "=", "None", ",", "sLen", "=", "None", ")", ":", "if", "h", "is", "not", "None", ":", "h", "=", "mapHashFunc", "(", "h", ")", "if", ...
Verify alleged signature 'S' is indeed the signature of message 'M' using 't' signature scheme where 't' can be: - None: the alleged signature 'S' is directly applied the RSAVP1 signature primitive, as described in PKCS#1 v2.1, i.e. RFC 3447 Sect 5.2.1. Simply put, the p...
[ "Verify", "alleged", "signature", "S", "is", "indeed", "the", "signature", "of", "message", "M", "using", "t", "signature", "scheme", "where", "t", "can", "be", ":" ]
python
train
rkcosmos/deepcut
deepcut/deepcut.py
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/deepcut.py#L79-L91
def _check_stop_list(stop): """ Check stop words list ref: https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/feature_extraction/text.py#L87-L95 """ if stop == "thai": return THAI_STOP_WORDS elif isinstance(stop, six.string_types): raise ValueError("not a built-in s...
[ "def", "_check_stop_list", "(", "stop", ")", ":", "if", "stop", "==", "\"thai\"", ":", "return", "THAI_STOP_WORDS", "elif", "isinstance", "(", "stop", ",", "six", ".", "string_types", ")", ":", "raise", "ValueError", "(", "\"not a built-in stop list: %s\"", "%",...
Check stop words list ref: https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/feature_extraction/text.py#L87-L95
[ "Check", "stop", "words", "list", "ref", ":", "https", ":", "//", "github", ".", "com", "/", "scikit", "-", "learn", "/", "scikit", "-", "learn", "/", "blob", "/", "master", "/", "sklearn", "/", "feature_extraction", "/", "text", ".", "py#L87", "-", ...
python
valid
bitprophet/ssh
ssh/client.py
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/client.py#L179-L195
def save_host_keys(self, filename): """ Save the host keys back to a file. Only the host keys loaded with L{load_host_keys} (plus any added directly) will be saved -- not any host keys loaded with L{load_system_host_keys}. @param filename: the filename to save to @type ...
[ "def", "save_host_keys", "(", "self", ",", "filename", ")", ":", "f", "=", "open", "(", "filename", ",", "'w'", ")", "f", ".", "write", "(", "'# SSH host keys collected by ssh\\n'", ")", "for", "hostname", ",", "keys", "in", "self", ".", "_host_keys", ".",...
Save the host keys back to a file. Only the host keys loaded with L{load_host_keys} (plus any added directly) will be saved -- not any host keys loaded with L{load_system_host_keys}. @param filename: the filename to save to @type filename: str @raise IOError: if the file could...
[ "Save", "the", "host", "keys", "back", "to", "a", "file", ".", "Only", "the", "host", "keys", "loaded", "with", "L", "{", "load_host_keys", "}", "(", "plus", "any", "added", "directly", ")", "will", "be", "saved", "--", "not", "any", "host", "keys", ...
python
train
pycontribs/python-crowd
crowd.py
https://github.com/pycontribs/python-crowd/blob/a075e45774dd5baecf0217843cda747084268e32/crowd.py#L94-L106
def _post(self, *args, **kwargs): """Wrapper around Requests for POST requests Returns: Response: A Requests Response object """ if 'timeout' not in kwargs: kwargs['timeout'] = self.timeout req = self.session.post(*args, **kwargs) ...
[ "def", "_post", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "'timeout'", "not", "in", "kwargs", ":", "kwargs", "[", "'timeout'", "]", "=", "self", ".", "timeout", "req", "=", "self", ".", "session", ".", "post", "(", "...
Wrapper around Requests for POST requests Returns: Response: A Requests Response object
[ "Wrapper", "around", "Requests", "for", "POST", "requests" ]
python
train
za-creature/gulpless
gulpless/handlers.py
https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/handlers.py#L75-L126
def _build(self, src, path, dest, mtime): """Calls `build` after testing that at least one output file (as returned by `_outputs()` does not exist or is older than `mtime`. If the build fails, the build time is recorded and no other builds will be attempted on `input` until this method i...
[ "def", "_build", "(", "self", ",", "src", ",", "path", ",", "dest", ",", "mtime", ")", ":", "input_path", "=", "os", ".", "path", ".", "join", "(", "src", ",", "path", ")", "output_paths", "=", "[", "os", ".", "path", ".", "join", "(", "dest", ...
Calls `build` after testing that at least one output file (as returned by `_outputs()` does not exist or is older than `mtime`. If the build fails, the build time is recorded and no other builds will be attempted on `input` until this method is called with a larger mtime.
[ "Calls", "build", "after", "testing", "that", "at", "least", "one", "output", "file", "(", "as", "returned", "by", "_outputs", "()", "does", "not", "exist", "or", "is", "older", "than", "mtime", ".", "If", "the", "build", "fails", "the", "build", "time",...
python
train
cykl/infoqscraper
infoqscraper/convert.py
https://github.com/cykl/infoqscraper/blob/4fc026b994f98a0a7fe8578e0c9a3a9664982b2e/infoqscraper/convert.py#L92-L113
def download_video(self): """Downloads the video. If self.client.cache_enabled is True, then the disk cache is used. Returns: The path where the video has been saved. Raises: DownloadError: If the video cannot be downloaded. """ rvideo_path = se...
[ "def", "download_video", "(", "self", ")", ":", "rvideo_path", "=", "self", ".", "presentation", ".", "metadata", "[", "'video_path'", "]", "if", "self", ".", "presentation", ".", "client", ".", "cache", ":", "video_path", "=", "self", ".", "presentation", ...
Downloads the video. If self.client.cache_enabled is True, then the disk cache is used. Returns: The path where the video has been saved. Raises: DownloadError: If the video cannot be downloaded.
[ "Downloads", "the", "video", "." ]
python
train
NiklasRosenstein-Python/nr-deprecated
nr/stream.py
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/stream.py#L70-L85
def unique(cls, iterable, key=None): """ Yields unique items from *iterable* whilst preserving the original order. """ if key is None: key = lambda x: x def generator(): seen = set() seen_add = seen.add for item in iterable: key_val = key(item) if key_val not...
[ "def", "unique", "(", "cls", ",", "iterable", ",", "key", "=", "None", ")", ":", "if", "key", "is", "None", ":", "key", "=", "lambda", "x", ":", "x", "def", "generator", "(", ")", ":", "seen", "=", "set", "(", ")", "seen_add", "=", "seen", ".",...
Yields unique items from *iterable* whilst preserving the original order.
[ "Yields", "unique", "items", "from", "*", "iterable", "*", "whilst", "preserving", "the", "original", "order", "." ]
python
train
ahtn/python-easyhid
easyhid/easyhid.py
https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L112-L126
def open(self): """ Open the HID device for reading and writing. """ if self._is_open: raise HIDException("Failed to open device: HIDDevice already open") path = self.path.encode('utf-8') dev = hidapi.hid_open_path(path) if dev: self._is_...
[ "def", "open", "(", "self", ")", ":", "if", "self", ".", "_is_open", ":", "raise", "HIDException", "(", "\"Failed to open device: HIDDevice already open\"", ")", "path", "=", "self", ".", "path", ".", "encode", "(", "'utf-8'", ")", "dev", "=", "hidapi", ".",...
Open the HID device for reading and writing.
[ "Open", "the", "HID", "device", "for", "reading", "and", "writing", "." ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/window.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/window.py#L590-L604
def show(self, bAsync = True): """ Make the window visible. @see: L{hide} @type bAsync: bool @param bAsync: Perform the request asynchronously. @raise WindowsError: An error occured while processing this request. """ if bAsync: win32.ShowWi...
[ "def", "show", "(", "self", ",", "bAsync", "=", "True", ")", ":", "if", "bAsync", ":", "win32", ".", "ShowWindowAsync", "(", "self", ".", "get_handle", "(", ")", ",", "win32", ".", "SW_SHOW", ")", "else", ":", "win32", ".", "ShowWindow", "(", "self",...
Make the window visible. @see: L{hide} @type bAsync: bool @param bAsync: Perform the request asynchronously. @raise WindowsError: An error occured while processing this request.
[ "Make", "the", "window", "visible", "." ]
python
train
materialsproject/pymatgen
pymatgen/analysis/local_env.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/local_env.py#L1446-L1490
def get_nn_info(self, structure, n): """ Get all near-neighbor sites as well as the associated image locations and weights of the site with index n using the closest relative neighbor distance-based method with O'Keeffe parameters. Args: structure (Structure): input ...
[ "def", "get_nn_info", "(", "self", ",", "structure", ",", "n", ")", ":", "site", "=", "structure", "[", "n", "]", "neighs_dists", "=", "structure", ".", "get_neighbors", "(", "site", ",", "self", ".", "cutoff", ")", "try", ":", "eln", "=", "site", "....
Get all near-neighbor sites as well as the associated image locations and weights of the site with index n using the closest relative neighbor distance-based method with O'Keeffe parameters. Args: structure (Structure): input structure. n (integer): index of site for whi...
[ "Get", "all", "near", "-", "neighbor", "sites", "as", "well", "as", "the", "associated", "image", "locations", "and", "weights", "of", "the", "site", "with", "index", "n", "using", "the", "closest", "relative", "neighbor", "distance", "-", "based", "method",...
python
train
hobson/pug-dj
pug/dj/db.py
https://github.com/hobson/pug-dj/blob/55678b08755a55366ce18e7d3b8ea8fa4491ab04/pug/dj/db.py#L1638-L1670
def write_queryset_to_csv(qs, filename): """Write a QuerySet or ValuesListQuerySet to a CSV file based on djangosnippets by zbyte64 and http://palewi.re Arguments: qs (QuerySet or ValuesListQuerySet): The records your want to write to a text file (UTF-8) filename (str): full path and file ...
[ "def", "write_queryset_to_csv", "(", "qs", ",", "filename", ")", ":", "model", "=", "qs", ".", "model", "with", "open", "(", "filename", ",", "'w'", ")", "as", "fp", ":", "writer", "=", "csv", ".", "writer", "(", "fp", ")", "try", ":", "headers", "...
Write a QuerySet or ValuesListQuerySet to a CSV file based on djangosnippets by zbyte64 and http://palewi.re Arguments: qs (QuerySet or ValuesListQuerySet): The records your want to write to a text file (UTF-8) filename (str): full path and file name to write to
[ "Write", "a", "QuerySet", "or", "ValuesListQuerySet", "to", "a", "CSV", "file" ]
python
train
Azure/msrest-for-python
msrest/serialization.py
https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/serialization.py#L742-L759
def serialize_unicode(self, data): """Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. :param data: Object to be serialized. :rtype: str """ try: return data.value except AttributeError: ...
[ "def", "serialize_unicode", "(", "self", ",", "data", ")", ":", "try", ":", "return", "data", ".", "value", "except", "AttributeError", ":", "pass", "try", ":", "if", "isinstance", "(", "data", ",", "unicode", ")", ":", "return", "data", ".", "encode", ...
Special handling for serializing unicode strings in Py2. Encode to UTF-8 if unicode, otherwise handle as a str. :param data: Object to be serialized. :rtype: str
[ "Special", "handling", "for", "serializing", "unicode", "strings", "in", "Py2", ".", "Encode", "to", "UTF", "-", "8", "if", "unicode", "otherwise", "handle", "as", "a", "str", "." ]
python
train
wilfilho/BingTranslator
BingTranslator/__init__.py
https://github.com/wilfilho/BingTranslator/blob/6bada6fe1ac4177cc7dc62ff16dab561ba714534/BingTranslator/__init__.py#L35-L49
def _get_token(self): """ Get token for make request. The The data obtained herein are used in the variable header. Returns: To perform the request, receive in return a dictionary with several keys. With this method only return the tok...
[ "def", "_get_token", "(", "self", ")", ":", "informations", "=", "self", ".", "_set_format_oauth", "(", ")", "oauth_url", "=", "\"https://datamarket.accesscontrol.windows.net/v2/OAuth2-13\"", "token", "=", "requests", ".", "post", "(", "oauth_url", ",", "informations"...
Get token for make request. The The data obtained herein are used in the variable header. Returns: To perform the request, receive in return a dictionary with several keys. With this method only return the token as it will use it for subseq...
[ "Get", "token", "for", "make", "request", ".", "The", "The", "data", "obtained", "herein", "are", "used", "in", "the", "variable", "header", ".", "Returns", ":", "To", "perform", "the", "request", "receive", "in", "return", "a", "dictionary", "with", "seve...
python
train
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/tracker.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/tracker.py#L126-L134
def print_diff(self, summary1=None, summary2=None): """Compute diff between to summaries and print it. If no summary is provided, the diff from the last to the current summary is used. If summary1 is provided the diff from summary1 to the current summary is used. If summary1 and summary...
[ "def", "print_diff", "(", "self", ",", "summary1", "=", "None", ",", "summary2", "=", "None", ")", ":", "summary", ".", "print_", "(", "self", ".", "diff", "(", "summary1", "=", "summary1", ",", "summary2", "=", "summary2", ")", ")" ]
Compute diff between to summaries and print it. If no summary is provided, the diff from the last to the current summary is used. If summary1 is provided the diff from summary1 to the current summary is used. If summary1 and summary2 are provided, the diff between these two is used.
[ "Compute", "diff", "between", "to", "summaries", "and", "print", "it", "." ]
python
train
kakwa/ldapcherry
ldapcherry/backend/backendLdap.py
https://github.com/kakwa/ldapcherry/blob/b5e7cb6a44065abc30d164e72981b3713a172dda/ldapcherry/backend/backendLdap.py#L250-L306
def _search(self, searchfilter, attrs, basedn): """Generic search""" if attrs == NO_ATTR: attrlist = [] elif attrs == DISPLAYED_ATTRS: # fix me later (to much attributes) attrlist = self.attrlist elif attrs == LISTED_ATTRS: attrlist = self....
[ "def", "_search", "(", "self", ",", "searchfilter", ",", "attrs", ",", "basedn", ")", ":", "if", "attrs", "==", "NO_ATTR", ":", "attrlist", "=", "[", "]", "elif", "attrs", "==", "DISPLAYED_ATTRS", ":", "# fix me later (to much attributes)", "attrlist", "=", ...
Generic search
[ "Generic", "search" ]
python
train
kensho-technologies/graphql-compiler
graphql_compiler/query_formatting/representations.py
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/representations.py#L8-L29
def represent_float_as_str(value): """Represent a float as a string without losing precision.""" # In Python 2, calling str() on a float object loses precision: # # In [1]: 1.23456789012345678 # Out[1]: 1.2345678901234567 # # In [2]: 1.2345678901234567 # Out[2]: 1.2345678901234567 # ...
[ "def", "represent_float_as_str", "(", "value", ")", ":", "# In Python 2, calling str() on a float object loses precision:", "#", "# In [1]: 1.23456789012345678", "# Out[1]: 1.2345678901234567", "#", "# In [2]: 1.2345678901234567", "# Out[2]: 1.2345678901234567", "#", "# In [3]: str(1.234...
Represent a float as a string without losing precision.
[ "Represent", "a", "float", "as", "a", "string", "without", "losing", "precision", "." ]
python
train
kennethreitz/flask-sslify
flask_sslify.py
https://github.com/kennethreitz/flask-sslify/blob/425a1deb4a1a8f693319f4b97134196e0235848c/flask_sslify.py#L52-L59
def hsts_header(self): """Returns the proper HSTS policy.""" hsts_policy = 'max-age={0}'.format(self.hsts_age) if self.hsts_include_subdomains: hsts_policy += '; includeSubDomains' return hsts_policy
[ "def", "hsts_header", "(", "self", ")", ":", "hsts_policy", "=", "'max-age={0}'", ".", "format", "(", "self", ".", "hsts_age", ")", "if", "self", ".", "hsts_include_subdomains", ":", "hsts_policy", "+=", "'; includeSubDomains'", "return", "hsts_policy" ]
Returns the proper HSTS policy.
[ "Returns", "the", "proper", "HSTS", "policy", "." ]
python
train
asweigart/pyautogui
pyautogui/__init__.py
https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/__init__.py#L955-L975
def keyDown(key, pause=None, _pause=True): """Performs a keyboard key press without the release. This will put that key in a held down state. NOTE: For some reason, this does not seem to cause key repeats like would happen if a keyboard key was held down on a text field. Args: key (str): The...
[ "def", "keyDown", "(", "key", ",", "pause", "=", "None", ",", "_pause", "=", "True", ")", ":", "if", "len", "(", "key", ")", ">", "1", ":", "key", "=", "key", ".", "lower", "(", ")", "_failSafeCheck", "(", ")", "platformModule", ".", "_keyDown", ...
Performs a keyboard key press without the release. This will put that key in a held down state. NOTE: For some reason, this does not seem to cause key repeats like would happen if a keyboard key was held down on a text field. Args: key (str): The key to be pressed down. The valid names are liste...
[ "Performs", "a", "keyboard", "key", "press", "without", "the", "release", ".", "This", "will", "put", "that", "key", "in", "a", "held", "down", "state", "." ]
python
train
ethereum/py-evm
eth/vm/base.py
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L918-L924
def validate_seal(cls, header: BlockHeader) -> None: """ Validate the seal on the given header. """ check_pow( header.block_number, header.mining_hash, header.mix_hash, header.nonce, header.difficulty)
[ "def", "validate_seal", "(", "cls", ",", "header", ":", "BlockHeader", ")", "->", "None", ":", "check_pow", "(", "header", ".", "block_number", ",", "header", ".", "mining_hash", ",", "header", ".", "mix_hash", ",", "header", ".", "nonce", ",", "header", ...
Validate the seal on the given header.
[ "Validate", "the", "seal", "on", "the", "given", "header", "." ]
python
train
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/simple_jwt.py
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/simple_jwt.py#L87-L106
def payload(self): """ Picks out the payload from the different parts of the signed/encrypted JSON Web Token. If the content type is said to be 'jwt' deserialize the payload into a Python object otherwise return as-is. :return: The payload """ _msg = as_unicode(s...
[ "def", "payload", "(", "self", ")", ":", "_msg", "=", "as_unicode", "(", "self", ".", "part", "[", "1", "]", ")", "# If not JSON web token assume JSON", "if", "\"cty\"", "in", "self", ".", "headers", "and", "self", ".", "headers", "[", "\"cty\"", "]", "....
Picks out the payload from the different parts of the signed/encrypted JSON Web Token. If the content type is said to be 'jwt' deserialize the payload into a Python object otherwise return as-is. :return: The payload
[ "Picks", "out", "the", "payload", "from", "the", "different", "parts", "of", "the", "signed", "/", "encrypted", "JSON", "Web", "Token", ".", "If", "the", "content", "type", "is", "said", "to", "be", "jwt", "deserialize", "the", "payload", "into", "a", "P...
python
train
SuryaSankar/flask-sqlalchemy-booster
flask_sqlalchemy_booster/model_booster/queryable_mixin.py
https://github.com/SuryaSankar/flask-sqlalchemy-booster/blob/444048d167ab7718f758e943665ef32d101423a5/flask_sqlalchemy_booster/model_booster/queryable_mixin.py#L497-L537
def get_all(cls, keyvals, key='id', user_id=None): """Works like a map function from keyvals to instances. Args: keyvals(list): The list of values of the attribute. key (str, optional): The attribute to search by. By default, it is 'id'. Returns: ...
[ "def", "get_all", "(", "cls", ",", "keyvals", ",", "key", "=", "'id'", ",", "user_id", "=", "None", ")", ":", "if", "len", "(", "keyvals", ")", "==", "0", ":", "return", "[", "]", "original_keyvals", "=", "keyvals", "keyvals_set", "=", "list", "(", ...
Works like a map function from keyvals to instances. Args: keyvals(list): The list of values of the attribute. key (str, optional): The attribute to search by. By default, it is 'id'. Returns: list: A list of model instances, in the same order ...
[ "Works", "like", "a", "map", "function", "from", "keyvals", "to", "instances", "." ]
python
train
MaxHalford/starboost
starboost/boosting.py
https://github.com/MaxHalford/starboost/blob/59d96dcc983404cbc326878facd8171fd2655ce1/starboost/boosting.py#L343-L367
def iter_predict_proba(self, X, include_init=False): """Returns the predicted probabilities for ``X`` at every stage of the boosting procedure. Arguments: X (array-like or sparse matrix of shape (n_samples, n_features)): The input samples. Sparse matrices are accepted only i...
[ "def", "iter_predict_proba", "(", "self", ",", "X", ",", "include_init", "=", "False", ")", ":", "utils", ".", "validation", ".", "check_is_fitted", "(", "self", ",", "'init_estimator_'", ")", "X", "=", "utils", ".", "check_array", "(", "X", ",", "accept_s...
Returns the predicted probabilities for ``X`` at every stage of the boosting procedure. Arguments: X (array-like or sparse matrix of shape (n_samples, n_features)): The input samples. Sparse matrices are accepted only if they are supported by the weak model. include_init...
[ "Returns", "the", "predicted", "probabilities", "for", "X", "at", "every", "stage", "of", "the", "boosting", "procedure", "." ]
python
train
biolink/ontobio
ontobio/io/ontol_renderers.py
https://github.com/biolink/ontobio/blob/4e512a7831cfe6bc1b32f2c3be2ba41bc5cf7345/ontobio/io/ontol_renderers.py#L70-L75
def write_subgraph(self, ontol, nodes, **args): """ Write a `ontology` object after inducing a subgraph """ subont = ontol.subontology(nodes, **args) self.write(subont, **args)
[ "def", "write_subgraph", "(", "self", ",", "ontol", ",", "nodes", ",", "*", "*", "args", ")", ":", "subont", "=", "ontol", ".", "subontology", "(", "nodes", ",", "*", "*", "args", ")", "self", ".", "write", "(", "subont", ",", "*", "*", "args", "...
Write a `ontology` object after inducing a subgraph
[ "Write", "a", "ontology", "object", "after", "inducing", "a", "subgraph" ]
python
train
saltstack/salt
salt/states/marathon_app.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/marathon_app.py#L122-L157
def running(name, restart=False, force=True): ''' Ensure that the marathon app with the given id is present and restart if set. :param name: The app name/id :param restart: Restart the app :param force: Override the current deployment :return: A standard Salt changes dictionary ''' ret ...
[ "def", "running", "(", "name", ",", "restart", "=", "False", ",", "force", "=", "True", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "False", ",", "'comment'", ":", "''", "}", "if", "not...
Ensure that the marathon app with the given id is present and restart if set. :param name: The app name/id :param restart: Restart the app :param force: Override the current deployment :return: A standard Salt changes dictionary
[ "Ensure", "that", "the", "marathon", "app", "with", "the", "given", "id", "is", "present", "and", "restart", "if", "set", "." ]
python
train
grahambell/pymoc
lib/pymoc/util/tool.py
https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/util/tool.py#L136-L206
def catalog(self): """Create MOC from catalog of coordinates. This command requires that the Healpy and Astropy libraries be available. It attempts to load the given catalog, and merges it with the running MOC. The name of an ASCII catalog file should be given. The file ...
[ "def", "catalog", "(", "self", ")", ":", "from", ".", "catalog", "import", "catalog_to_moc", ",", "read_ascii_catalog", "filename", "=", "self", ".", "params", ".", "pop", "(", ")", "order", "=", "12", "radius", "=", "3600", "unit", "=", "None", "format_...
Create MOC from catalog of coordinates. This command requires that the Healpy and Astropy libraries be available. It attempts to load the given catalog, and merges it with the running MOC. The name of an ASCII catalog file should be given. The file should contain either "RA" ...
[ "Create", "MOC", "from", "catalog", "of", "coordinates", "." ]
python
train
sods/paramz
paramz/core/indexable.py
https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L150-L162
def _raveled_index_for(self, param): """ get the raveled index for a param that is an int array, containing the indexes for the flattened param inside this parameterized logic. !Warning! be sure to call this method on the highest parent of a hierarchy, as it uses the fix...
[ "def", "_raveled_index_for", "(", "self", ",", "param", ")", ":", "from", ".", ".", "param", "import", "ParamConcatenation", "if", "isinstance", "(", "param", ",", "ParamConcatenation", ")", ":", "return", "np", ".", "hstack", "(", "(", "self", ".", "_rave...
get the raveled index for a param that is an int array, containing the indexes for the flattened param inside this parameterized logic. !Warning! be sure to call this method on the highest parent of a hierarchy, as it uses the fixes to do its work
[ "get", "the", "raveled", "index", "for", "a", "param", "that", "is", "an", "int", "array", "containing", "the", "indexes", "for", "the", "flattened", "param", "inside", "this", "parameterized", "logic", "." ]
python
train
rwl/pylon
pylon/opf.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L782-L818
def linear_constraints(self): """ Returns the linear constraints. """ if self.lin_N == 0: return None, array([]), array([]) A = lil_matrix((self.lin_N, self.var_N), dtype=float64) l = -Inf * ones(self.lin_N) u = -l for lin in self.lin_constraints: ...
[ "def", "linear_constraints", "(", "self", ")", ":", "if", "self", ".", "lin_N", "==", "0", ":", "return", "None", ",", "array", "(", "[", "]", ")", ",", "array", "(", "[", "]", ")", "A", "=", "lil_matrix", "(", "(", "self", ".", "lin_N", ",", "...
Returns the linear constraints.
[ "Returns", "the", "linear", "constraints", "." ]
python
train
CalebBell/thermo
thermo/electrochem.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/electrochem.py#L190-L235
def Laliberte_viscosity(T, ws, CASRNs): r'''Calculate the viscosity of an aqueous mixture using the form proposed by [1]_. Parameters are loaded by the function as needed. Units are Kelvin and Pa*s. .. math:: \mu_m = \mu_w^{w_w} \Pi\mu_i^{w_i} Parameters ---------- T : float Te...
[ "def", "Laliberte_viscosity", "(", "T", ",", "ws", ",", "CASRNs", ")", ":", "mu_w", "=", "Laliberte_viscosity_w", "(", "T", ")", "*", "1000.", "w_w", "=", "1", "-", "sum", "(", "ws", ")", "mu", "=", "mu_w", "**", "(", "w_w", ")", "for", "i", "in"...
r'''Calculate the viscosity of an aqueous mixture using the form proposed by [1]_. Parameters are loaded by the function as needed. Units are Kelvin and Pa*s. .. math:: \mu_m = \mu_w^{w_w} \Pi\mu_i^{w_i} Parameters ---------- T : float Temperature of fluid [K] ws : array ...
[ "r", "Calculate", "the", "viscosity", "of", "an", "aqueous", "mixture", "using", "the", "form", "proposed", "by", "[", "1", "]", "_", ".", "Parameters", "are", "loaded", "by", "the", "function", "as", "needed", ".", "Units", "are", "Kelvin", "and", "Pa",...
python
valid
jtwhite79/pyemu
pyemu/utils/gw_utils.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/utils/gw_utils.py#L462-L538
def setup_mflist_budget_obs(list_filename,flx_filename="flux.dat", vol_filename="vol.dat",start_datetime="1-1'1970",prefix='', save_setup_file=False): """ setup observations of budget volume and flux from modflow list file. writes an instruction file and ...
[ "def", "setup_mflist_budget_obs", "(", "list_filename", ",", "flx_filename", "=", "\"flux.dat\"", ",", "vol_filename", "=", "\"vol.dat\"", ",", "start_datetime", "=", "\"1-1'1970\"", ",", "prefix", "=", "''", ",", "save_setup_file", "=", "False", ")", ":", "flx", ...
setup observations of budget volume and flux from modflow list file. writes an instruction file and also a _setup_.csv to use when constructing a pest control file Parameters ---------- list_filename : str modflow list file flx_filename : str output filename that will conta...
[ "setup", "observations", "of", "budget", "volume", "and", "flux", "from", "modflow", "list", "file", ".", "writes", "an", "instruction", "file", "and", "also", "a", "_setup_", ".", "csv", "to", "use", "when", "constructing", "a", "pest", "control", "file" ]
python
train
QualiSystems/vCenterShell
package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py
https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py#L413-L491
def clone_vm(self, clone_params, logger, cancellation_context): """ Clone a VM from a template/VM and return the vm oject or throws argument is not valid :param cancellation_context: :param clone_params: CloneVmParameters = :param logger: """ result = self.CloneV...
[ "def", "clone_vm", "(", "self", ",", "clone_params", ",", "logger", ",", "cancellation_context", ")", ":", "result", "=", "self", ".", "CloneVmResult", "(", ")", "if", "not", "isinstance", "(", "clone_params", ".", "si", ",", "self", ".", "vim", ".", "Se...
Clone a VM from a template/VM and return the vm oject or throws argument is not valid :param cancellation_context: :param clone_params: CloneVmParameters = :param logger:
[ "Clone", "a", "VM", "from", "a", "template", "/", "VM", "and", "return", "the", "vm", "oject", "or", "throws", "argument", "is", "not", "valid" ]
python
train
cokelaer/spectrum
src/spectrum/covar.py
https://github.com/cokelaer/spectrum/blob/bad6c32e3f10e185098748f67bb421b378b06afe/src/spectrum/covar.py#L260-L328
def arcovar(x, order): r"""Simple and fast implementation of the covariance AR estimate This code is 10 times faster than :func:`arcovar_marple` and more importantly only 10 lines of code, compared to a 200 loc for :func:`arcovar_marple` :param array X: Array of complex data samples :param int o...
[ "def", "arcovar", "(", "x", ",", "order", ")", ":", "from", "spectrum", "import", "corrmtx", "import", "scipy", ".", "linalg", "X", "=", "corrmtx", "(", "x", ",", "order", ",", "'covariance'", ")", "Xc", "=", "np", ".", "matrix", "(", "X", "[", ":"...
r"""Simple and fast implementation of the covariance AR estimate This code is 10 times faster than :func:`arcovar_marple` and more importantly only 10 lines of code, compared to a 200 loc for :func:`arcovar_marple` :param array X: Array of complex data samples :param int oder: Order of linear predic...
[ "r", "Simple", "and", "fast", "implementation", "of", "the", "covariance", "AR", "estimate" ]
python
valid
lltk/lltk
lltk/scrapers/verbix.py
https://github.com/lltk/lltk/blob/d171de55c1b97695fddedf4b02401ae27bf1d634/lltk/scrapers/verbix.py#L22-L27
def _normalize(self, string): ''' Returns a sanitized string. ''' string = string.replace(u'\xa0', '') string = string.strip() return string
[ "def", "_normalize", "(", "self", ",", "string", ")", ":", "string", "=", "string", ".", "replace", "(", "u'\\xa0'", ",", "''", ")", "string", "=", "string", ".", "strip", "(", ")", "return", "string" ]
Returns a sanitized string.
[ "Returns", "a", "sanitized", "string", "." ]
python
train
ChargePoint/pydnp3
examples/master_cmd.py
https://github.com/ChargePoint/pydnp3/blob/5bcd8240d1fc0aa1579e71f2efcab63b4c61c547/examples/master_cmd.py#L150-L152
def do_scan_range(self, line): """Do an ad-hoc scan of a range of points (group 1, variation 2, indexes 0-3). Command syntax is: scan_range""" self.application.master.ScanRange(opendnp3.GroupVariationID(1, 2), 0, 3, opendnp3.TaskConfig().Default())
[ "def", "do_scan_range", "(", "self", ",", "line", ")", ":", "self", ".", "application", ".", "master", ".", "ScanRange", "(", "opendnp3", ".", "GroupVariationID", "(", "1", ",", "2", ")", ",", "0", ",", "3", ",", "opendnp3", ".", "TaskConfig", "(", "...
Do an ad-hoc scan of a range of points (group 1, variation 2, indexes 0-3). Command syntax is: scan_range
[ "Do", "an", "ad", "-", "hoc", "scan", "of", "a", "range", "of", "points", "(", "group", "1", "variation", "2", "indexes", "0", "-", "3", ")", ".", "Command", "syntax", "is", ":", "scan_range" ]
python
valid
sorgerlab/indra
indra/assemblers/pybel/assembler.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/pybel/assembler.py#L320-L344
def _assemble_conversion(self, stmt): """Example: p(HGNC:HK1) => rxn(reactants(a(CHEBI:"CHEBI:17634")), products(a(CHEBI:"CHEBI:4170")))""" pybel_lists = ([], []) for pybel_list, agent_list in \ zip(pybel_lists, (stmt.obj_from, s...
[ "def", "_assemble_conversion", "(", "self", ",", "stmt", ")", ":", "pybel_lists", "=", "(", "[", "]", ",", "[", "]", ")", "for", "pybel_list", ",", "agent_list", "in", "zip", "(", "pybel_lists", ",", "(", "stmt", ".", "obj_from", ",", "stmt", ".", "o...
Example: p(HGNC:HK1) => rxn(reactants(a(CHEBI:"CHEBI:17634")), products(a(CHEBI:"CHEBI:4170")))
[ "Example", ":", "p", "(", "HGNC", ":", "HK1", ")", "=", ">", "rxn", "(", "reactants", "(", "a", "(", "CHEBI", ":", "CHEBI", ":", "17634", "))", "products", "(", "a", "(", "CHEBI", ":", "CHEBI", ":", "4170", ")))" ]
python
train
aetros/aetros-cli
aetros/git.py
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/git.py#L941-L955
def commit_index(self, message): """ Commit the current index. :param message: str :return: str the generated commit sha """ tree_id = self.write_tree() args = ['commit-tree', tree_id, '-p', self.ref_head] # todo, this can end in a race-condition with ot...
[ "def", "commit_index", "(", "self", ",", "message", ")", ":", "tree_id", "=", "self", ".", "write_tree", "(", ")", "args", "=", "[", "'commit-tree'", ",", "tree_id", ",", "'-p'", ",", "self", ".", "ref_head", "]", "# todo, this can end in a race-condition with...
Commit the current index. :param message: str :return: str the generated commit sha
[ "Commit", "the", "current", "index", ".", ":", "param", "message", ":", "str", ":", "return", ":", "str", "the", "generated", "commit", "sha" ]
python
train
mseclab/PyJFuzz
pyjfuzz/core/pjf_mutators.py
https://github.com/mseclab/PyJFuzz/blob/f777067076f62c9ab74ffea6e90fd54402b7a1b4/pyjfuzz/core/pjf_mutators.py#L127-L131
def _get_random(self, obj_type): """ Get a random mutator from a list of mutators """ return self.mutator[obj_type][random.randint(0, self.config.level)]
[ "def", "_get_random", "(", "self", ",", "obj_type", ")", ":", "return", "self", ".", "mutator", "[", "obj_type", "]", "[", "random", ".", "randint", "(", "0", ",", "self", ".", "config", ".", "level", ")", "]" ]
Get a random mutator from a list of mutators
[ "Get", "a", "random", "mutator", "from", "a", "list", "of", "mutators" ]
python
test
MisterY/price-database
pricedb/csv.py
https://github.com/MisterY/price-database/blob/b4fd366b7763891c690fe3000b8840e656da023e/pricedb/csv.py#L50-L75
def parse_line(self, line: str) -> PriceModel: """ Parse a CSV line into a price element """ line = line.rstrip() parts = line.split(',') result = PriceModel() # symbol result.symbol = self.translate_symbol(parts[0]) # value result.value = Decimal(parts...
[ "def", "parse_line", "(", "self", ",", "line", ":", "str", ")", "->", "PriceModel", ":", "line", "=", "line", ".", "rstrip", "(", ")", "parts", "=", "line", ".", "split", "(", "','", ")", "result", "=", "PriceModel", "(", ")", "# symbol", "result", ...
Parse a CSV line into a price element
[ "Parse", "a", "CSV", "line", "into", "a", "price", "element" ]
python
test
Rockhopper-Technologies/pluginlib
pluginlib/_objects.py
https://github.com/Rockhopper-Technologies/pluginlib/blob/8beb78984dd9c97c493642df9da9f1b5a1c5e2b2/pluginlib/_objects.py#L119-L165
def _filter(self, blacklist=None, newest_only=False, type_filter=None, **kwargs): """ Args: blacklist(tuple): Iterable of of BlacklistEntry objects newest_only(bool): Only the newest version of each plugin is returned type(str): Plugin type to retrieve nam...
[ "def", "_filter", "(", "self", ",", "blacklist", "=", "None", ",", "newest_only", "=", "False", ",", "type_filter", "=", "None", ",", "*", "*", "kwargs", ")", ":", "plugins", "=", "DictWithDotNotation", "(", ")", "filtered_name", "=", "kwargs", ".", "get...
Args: blacklist(tuple): Iterable of of BlacklistEntry objects newest_only(bool): Only the newest version of each plugin is returned type(str): Plugin type to retrieve name(str): Plugin name to retrieve version(str): Plugin version to retrieve Returns ...
[ "Args", ":", "blacklist", "(", "tuple", ")", ":", "Iterable", "of", "of", "BlacklistEntry", "objects", "newest_only", "(", "bool", ")", ":", "Only", "the", "newest", "version", "of", "each", "plugin", "is", "returned", "type", "(", "str", ")", ":", "Plug...
python
train
Min-ops/cruddy
cruddy/lambdaclient.py
https://github.com/Min-ops/cruddy/blob/b9ba3dda1757e1075bc1c62a6f43473eea27de41/cruddy/lambdaclient.py#L62-L68
def call_operation(self, operation, **kwargs): """ A generic method to call any operation supported by the Lambda handler """ data = {'operation': operation} data.update(kwargs) return self.invoke(data)
[ "def", "call_operation", "(", "self", ",", "operation", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'operation'", ":", "operation", "}", "data", ".", "update", "(", "kwargs", ")", "return", "self", ".", "invoke", "(", "data", ")" ]
A generic method to call any operation supported by the Lambda handler
[ "A", "generic", "method", "to", "call", "any", "operation", "supported", "by", "the", "Lambda", "handler" ]
python
train
jgillick/LendingClub
lendingclub/__init__.py
https://github.com/jgillick/LendingClub/blob/4495f99fd869810f39c00e02b0f4112c6b210384/lendingclub/__init__.py#L712-L808
def search_my_notes(self, loan_id=None, order_id=None, grade=None, portfolio_name=None, status=None, term=None): """ Search for notes you are invested in. Use the parameters to define how to search. Passing no parameters is the same as calling `my_notes(get_all=True)` Parameters ...
[ "def", "search_my_notes", "(", "self", ",", "loan_id", "=", "None", ",", "order_id", "=", "None", ",", "grade", "=", "None", ",", "portfolio_name", "=", "None", ",", "status", "=", "None", ",", "term", "=", "None", ")", ":", "assert", "grade", "is", ...
Search for notes you are invested in. Use the parameters to define how to search. Passing no parameters is the same as calling `my_notes(get_all=True)` Parameters ---------- loan_id : int, optional Search for notes for a specific loan. Since a loan is broken up into a pool o...
[ "Search", "for", "notes", "you", "are", "invested", "in", ".", "Use", "the", "parameters", "to", "define", "how", "to", "search", ".", "Passing", "no", "parameters", "is", "the", "same", "as", "calling", "my_notes", "(", "get_all", "=", "True", ")" ]
python
train
SylvanasSun/python-common-cache
common_cache/__init__.py
https://github.com/SylvanasSun/python-common-cache/blob/f113eb3cd751eed5ab5373e8610a31a444220cf8/common_cache/__init__.py#L355-L371
def replace_evict_func(self, func, only_read=False): """ >>> cache = Cache(log_level=logging.WARNING) >>> def evict(dict, evict_number=10): pass >>> cache.replace_evict_func(evict) True >>> def evict_b(dict): pass >>> cache.replace_evict_func(evict_b) Fals...
[ "def", "replace_evict_func", "(", "self", ",", "func", ",", "only_read", "=", "False", ")", ":", "self", ".", "logger", ".", "info", "(", "'Replace the evict function %s ---> %s'", "%", "(", "get_function_signature", "(", "self", ".", "evict_func", ")", ",", "...
>>> cache = Cache(log_level=logging.WARNING) >>> def evict(dict, evict_number=10): pass >>> cache.replace_evict_func(evict) True >>> def evict_b(dict): pass >>> cache.replace_evict_func(evict_b) False >>> def evict_c(dict, a, b): pass >>> cache.replace_evi...
[ ">>>", "cache", "=", "Cache", "(", "log_level", "=", "logging", ".", "WARNING", ")", ">>>", "def", "evict", "(", "dict", "evict_number", "=", "10", ")", ":", "pass", ">>>", "cache", ".", "replace_evict_func", "(", "evict", ")", "True", ">>>", "def", "e...
python
train
nbedi/typecaster
typecaster/utils.py
https://github.com/nbedi/typecaster/blob/09eee6d4fbad9f70c90364ea89ab39917f903afc/typecaster/utils.py#L11-L53
def text_to_speech(text, synthesizer, synth_args, sentence_break): """ Converts given text to a pydub AudioSegment using a specified speech synthesizer. At the moment, IBM Watson's text-to-speech API is the only available synthesizer. :param text: The text that will be synthesized to audio....
[ "def", "text_to_speech", "(", "text", ",", "synthesizer", ",", "synth_args", ",", "sentence_break", ")", ":", "if", "len", "(", "text", ".", "split", "(", ")", ")", "<", "50", ":", "if", "synthesizer", "==", "'watson'", ":", "with", "open", "(", "'.tem...
Converts given text to a pydub AudioSegment using a specified speech synthesizer. At the moment, IBM Watson's text-to-speech API is the only available synthesizer. :param text: The text that will be synthesized to audio. :param synthesizer: The text-to-speech synthesizer to use. At the...
[ "Converts", "given", "text", "to", "a", "pydub", "AudioSegment", "using", "a", "specified", "speech", "synthesizer", ".", "At", "the", "moment", "IBM", "Watson", "s", "text", "-", "to", "-", "speech", "API", "is", "the", "only", "available", "synthesizer", ...
python
train
bitesofcode/projexui
projexui/xcommands.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/xcommands.py#L567-L579
def stylize(obj, style='plastique', theme='projexui'): """ Styles the inputed object with the given options. :param obj | <QtGui.QWidget> || <QtGui.QApplication> style | <str> base | <str> """ obj.setStyle(style) if theme: shee...
[ "def", "stylize", "(", "obj", ",", "style", "=", "'plastique'", ",", "theme", "=", "'projexui'", ")", ":", "obj", ".", "setStyle", "(", "style", ")", "if", "theme", ":", "sheet", "=", "resources", ".", "read", "(", "'styles/{0}/style.css'", ".", "format"...
Styles the inputed object with the given options. :param obj | <QtGui.QWidget> || <QtGui.QApplication> style | <str> base | <str>
[ "Styles", "the", "inputed", "object", "with", "the", "given", "options", ".", ":", "param", "obj", "|", "<QtGui", ".", "QWidget", ">", "||", "<QtGui", ".", "QApplication", ">", "style", "|", "<str", ">", "base", "|", "<str", ">" ]
python
train
googleapis/oauth2client
oauth2client/contrib/flask_util.py
https://github.com/googleapis/oauth2client/blob/50d20532a748f18e53f7d24ccbe6647132c979a9/oauth2client/contrib/flask_util.py#L456-L469
def email(self): """Returns the user's email address or None if there are no credentials. The email address is provided by the current credentials' id_token. This should not be used as unique identifier as the user can change their email. If you need a unique identifier, use user_id. ...
[ "def", "email", "(", "self", ")", ":", "if", "not", "self", ".", "credentials", ":", "return", "None", "try", ":", "return", "self", ".", "credentials", ".", "id_token", "[", "'email'", "]", "except", "KeyError", ":", "current_app", ".", "logger", ".", ...
Returns the user's email address or None if there are no credentials. The email address is provided by the current credentials' id_token. This should not be used as unique identifier as the user can change their email. If you need a unique identifier, use user_id.
[ "Returns", "the", "user", "s", "email", "address", "or", "None", "if", "there", "are", "no", "credentials", "." ]
python
valid