repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
inveniosoftware-contrib/json-merger
json_merger/conflict.py
https://github.com/inveniosoftware-contrib/json-merger/blob/adc6d372da018427e1db7b92424d3471e01a4118/json_merger/conflict.py#L99-L139
def to_json(self): """Deserializes conflict to a JSON object. It returns list of: `json-patch <https://tools.ietf.org/html/rfc6902>`_ format. - REORDER, SET_FIELD become "op": "replace" - MANUAL_MERGE, ADD_BACK_TO_HEAD become "op": "add" - Path becomes `json-pointer...
[ "def", "to_json", "(", "self", ")", ":", "# map ConflictType to json-patch operator", "path", "=", "self", ".", "path", "if", "self", ".", "conflict_type", "in", "(", "'REORDER'", ",", "'SET_FIELD'", ")", ":", "op", "=", "'replace'", "elif", "self", ".", "co...
Deserializes conflict to a JSON object. It returns list of: `json-patch <https://tools.ietf.org/html/rfc6902>`_ format. - REORDER, SET_FIELD become "op": "replace" - MANUAL_MERGE, ADD_BACK_TO_HEAD become "op": "add" - Path becomes `json-pointer <https://tools.ietf.org/html/...
[ "Deserializes", "conflict", "to", "a", "JSON", "object", "." ]
python
train
35.146341
bluec0re/android-backup-tools
android_backup/android_backup.py
https://github.com/bluec0re/android-backup-tools/blob/e2e0d95e56624c1a99a176df9e307398e837d908/android_backup/android_backup.py#L320-L333
def _decompress(self, fp): """ Internal function for decompressing a backup file with the DEFLATE algorithm :rtype: Proxy """ decompressor = zlib.decompressobj() if self.stream: return Proxy(decompressor.decompress, fp) else: out = io.Byte...
[ "def", "_decompress", "(", "self", ",", "fp", ")", ":", "decompressor", "=", "zlib", ".", "decompressobj", "(", ")", "if", "self", ".", "stream", ":", "return", "Proxy", "(", "decompressor", ".", "decompress", ",", "fp", ")", "else", ":", "out", "=", ...
Internal function for decompressing a backup file with the DEFLATE algorithm :rtype: Proxy
[ "Internal", "function", "for", "decompressing", "a", "backup", "file", "with", "the", "DEFLATE", "algorithm" ]
python
train
31.214286
pyqt/python-qt5
util.py
https://github.com/pyqt/python-qt5/blob/c9ed180c56f6fd3521ffe5fb70904bc5d3f50e5f/util.py#L5-L24
def createqtconf(): """Create a qt.conf file next to the current executable""" template = """[Paths] Prefix = {path} Binaries = {path} """ import PyQt5 exedir = os.path.dirname(sys.executable) qtpath = os.path.join(exedir, "qt.conf") pyqt5path = os.path.abspath(PyQt5.__file__) binpath = o...
[ "def", "createqtconf", "(", ")", ":", "template", "=", "\"\"\"[Paths]\nPrefix = {path}\nBinaries = {path}\n\"\"\"", "import", "PyQt5", "exedir", "=", "os", ".", "path", ".", "dirname", "(", "sys", ".", "executable", ")", "qtpath", "=", "os", ".", "path", ".", ...
Create a qt.conf file next to the current executable
[ "Create", "a", "qt", ".", "conf", "file", "next", "to", "the", "current", "executable" ]
python
train
23.4
delph-in/pydelphin
delphin/mrs/compare.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/compare.py#L458-L492
def compare_bags(testbag, goldbag, count_only=True): """ Compare two bags of Xmrs objects, returning a triple of (unique in test, shared, unique in gold). Args: testbag: An iterable of Xmrs objects to test. goldbag: An iterable of Xmrs objects to compare against. count_only: If ...
[ "def", "compare_bags", "(", "testbag", ",", "goldbag", ",", "count_only", "=", "True", ")", ":", "gold_remaining", "=", "list", "(", "goldbag", ")", "test_unique", "=", "[", "]", "shared", "=", "[", "]", "for", "test", "in", "testbag", ":", "gold_match",...
Compare two bags of Xmrs objects, returning a triple of (unique in test, shared, unique in gold). Args: testbag: An iterable of Xmrs objects to test. goldbag: An iterable of Xmrs objects to compare against. count_only: If True, the returned triple will only have the counts o...
[ "Compare", "two", "bags", "of", "Xmrs", "objects", "returning", "a", "triple", "of", "(", "unique", "in", "test", "shared", "unique", "in", "gold", ")", "." ]
python
train
36.6
miyakogi/wdom
wdom/css.py
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/css.py#L155-L162
def parse_style_decl(style: str, owner: AbstractNode = None ) -> CSSStyleDeclaration: """Make CSSStyleDeclaration from style string. :arg AbstractNode owner: Owner of the style. """ _style = CSSStyleDeclaration(style, owner=owner) return _style
[ "def", "parse_style_decl", "(", "style", ":", "str", ",", "owner", ":", "AbstractNode", "=", "None", ")", "->", "CSSStyleDeclaration", ":", "_style", "=", "CSSStyleDeclaration", "(", "style", ",", "owner", "=", "owner", ")", "return", "_style" ]
Make CSSStyleDeclaration from style string. :arg AbstractNode owner: Owner of the style.
[ "Make", "CSSStyleDeclaration", "from", "style", "string", "." ]
python
train
34.875
Terrance/SkPy
skpy/util.py
https://github.com/Terrance/SkPy/blob/0f9489c94e8ec4d3effab4314497428872a80ad1/skpy/util.py#L94-L121
def initAttrs(cls): """ Class decorator: automatically generate an ``__init__`` method that expects args from cls.attrs and stores them. Args: cls (class): class to decorate Returns: class: same, but modified, class """ def __init__(self, skype=N...
[ "def", "initAttrs", "(", "cls", ")", ":", "def", "__init__", "(", "self", ",", "skype", "=", "None", ",", "raw", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "super", "(", "cls", ",", "self", ")", ".", "__init__", "(", "sky...
Class decorator: automatically generate an ``__init__`` method that expects args from cls.attrs and stores them. Args: cls (class): class to decorate Returns: class: same, but modified, class
[ "Class", "decorator", ":", "automatically", "generate", "an", "__init__", "method", "that", "expects", "args", "from", "cls", ".", "attrs", "and", "stores", "them", "." ]
python
test
43.642857
wavycloud/pyboto3
pyboto3/swf.py
https://github.com/wavycloud/pyboto3/blob/924957ccf994303713a4eed90b775ff2ab95b2e5/pyboto3/swf.py#L2797-L2923
def register_workflow_type(domain=None, name=None, version=None, description=None, defaultTaskStartToCloseTimeout=None, defaultExecutionStartToCloseTimeout=None, defaultTaskList=None, defaultTaskPriority=None, defaultChildPolicy=None, defaultLambdaRole=None): """ Registers a new workflow type and its configurat...
[ "def", "register_workflow_type", "(", "domain", "=", "None", ",", "name", "=", "None", ",", "version", "=", "None", ",", "description", "=", "None", ",", "defaultTaskStartToCloseTimeout", "=", "None", ",", "defaultExecutionStartToCloseTimeout", "=", "None", ",", ...
Registers a new workflow type and its configuration settings in the specified domain. The retention period for the workflow history is set by the RegisterDomain action. Access Control You can use IAM policies to control this action's access to Amazon SWF resources as follows: If the caller does not hav...
[ "Registers", "a", "new", "workflow", "type", "and", "its", "configuration", "settings", "in", "the", "specified", "domain", ".", "The", "retention", "period", "for", "the", "workflow", "history", "is", "set", "by", "the", "RegisterDomain", "action", ".", "Acce...
python
train
79.527559
its-rigs/Trolly
trolly/client.py
https://github.com/its-rigs/Trolly/blob/483dc94c352df40dc05ead31820b059b2545cf82/trolly/client.py#L182-L193
def create_checklist_item(self, card_id, checklist_id, checklistitem_json): """ Create a ChecklistItem object from JSON object """ return trolly.checklist.ChecklistItem( trello_client=self, card_id=card_id, checklist_id=checklist_id, checkl...
[ "def", "create_checklist_item", "(", "self", ",", "card_id", ",", "checklist_id", ",", "checklistitem_json", ")", ":", "return", "trolly", ".", "checklist", ".", "ChecklistItem", "(", "trello_client", "=", "self", ",", "card_id", "=", "card_id", ",", "checklist_...
Create a ChecklistItem object from JSON object
[ "Create", "a", "ChecklistItem", "object", "from", "JSON", "object" ]
python
test
41.166667
gregmccoy/melissadata
melissadata/melissadata.py
https://github.com/gregmccoy/melissadata/blob/e610152c8ec98f673b9c7be4d359bfacdfde7c1e/melissadata/melissadata.py#L30-L79
def verify_address(self, addr1="", addr2="", city="", fname="", lname="", phone="", province="", postal="", country="", email="", recordID="", freeform= ""): """verify_address Builds a JSON request to send to Melissa data. Takes in all needed address info. Args: addr1 (str):Con...
[ "def", "verify_address", "(", "self", ",", "addr1", "=", "\"\"", ",", "addr2", "=", "\"\"", ",", "city", "=", "\"\"", ",", "fname", "=", "\"\"", ",", "lname", "=", "\"\"", ",", "phone", "=", "\"\"", ",", "province", "=", "\"\"", ",", "postal", "=",...
verify_address Builds a JSON request to send to Melissa data. Takes in all needed address info. Args: addr1 (str):Contains info for Melissa data addr2 (str):Contains info for Melissa data city (str):Contains info for Melissa data fname (s...
[ "verify_address" ]
python
train
41.32
oceanprotocol/squid-py
squid_py/keeper/templates/access_secret_store_template.py
https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/templates/access_secret_store_template.py#L17-L45
def create_agreement(self, agreement_id, did, condition_ids, time_locks, time_outs, consumer_address, account): """ Create the service agreement. Return true if it is created successfully. :param agreement_id: id of the agreement, hex str :param did: DID, str ...
[ "def", "create_agreement", "(", "self", ",", "agreement_id", ",", "did", ",", "condition_ids", ",", "time_locks", ",", "time_outs", ",", "consumer_address", ",", "account", ")", ":", "logger", ".", "info", "(", "f'Creating agreement {agreement_id} with did={did}, cons...
Create the service agreement. Return true if it is created successfully. :param agreement_id: id of the agreement, hex str :param did: DID, str :param condition_ids: is a list of bytes32 content-addressed Condition IDs, bytes32 :param time_locks: is a list of uint time lock values assoc...
[ "Create", "the", "service", "agreement", ".", "Return", "true", "if", "it", "is", "created", "successfully", "." ]
python
train
44.655172
mitsei/dlkit
dlkit/json_/learning/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/sessions.py#L1732-L1753
def get_objective_bank_ids_by_objective(self, objective_id): """Gets the list of ``ObjectiveBank`` ``Ids`` mapped to an ``Objective``. arg: objective_id (osid.id.Id): ``Id`` of an ``Objective`` return: (osid.id.IdList) - list of objective bank ``Ids`` raise: NotFound - ``objective_...
[ "def", "get_objective_bank_ids_by_objective", "(", "self", ",", "objective_id", ")", ":", "# Implemented from template for", "# osid.resource.ResourceBinSession.get_bin_ids_by_resource", "mgr", "=", "self", ".", "_get_provider_manager", "(", "'LEARNING'", ",", "local", "=", "...
Gets the list of ``ObjectiveBank`` ``Ids`` mapped to an ``Objective``. arg: objective_id (osid.id.Id): ``Id`` of an ``Objective`` return: (osid.id.IdList) - list of objective bank ``Ids`` raise: NotFound - ``objective_id`` is not found raise: NullArgument - ``objective_id`` is ``n...
[ "Gets", "the", "list", "of", "ObjectiveBank", "Ids", "mapped", "to", "an", "Objective", "." ]
python
train
50.181818
saltstack/salt
salt/utils/reactor.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/reactor.py#L492-L496
def runner(self, fun, **kwargs): ''' Wrap RunnerClient for executing :ref:`runner modules <all-salt.runners>` ''' return self.pool.fire_async(self.client_cache['runner'].low, args=(fun, kwargs))
[ "def", "runner", "(", "self", ",", "fun", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "pool", ".", "fire_async", "(", "self", ".", "client_cache", "[", "'runner'", "]", ".", "low", ",", "args", "=", "(", "fun", ",", "kwargs", ")", "...
Wrap RunnerClient for executing :ref:`runner modules <all-salt.runners>`
[ "Wrap", "RunnerClient", "for", "executing", ":", "ref", ":", "runner", "modules", "<all", "-", "salt", ".", "runners", ">" ]
python
train
44.4
PmagPy/PmagPy
programs/thellier_gui.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/thellier_gui.py#L2886-L2918
def on_menu_save_interpretation(self, event): ''' save interpretations to a redo file ''' thellier_gui_redo_file = open( os.path.join(self.WD, "thellier_GUI.redo"), 'w') #-------------------------------------------------- # write interpretations to thellier...
[ "def", "on_menu_save_interpretation", "(", "self", ",", "event", ")", ":", "thellier_gui_redo_file", "=", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "WD", ",", "\"thellier_GUI.redo\"", ")", ",", "'w'", ")", "#---------------------------------...
save interpretations to a redo file
[ "save", "interpretations", "to", "a", "redo", "file" ]
python
train
37.666667
tropo/tropo-webapi-python
build/lib/tropo.py
https://github.com/tropo/tropo-webapi-python/blob/f87772644a6b45066a4c5218f0c1f6467b64ab3c/build/lib/tropo.py#L654-L664
def getInterpretation(self): """ Get the value of the previously POSTed Tropo action. """ actions = self._actions if (type (actions) is list): dict = actions[0] else: dict = actions return dict['interpretation']
[ "def", "getInterpretation", "(", "self", ")", ":", "actions", "=", "self", ".", "_actions", "if", "(", "type", "(", "actions", ")", "is", "list", ")", ":", "dict", "=", "actions", "[", "0", "]", "else", ":", "dict", "=", "actions", "return", "dict", ...
Get the value of the previously POSTed Tropo action.
[ "Get", "the", "value", "of", "the", "previously", "POSTed", "Tropo", "action", "." ]
python
train
25.636364
quantopian/zipline
zipline/assets/assets.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L1568-L1591
def was_active(reference_date_value, asset): """ Whether or not `asset` was active at the time corresponding to `reference_date_value`. Parameters ---------- reference_date_value : int Date, represented as nanoseconds since EPOCH, for which we want to know if `asset` was alive. ...
[ "def", "was_active", "(", "reference_date_value", ",", "asset", ")", ":", "return", "(", "asset", ".", "start_date", ".", "value", "<=", "reference_date_value", "<=", "asset", ".", "end_date", ".", "value", ")" ]
Whether or not `asset` was active at the time corresponding to `reference_date_value`. Parameters ---------- reference_date_value : int Date, represented as nanoseconds since EPOCH, for which we want to know if `asset` was alive. This is generally the result of accessing the `v...
[ "Whether", "or", "not", "asset", "was", "active", "at", "the", "time", "corresponding", "to", "reference_date_value", "." ]
python
train
28.333333
ponty/confduino
confduino/util.py
https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/util.py#L58-L76
def read_properties(filename): """read properties file into bunch. :param filename: string :rtype: bunch (dict like and object like) """ s = path(filename).text() dummy_section = 'xxx' cfgparser = configparser.RawConfigParser() # avoid converting options to lower case cfgparser.op...
[ "def", "read_properties", "(", "filename", ")", ":", "s", "=", "path", "(", "filename", ")", ".", "text", "(", ")", "dummy_section", "=", "'xxx'", "cfgparser", "=", "configparser", ".", "RawConfigParser", "(", ")", "# avoid converting options to lower case", "cf...
read properties file into bunch. :param filename: string :rtype: bunch (dict like and object like)
[ "read", "properties", "file", "into", "bunch", "." ]
python
train
27.947368
cloudtools/stacker
stacker/hooks/command.py
https://github.com/cloudtools/stacker/blob/ad6013a03a560c46ba3c63c4d153336273e6da5d/stacker/hooks/command.py#L18-L124
def run_command(provider, context, command, capture=False, interactive=False, ignore_status=False, quiet=False, stdin=None, env=None, **kwargs): """Run a custom command as a hook Keyword Arguments: command (list or str): Command to run capture (bool, ...
[ "def", "run_command", "(", "provider", ",", "context", ",", "command", ",", "capture", "=", "False", ",", "interactive", "=", "False", ",", "ignore_status", "=", "False", ",", "quiet", "=", "False", ",", "stdin", "=", "None", ",", "env", "=", "None", "...
Run a custom command as a hook Keyword Arguments: command (list or str): Command to run capture (bool, optional): If enabled, capture the command's stdout and stderr, and return them in the hook result. Default: false interactive (bool, optional): ...
[ "Run", "a", "custom", "command", "as", "a", "hook" ]
python
train
33.588785
BerkeleyAutomation/perception
perception/primesense_sensor.py
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/primesense_sensor.py#L370-L378
def _read_color_images(self, num_images): """ Reads color images from the device """ color_images = self._ros_read_images(self._color_image_buffer, num_images, self.staleness_limit) for i in range(0, num_images): if self._flip_images: color_images[i] = np.flipud(color...
[ "def", "_read_color_images", "(", "self", ",", "num_images", ")", ":", "color_images", "=", "self", ".", "_ros_read_images", "(", "self", ".", "_color_image_buffer", ",", "num_images", ",", "self", ".", "staleness_limit", ")", "for", "i", "in", "range", "(", ...
Reads color images from the device
[ "Reads", "color", "images", "from", "the", "device" ]
python
train
58.222222
modin-project/modin
modin/engines/base/frame/axis_partition.py
https://github.com/modin-project/modin/blob/5b77d242596560c646b8405340c9ce64acb183cb/modin/engines/base/frame/axis_partition.py#L164-L210
def deploy_axis_func( cls, axis, func, num_splits, kwargs, maintain_partitioning, *partitions ): """Deploy a function along a full axis in Ray. Args: axis: The axis to perform the function along. func: The function to perform. num_splits: ...
[ "def", "deploy_axis_func", "(", "cls", ",", "axis", ",", "func", ",", "num_splits", ",", "kwargs", ",", "maintain_partitioning", ",", "*", "partitions", ")", ":", "# Pop these off first because they aren't expected by the function.", "manual_partition", "=", "kwargs", "...
Deploy a function along a full axis in Ray. Args: axis: The axis to perform the function along. func: The function to perform. num_splits: The number of splits to return (see `split_result_of_axis_func_pandas`) kwargs: A di...
[ "Deploy", "a", "function", "along", "a", "full", "axis", "in", "Ray", "." ]
python
train
44.978723
JukeboxPipeline/jukebox-core
src/jukeboxcore/gui/configeditor.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/configeditor.py#L390-L404
def set_index_edited(self, index, edited): """Set whether the conf was edited or not. Edited files will be displayed with a \'*\' :param index: the index that was edited :type index: QModelIndex :param edited: if the file was edited, set edited to True, else False :type...
[ "def", "set_index_edited", "(", "self", ",", "index", ",", "edited", ")", ":", "self", ".", "__edited", "[", "index", ".", "row", "(", ")", "]", "=", "edited", "self", ".", "dataChanged", ".", "emit", "(", "index", ",", "index", ")" ]
Set whether the conf was edited or not. Edited files will be displayed with a \'*\' :param index: the index that was edited :type index: QModelIndex :param edited: if the file was edited, set edited to True, else False :type edited: bool :returns: None :rtype: N...
[ "Set", "whether", "the", "conf", "was", "edited", "or", "not", "." ]
python
train
32.333333
openstack/networking-cisco
networking_cisco/apps/saf/server/services/firewall/native/drivers/dev_mgr.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/drivers/dev_mgr.py#L168-L175
def populate_event_que(self, que_obj): """Populates the event queue object. This is for sending router events to event handler. """ for ip in self.obj_dict: drvr_obj = self.obj_dict.get(ip).get('drvr_obj') drvr_obj.populate_event_que(que_obj)
[ "def", "populate_event_que", "(", "self", ",", "que_obj", ")", ":", "for", "ip", "in", "self", ".", "obj_dict", ":", "drvr_obj", "=", "self", ".", "obj_dict", ".", "get", "(", "ip", ")", ".", "get", "(", "'drvr_obj'", ")", "drvr_obj", ".", "populate_ev...
Populates the event queue object. This is for sending router events to event handler.
[ "Populates", "the", "event", "queue", "object", "." ]
python
train
36.5
has2k1/plotnine
plotnine/geoms/geom.py
https://github.com/has2k1/plotnine/blob/566e579af705367e584fb27a74e6c5199624ca89/plotnine/geoms/geom.py#L223-L256
def draw_panel(self, data, panel_params, coord, ax, **params): """ Plot all groups For effeciency, geoms that do not need to partition different groups before plotting should override this method and avoid the groupby. Parameters ---------- data : datafr...
[ "def", "draw_panel", "(", "self", ",", "data", ",", "panel_params", ",", "coord", ",", "ax", ",", "*", "*", "params", ")", ":", "for", "_", ",", "gdata", "in", "data", ".", "groupby", "(", "'group'", ")", ":", "gdata", ".", "reset_index", "(", "inp...
Plot all groups For effeciency, geoms that do not need to partition different groups before plotting should override this method and avoid the groupby. Parameters ---------- data : dataframe Data to be plotted by this geom. This is the dataframe ...
[ "Plot", "all", "groups" ]
python
train
34.205882
delfick/harpoon
docs/sphinx/ext/show_tasks.py
https://github.com/delfick/harpoon/blob/a2d39311d6127b7da2e15f40468bf320d598e461/docs/sphinx/ext/show_tasks.py#L13-L32
def run(self): """For each file in noseOfYeti/specs, output nodes to represent each spec file""" tokens = [] section = nodes.section() section['ids'].append("available-tasks") title = nodes.title() title += nodes.Text("Default tasks") section += title ta...
[ "def", "run", "(", "self", ")", ":", "tokens", "=", "[", "]", "section", "=", "nodes", ".", "section", "(", ")", "section", "[", "'ids'", "]", ".", "append", "(", "\"available-tasks\"", ")", "title", "=", "nodes", ".", "title", "(", ")", "title", "...
For each file in noseOfYeti/specs, output nodes to represent each spec file
[ "For", "each", "file", "in", "noseOfYeti", "/", "specs", "output", "nodes", "to", "represent", "each", "spec", "file" ]
python
train
37.25
allenai/allennlp
allennlp/training/metric_tracker.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/training/metric_tracker.py#L115-L120
def add_metrics(self, metrics: Iterable[float]) -> None: """ Helper to add multiple metrics at once. """ for metric in metrics: self.add_metric(metric)
[ "def", "add_metrics", "(", "self", ",", "metrics", ":", "Iterable", "[", "float", "]", ")", "->", "None", ":", "for", "metric", "in", "metrics", ":", "self", ".", "add_metric", "(", "metric", ")" ]
Helper to add multiple metrics at once.
[ "Helper", "to", "add", "multiple", "metrics", "at", "once", "." ]
python
train
31.666667
partofthething/ace
ace/validation/validate_smoothers.py
https://github.com/partofthething/ace/blob/1593a49f3c2e845514323e9c36ee253fe77bac3c/ace/validation/validate_smoothers.py#L136-L143
def run_mace_smothr(x, y, bass_enhancement=0.0): # pylint: disable=unused-argument """Run the FORTRAN SMOTHR.""" N = len(x) weight = numpy.ones(N) results = numpy.zeros(N) flags = numpy.zeros((N, 7)) mace.smothr(1, x, y, weight, results, flags) return results
[ "def", "run_mace_smothr", "(", "x", ",", "y", ",", "bass_enhancement", "=", "0.0", ")", ":", "# pylint: disable=unused-argument", "N", "=", "len", "(", "x", ")", "weight", "=", "numpy", ".", "ones", "(", "N", ")", "results", "=", "numpy", ".", "zeros", ...
Run the FORTRAN SMOTHR.
[ "Run", "the", "FORTRAN", "SMOTHR", "." ]
python
train
35.125
not-na/peng3d
peng3d/pyglet_patch.py
https://github.com/not-na/peng3d/blob/1151be665b26cc8a479f6307086ba919e4d32d85/peng3d/pyglet_patch.py#L136-L181
def _draw(self, mode, vertex_list=None): '''Draw vertices in the domain. If `vertex_list` is not specified, all vertices in the domain are drawn. This is the most efficient way to render primitives. If `vertex_list` specifies a `VertexList`, only primitives in that list will b...
[ "def", "_draw", "(", "self", ",", "mode", ",", "vertex_list", "=", "None", ")", ":", "glPushClientAttrib", "(", "GL_CLIENT_VERTEX_ARRAY_BIT", ")", "for", "buffer", ",", "attributes", "in", "self", ".", "buffer_attributes", ":", "buffer", ".", "bind", "(", ")...
Draw vertices in the domain. If `vertex_list` is not specified, all vertices in the domain are drawn. This is the most efficient way to render primitives. If `vertex_list` specifies a `VertexList`, only primitives in that list will be drawn. :Parameters: `mode` : ...
[ "Draw", "vertices", "in", "the", "domain", "." ]
python
test
37.695652
tensorflow/datasets
tensorflow_datasets/core/features/image_feature.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/features/image_feature.py#L135-L144
def encode_example(self, image_or_path_or_fobj): """Convert the given image into a dict convertible to tf example.""" if isinstance(image_or_path_or_fobj, np.ndarray): encoded_image = self._encode_image(image_or_path_or_fobj) elif isinstance(image_or_path_or_fobj, six.string_types): with tf.io.g...
[ "def", "encode_example", "(", "self", ",", "image_or_path_or_fobj", ")", ":", "if", "isinstance", "(", "image_or_path_or_fobj", ",", "np", ".", "ndarray", ")", ":", "encoded_image", "=", "self", ".", "_encode_image", "(", "image_or_path_or_fobj", ")", "elif", "i...
Convert the given image into a dict convertible to tf example.
[ "Convert", "the", "given", "image", "into", "a", "dict", "convertible", "to", "tf", "example", "." ]
python
train
48.7
pyca/pyopenssl
src/OpenSSL/crypto.py
https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/src/OpenSSL/crypto.py#L165-L202
def _get_asn1_time(timestamp): """ Retrieve the time value of an ASN1 time object. @param timestamp: An ASN1_GENERALIZEDTIME* (or an object safely castable to that type) from which the time value will be retrieved. @return: The time value from C{timestamp} as a L{bytes} string in a certain ...
[ "def", "_get_asn1_time", "(", "timestamp", ")", ":", "string_timestamp", "=", "_ffi", ".", "cast", "(", "'ASN1_STRING*'", ",", "timestamp", ")", "if", "_lib", ".", "ASN1_STRING_length", "(", "string_timestamp", ")", "==", "0", ":", "return", "None", "elif", ...
Retrieve the time value of an ASN1 time object. @param timestamp: An ASN1_GENERALIZEDTIME* (or an object safely castable to that type) from which the time value will be retrieved. @return: The time value from C{timestamp} as a L{bytes} string in a certain format. Or C{None} if the object cont...
[ "Retrieve", "the", "time", "value", "of", "an", "ASN1", "time", "object", "." ]
python
test
45.657895
JelteF/PyLaTeX
pylatex/table.py
https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/table.py#L311-L322
def dumps(self): """Represent the multicolumn as a string in LaTeX syntax. Returns ------- str """ args = [self.size, self.align, self.dumps_content()] string = Command(self.latex_name, args).dumps() return string
[ "def", "dumps", "(", "self", ")", ":", "args", "=", "[", "self", ".", "size", ",", "self", ".", "align", ",", "self", ".", "dumps_content", "(", ")", "]", "string", "=", "Command", "(", "self", ".", "latex_name", ",", "args", ")", ".", "dumps", "...
Represent the multicolumn as a string in LaTeX syntax. Returns ------- str
[ "Represent", "the", "multicolumn", "as", "a", "string", "in", "LaTeX", "syntax", "." ]
python
train
22.416667
robinandeer/puzzle
puzzle/utils/get_file_info.py
https://github.com/robinandeer/puzzle/blob/9476f05b416d3a5135d25492cb31411fdf831c58/puzzle/utils/get_file_info.py#L11-L33
def get_file_type(variant_source): """Check what kind of file variant source is Args: variant_source (str): Path to variant source Returns: file_type (str): 'vcf', 'gemini' or 'unknown' """ file_type = 'unknown' valid_vcf_suffixes = ('.vcf', '.vcf.gz...
[ "def", "get_file_type", "(", "variant_source", ")", ":", "file_type", "=", "'unknown'", "valid_vcf_suffixes", "=", "(", "'.vcf'", ",", "'.vcf.gz'", ")", "if", "variant_source", ":", "logger", ".", "debug", "(", "\"Check file type with file: {0}\"", ".", "format", ...
Check what kind of file variant source is Args: variant_source (str): Path to variant source Returns: file_type (str): 'vcf', 'gemini' or 'unknown'
[ "Check", "what", "kind", "of", "file", "variant", "source", "is", "Args", ":", "variant_source", "(", "str", ")", ":", "Path", "to", "variant", "source", "Returns", ":", "file_type", "(", "str", ")", ":", "vcf", "gemini", "or", "unknown" ]
python
train
35.26087
cltk/cltk
cltk/text_reuse/text_reuse.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/text_reuse/text_reuse.py#L163-L181
def _process_sentences(self, sents_list): """ Divide an input string to a list of substrings based on window_length and curse_forward values :param sents_list: list [str] :return: list [object] """ processed_sents = [] for sent in sents_list: processe...
[ "def", "_process_sentences", "(", "self", ",", "sents_list", ")", ":", "processed_sents", "=", "[", "]", "for", "sent", "in", "sents_list", ":", "processed_sent", "=", "{", "'text'", ":", "sent", "}", "# If the class is set to santize input before comparison, do so", ...
Divide an input string to a list of substrings based on window_length and curse_forward values :param sents_list: list [str] :return: list [object]
[ "Divide", "an", "input", "string", "to", "a", "list", "of", "substrings", "based", "on", "window_length", "and", "curse_forward", "values", ":", "param", "sents_list", ":", "list", "[", "str", "]", ":", "return", ":", "list", "[", "object", "]" ]
python
train
34.315789
adafruit/Adafruit_Python_BluefruitLE
Adafruit_BluefruitLE/corebluetooth/device.py
https://github.com/adafruit/Adafruit_Python_BluefruitLE/blob/34fc6f596371b961628369d78ce836950514062f/Adafruit_BluefruitLE/corebluetooth/device.py#L132-L137
def _descriptor_changed(self, descriptor): """Called when the specified descriptor has changed its value.""" # Tell the descriptor it has a new value to read. desc = descriptor_list().get(descriptor) if desc is not None: desc._value_read.set()
[ "def", "_descriptor_changed", "(", "self", ",", "descriptor", ")", ":", "# Tell the descriptor it has a new value to read.", "desc", "=", "descriptor_list", "(", ")", ".", "get", "(", "descriptor", ")", "if", "desc", "is", "not", "None", ":", "desc", ".", "_valu...
Called when the specified descriptor has changed its value.
[ "Called", "when", "the", "specified", "descriptor", "has", "changed", "its", "value", "." ]
python
valid
47
lambdamusic/Ontospy
ontospy/core/ontospy.py
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/ontospy.py#L1019-L1027
def rdf_source(self, format="turtle"): """ Wrapper for rdflib serializer method. Valid options are: xml, n3, turtle, nt, pretty-xml, json-ld [trix not working out of the box] """ s = self.rdflib_graph.serialize(format=format) if isinstance(s, bytes): s = s.dec...
[ "def", "rdf_source", "(", "self", ",", "format", "=", "\"turtle\"", ")", ":", "s", "=", "self", ".", "rdflib_graph", ".", "serialize", "(", "format", "=", "format", ")", "if", "isinstance", "(", "s", ",", "bytes", ")", ":", "s", "=", "s", ".", "dec...
Wrapper for rdflib serializer method. Valid options are: xml, n3, turtle, nt, pretty-xml, json-ld [trix not working out of the box]
[ "Wrapper", "for", "rdflib", "serializer", "method", ".", "Valid", "options", "are", ":", "xml", "n3", "turtle", "nt", "pretty", "-", "xml", "json", "-", "ld", "[", "trix", "not", "working", "out", "of", "the", "box", "]" ]
python
train
37.888889
tmontaigu/pylas
pylas/point/packing.py
https://github.com/tmontaigu/pylas/blob/8335a1a7d7677f0e4bc391bb6fa3c75b42ed5b06/pylas/point/packing.py#L30-L63
def pack(array, sub_field_array, mask, inplace=False): """ Packs a sub field's array into another array using a mask Parameters: ---------- array : numpy.ndarray The array in which the sub field array will be packed into array_in : numpy.ndarray sub field array to pack mask : ma...
[ "def", "pack", "(", "array", ",", "sub_field_array", ",", "mask", ",", "inplace", "=", "False", ")", ":", "lsb", "=", "least_significant_bit", "(", "mask", ")", "max_value", "=", "int", "(", "mask", ">>", "lsb", ")", "if", "sub_field_array", ".", "max", ...
Packs a sub field's array into another array using a mask Parameters: ---------- array : numpy.ndarray The array in which the sub field array will be packed into array_in : numpy.ndarray sub field array to pack mask : mask (ie: 0b00001111) Mask of the sub field inplace :...
[ "Packs", "a", "sub", "field", "s", "array", "into", "another", "array", "using", "a", "mask" ]
python
test
34.029412
pyroscope/pyrocore
pavement.py
https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/pavement.py#L262-L270
def watchdog_pid(): """Get watchdog PID via ``netstat``.""" result = sh('netstat -tulpn 2>/dev/null | grep 127.0.0.1:{:d}' .format(SPHINX_AUTOBUILD_PORT), capture=True, ignore_error=True) pid = result.strip() pid = pid.split()[-1] if pid else None pid = pid.split('/', 1)[0] if pid an...
[ "def", "watchdog_pid", "(", ")", ":", "result", "=", "sh", "(", "'netstat -tulpn 2>/dev/null | grep 127.0.0.1:{:d}'", ".", "format", "(", "SPHINX_AUTOBUILD_PORT", ")", ",", "capture", "=", "True", ",", "ignore_error", "=", "True", ")", "pid", "=", "result", ".",...
Get watchdog PID via ``netstat``.
[ "Get", "watchdog", "PID", "via", "netstat", "." ]
python
train
38.888889
oscarbranson/latools
latools/filtering/classifier_obj.py
https://github.com/oscarbranson/latools/blob/cd25a650cfee318152f234d992708511f7047fbe/latools/filtering/classifier_obj.py#L28-L65
def format_data(self, data, scale=True): """ Function for converting a dict to an array suitable for sklearn. Parameters ---------- data : dict A dict of data, containing all elements of `analytes` as items. scale : bool Whether or not...
[ "def", "format_data", "(", "self", ",", "data", ",", "scale", "=", "True", ")", ":", "if", "len", "(", "self", ".", "analytes", ")", "==", "1", ":", "# if single analyte", "d", "=", "nominal_values", "(", "data", "[", "self", ".", "analytes", "[", "0...
Function for converting a dict to an array suitable for sklearn. Parameters ---------- data : dict A dict of data, containing all elements of `analytes` as items. scale : bool Whether or not to scale the data. Should always be `True`, unle...
[ "Function", "for", "converting", "a", "dict", "to", "an", "array", "suitable", "for", "sklearn", "." ]
python
test
32
AartGoossens/goldencheetahlib
goldencheetahlib/client.py
https://github.com/AartGoossens/goldencheetahlib/blob/ebe57de7d94280674c8440a81f53ac02f0b4eb43/goldencheetahlib/client.py#L112-L128
def _request_activity_data(self, athlete, filename): """Actually do the request for activity filename This call is slow and therefore this method is memory cached. Keyword arguments: athlete -- Full name of athlete filename -- filename of request activity (e.g. \'2015_04_29_09_0...
[ "def", "_request_activity_data", "(", "self", ",", "athlete", ",", "filename", ")", ":", "response", "=", "self", ".", "_get_request", "(", "self", ".", "_activity_endpoint", "(", "athlete", ",", "filename", ")", ")", ".", "json", "(", ")", "activity", "="...
Actually do the request for activity filename This call is slow and therefore this method is memory cached. Keyword arguments: athlete -- Full name of athlete filename -- filename of request activity (e.g. \'2015_04_29_09_03_16.json\')
[ "Actually", "do", "the", "request", "for", "activity", "filename", "This", "call", "is", "slow", "and", "therefore", "this", "method", "is", "memory", "cached", "." ]
python
test
44.411765
beregond/super_state_machine
super_state_machine/machines.py
https://github.com/beregond/super_state_machine/blob/31ad527f4e6b7a01e315ce865735ca18957c223e/super_state_machine/machines.py#L235-L244
def _add_new_methods(cls): """Add all generated methods to result class.""" for name, method in cls.context.new_methods.items(): if hasattr(cls.context.new_class, name): raise ValueError( "Name collision in state machine class - '{name}'." ...
[ "def", "_add_new_methods", "(", "cls", ")", ":", "for", "name", ",", "method", "in", "cls", ".", "context", ".", "new_methods", ".", "items", "(", ")", ":", "if", "hasattr", "(", "cls", ".", "context", ".", "new_class", ",", "name", ")", ":", "raise"...
Add all generated methods to result class.
[ "Add", "all", "generated", "methods", "to", "result", "class", "." ]
python
train
40.4
vmalyi/adb_android
adb_android/adb_android.py
https://github.com/vmalyi/adb_android/blob/de53dc54f27b14dc8c2ae64b136a60a59e1a1cb1/adb_android/adb_android.py#L61-L69
def pull(src, dest): """ Pull object from target to host :param src: string path of object on target :param dest: string destination path on host :return: result of _exec_command() execution """ adb_full_cmd = [v.ADB_COMMAND_PREFIX, v.ADB_COMMAND_PULL, src, dest] return _exec_command(adb...
[ "def", "pull", "(", "src", ",", "dest", ")", ":", "adb_full_cmd", "=", "[", "v", ".", "ADB_COMMAND_PREFIX", ",", "v", ".", "ADB_COMMAND_PULL", ",", "src", ",", "dest", "]", "return", "_exec_command", "(", "adb_full_cmd", ")" ]
Pull object from target to host :param src: string path of object on target :param dest: string destination path on host :return: result of _exec_command() execution
[ "Pull", "object", "from", "target", "to", "host", ":", "param", "src", ":", "string", "path", "of", "object", "on", "target", ":", "param", "dest", ":", "string", "destination", "path", "on", "host", ":", "return", ":", "result", "of", "_exec_command", "...
python
train
35.777778
camptocamp/Studio
studio/controllers/datasources.py
https://github.com/camptocamp/Studio/blob/43cb7298434fb606b15136801b79b03571a2f27e/studio/controllers/datasources.py#L62-L95
def create(self, datastore_id=None): """POST /datastores/{datastore_id}/datasources: Create a new datasource by file upload.""" datastore = self._get_ogrdatastore_by_id(datastore_id) if not datastore: abort(404) # only "directory" datastores are supported at this po...
[ "def", "create", "(", "self", ",", "datastore_id", "=", "None", ")", ":", "datastore", "=", "self", ".", "_get_ogrdatastore_by_id", "(", "datastore_id", ")", "if", "not", "datastore", ":", "abort", "(", "404", ")", "# only \"directory\" datastores are supported at...
POST /datastores/{datastore_id}/datasources: Create a new datasource by file upload.
[ "POST", "/", "datastores", "/", "{", "datastore_id", "}", "/", "datasources", ":", "Create", "a", "new", "datasource", "by", "file", "upload", "." ]
python
train
38.029412
apache/airflow
airflow/contrib/hooks/azure_fileshare_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/azure_fileshare_hook.py#L64-L81
def check_for_file(self, share_name, directory_name, file_name, **kwargs): """ Check if a file exists on Azure File Share. :param share_name: Name of the share. :type share_name: str :param directory_name: Name of the directory. :type directory_name: str :param f...
[ "def", "check_for_file", "(", "self", ",", "share_name", ",", "directory_name", ",", "file_name", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "connection", ".", "exists", "(", "share_name", ",", "directory_name", ",", "file_name", ",", "*", "...
Check if a file exists on Azure File Share. :param share_name: Name of the share. :type share_name: str :param directory_name: Name of the directory. :type directory_name: str :param file_name: Name of the file. :type file_name: str :param kwargs: Optional keywor...
[ "Check", "if", "a", "file", "exists", "on", "Azure", "File", "Share", "." ]
python
test
39
glut23/webvtt-py
webvtt/cli.py
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/cli.py#L23-L32
def main(): """Main entry point for CLI commands.""" options = docopt(__doc__, version=__version__) if options['segment']: segment( options['<file>'], options['--output'], options['--target-duration'], options['--mpegts'], )
[ "def", "main", "(", ")", ":", "options", "=", "docopt", "(", "__doc__", ",", "version", "=", "__version__", ")", "if", "options", "[", "'segment'", "]", ":", "segment", "(", "options", "[", "'<file>'", "]", ",", "options", "[", "'--output'", "]", ",", ...
Main entry point for CLI commands.
[ "Main", "entry", "point", "for", "CLI", "commands", "." ]
python
train
29.1
titusjan/argos
argos/repo/rtiplugins/hdf5.py
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/repo/rtiplugins/hdf5.py#L107-L127
def dataSetMissingValue(h5Dataset): """ Returns the missingData given a HDF-5 dataset Looks for one of the following attributes: _FillValue, missing_value, MissingValue, missingValue. Returns None if these attributes are not found. HDF-EOS and NetCDF files seem to put the attributes in 1-e...
[ "def", "dataSetMissingValue", "(", "h5Dataset", ")", ":", "attributes", "=", "h5Dataset", ".", "attrs", "if", "not", "attributes", ":", "return", "None", "# a premature optimization :-)", "for", "key", "in", "(", "'missing_value'", ",", "'MissingValue'", ",", "'mi...
Returns the missingData given a HDF-5 dataset Looks for one of the following attributes: _FillValue, missing_value, MissingValue, missingValue. Returns None if these attributes are not found. HDF-EOS and NetCDF files seem to put the attributes in 1-element arrays. So if the attribute c...
[ "Returns", "the", "missingData", "given", "a", "HDF", "-", "5", "dataset" ]
python
train
44.333333
bitesofcode/projexui
projexui/widgets/xnodewidget/xnode.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnode.py#L978-L992
def hoverLeaveEvent(self, event): """ Processes the hovering information for this node. :param event | <QHoverEvent> """ if self._hoverSpot: if self._hoverSpot.hoverLeaveEvent(event): self.update() self._hoverSpot = None ...
[ "def", "hoverLeaveEvent", "(", "self", ",", "event", ")", ":", "if", "self", ".", "_hoverSpot", ":", "if", "self", ".", "_hoverSpot", ".", "hoverLeaveEvent", "(", "event", ")", ":", "self", ".", "update", "(", ")", "self", ".", "_hoverSpot", "=", "None...
Processes the hovering information for this node. :param event | <QHoverEvent>
[ "Processes", "the", "hovering", "information", "for", "this", "node", ".", ":", "param", "event", "|", "<QHoverEvent", ">" ]
python
train
29.8
samstav/tox-pyenv
tox_pyenv.py
https://github.com/samstav/tox-pyenv/blob/7391610c2c4f1c95abde2e8638763b1b24e604cd/tox_pyenv.py#L69-L106
def tox_get_python_executable(envconfig): """Return a python executable for the given python base name. The first plugin/hook which returns an executable path will determine it. ``envconfig`` is the testenv configuration which contains per-testenv configuration, notably the ``.envname`` and ``.basepyt...
[ "def", "tox_get_python_executable", "(", "envconfig", ")", ":", "try", ":", "# pylint: disable=no-member", "pyenv", "=", "(", "getattr", "(", "py", ".", "path", ".", "local", ".", "sysfind", "(", "'pyenv'", ")", ",", "'strpath'", ",", "'pyenv'", ")", "or", ...
Return a python executable for the given python base name. The first plugin/hook which returns an executable path will determine it. ``envconfig`` is the testenv configuration which contains per-testenv configuration, notably the ``.envname`` and ``.basepython`` setting.
[ "Return", "a", "python", "executable", "for", "the", "given", "python", "base", "name", "." ]
python
train
37.394737
materialsproject/pymatgen
pymatgen/util/plotting.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/util/plotting.py#L77-L154
def pretty_plot_two_axis(x, y1, y2, xlabel=None, y1label=None, y2label=None, width=8, height=None, dpi=300): """ Variant of pretty_plot that does a dual axis plot. Adapted from matplotlib examples. Makes it easier to create plots with different axes. Args: x (np.ndarray...
[ "def", "pretty_plot_two_axis", "(", "x", ",", "y1", ",", "y2", ",", "xlabel", "=", "None", ",", "y1label", "=", "None", ",", "y2label", "=", "None", ",", "width", "=", "8", ",", "height", "=", "None", ",", "dpi", "=", "300", ")", ":", "import", "...
Variant of pretty_plot that does a dual axis plot. Adapted from matplotlib examples. Makes it easier to create plots with different axes. Args: x (np.ndarray/list): Data for x-axis. y1 (dict/np.ndarray/list): Data for y1 axis (left). If a dict, it will be interpreted as a {label: se...
[ "Variant", "of", "pretty_plot", "that", "does", "a", "dual", "axis", "plot", ".", "Adapted", "from", "matplotlib", "examples", ".", "Makes", "it", "easier", "to", "create", "plots", "with", "different", "axes", "." ]
python
train
34.358974
fake-name/ChromeController
ChromeController/Generator/Generated.py
https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L1776-L1796
def Emulation_setCPUThrottlingRate(self, rate): """ Function path: Emulation.setCPUThrottlingRate Domain: Emulation Method name: setCPUThrottlingRate WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'rate' (type: number) -> Throttling rate as a slowdown fac...
[ "def", "Emulation_setCPUThrottlingRate", "(", "self", ",", "rate", ")", ":", "assert", "isinstance", "(", "rate", ",", "(", "float", ",", "int", ")", ")", ",", "\"Argument 'rate' must be of type '['float', 'int']'. Received type: '%s'\"", "%", "type", "(", "rate", "...
Function path: Emulation.setCPUThrottlingRate Domain: Emulation Method name: setCPUThrottlingRate WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'rate' (type: number) -> Throttling rate as a slowdown factor (1 is no throttle, 2 is 2x slowdown, etc). No ret...
[ "Function", "path", ":", "Emulation", ".", "setCPUThrottlingRate", "Domain", ":", "Emulation", "Method", "name", ":", "setCPUThrottlingRate", "WARNING", ":", "This", "function", "is", "marked", "Experimental", "!", "Parameters", ":", "Required", "arguments", ":", ...
python
train
33
Nukesor/pueue
pueue/daemon/daemon.py
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L82-L109
def create_socket(self): """Create a socket for the daemon, depending on the directory location. Args: config_dir (str): The absolute path to the config directory used by the daemon. Returns: socket.socket: The daemon socket. Clients connect to this socket. """...
[ "def", "create_socket", "(", "self", ")", ":", "socket_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config_dir", ",", "'pueue.sock'", ")", "# Create Socket and exit with 1, if socket can't be created", "try", ":", "if", "os", ".", "path", ".", ...
Create a socket for the daemon, depending on the directory location. Args: config_dir (str): The absolute path to the config directory used by the daemon. Returns: socket.socket: The daemon socket. Clients connect to this socket.
[ "Create", "a", "socket", "for", "the", "daemon", "depending", "on", "the", "directory", "location", "." ]
python
train
37.678571
jaredLunde/redis_structures
redis_structures/debug/__init__.py
https://github.com/jaredLunde/redis_structures/blob/b9cce5f5c85db5e12c292633ff8d04e3ae053294/redis_structures/debug/__init__.py#L82-L93
def stdout_encode(u, default='utf-8'): """ Encodes a given string with the proper standard out encoding If sys.stdout.encoding isn't specified, it this defaults to @default @default: default encoding -> #str with standard out encoding """ # from http://stackoverflow.com/questions/3...
[ "def", "stdout_encode", "(", "u", ",", "default", "=", "'utf-8'", ")", ":", "# from http://stackoverflow.com/questions/3627793/best-output-type-and-", "# encoding-practices-for-repr-functions", "encoding", "=", "sys", ".", "stdout", ".", "encoding", "or", "default", "retu...
Encodes a given string with the proper standard out encoding If sys.stdout.encoding isn't specified, it this defaults to @default @default: default encoding -> #str with standard out encoding
[ "Encodes", "a", "given", "string", "with", "the", "proper", "standard", "out", "encoding", "If", "sys", ".", "stdout", ".", "encoding", "isn", "t", "specified", "it", "this", "defaults", "to", "@default" ]
python
train
41.5
lambdamusic/Ontospy
ontospy/core/actions.py
https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/core/actions.py#L209-L240
def _print_table_ontologies(): """ list all local files 2015-10-18: removed 'cached' from report 2016-06-17: made a subroutine of action_listlocal() """ ontologies = get_localontologies() ONTOSPY_LOCAL_MODELS = get_home_location() if ontologies: print("") temp...
[ "def", "_print_table_ontologies", "(", ")", ":", "ontologies", "=", "get_localontologies", "(", ")", "ONTOSPY_LOCAL_MODELS", "=", "get_home_location", "(", ")", "if", "ontologies", ":", "print", "(", "\"\"", ")", "temp", "=", "[", "]", "from", "collections", "...
list all local files 2015-10-18: removed 'cached' from report 2016-06-17: made a subroutine of action_listlocal()
[ "list", "all", "local", "files", "2015", "-", "10", "-", "18", ":", "removed", "cached", "from", "report", "2016", "-", "06", "-", "17", ":", "made", "a", "subroutine", "of", "action_listlocal", "()" ]
python
train
35.3125
saltstack/salt
salt/modules/introspect.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/introspect.py#L69-L104
def enabled_service_owners(): ''' Return which packages own each of the services that are currently enabled. CLI Example: salt myminion introspect.enabled_service_owners ''' error = {} if 'pkg.owner' not in __salt__: error['Unsupported Package Manager'] = ( 'The mod...
[ "def", "enabled_service_owners", "(", ")", ":", "error", "=", "{", "}", "if", "'pkg.owner'", "not", "in", "__salt__", ":", "error", "[", "'Unsupported Package Manager'", "]", "=", "(", "'The module for the package manager on this system does not '", "'support looking up w...
Return which packages own each of the services that are currently enabled. CLI Example: salt myminion introspect.enabled_service_owners
[ "Return", "which", "packages", "own", "each", "of", "the", "services", "that", "are", "currently", "enabled", "." ]
python
train
29.138889
rwl/pylon
contrib/cvxopf.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L599-L621
def dAbr_dV(dSf_dVa, dSf_dVm, dSt_dVa, dSt_dVm, Sf, St): """ Partial derivatives of squared flow magnitudes w.r.t voltage. Computes partial derivatives of apparent power w.r.t active and reactive power flows. Partial derivative must equal 1 for lines with zero flow to avoid division by zer...
[ "def", "dAbr_dV", "(", "dSf_dVa", ",", "dSf_dVm", ",", "dSt_dVa", ",", "dSt_dVm", ",", "Sf", ",", "St", ")", ":", "dAf_dPf", "=", "spdiag", "(", "2", "*", "Sf", ".", "real", "(", ")", ")", "dAf_dQf", "=", "spdiag", "(", "2", "*", "Sf", ".", "im...
Partial derivatives of squared flow magnitudes w.r.t voltage. Computes partial derivatives of apparent power w.r.t active and reactive power flows. Partial derivative must equal 1 for lines with zero flow to avoid division by zero errors (1 comes from L'Hopital).
[ "Partial", "derivatives", "of", "squared", "flow", "magnitudes", "w", ".", "r", ".", "t", "voltage", "." ]
python
train
42.391304
trailofbits/manticore
manticore/ethereum/detectors.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/ethereum/detectors.py#L340-L355
def _signed_sub_overflow(state, a, b): """ Sign extend the value to 512 bits and check the result can be represented in 256. Following there is a 32 bit excerpt of this condition: a - b -80000000 -3fffffff -00000001 +00000000 +00000001 +3fffffff +7fffffff +80000000 False ...
[ "def", "_signed_sub_overflow", "(", "state", ",", "a", ",", "b", ")", ":", "sub", "=", "Operators", ".", "SEXTEND", "(", "a", ",", "256", ",", "512", ")", "-", "Operators", ".", "SEXTEND", "(", "b", ",", "256", ",", "512", ")", "cond", "=", "Oper...
Sign extend the value to 512 bits and check the result can be represented in 256. Following there is a 32 bit excerpt of this condition: a - b -80000000 -3fffffff -00000001 +00000000 +00000001 +3fffffff +7fffffff +80000000 False False False False True True True ...
[ "Sign", "extend", "the", "value", "to", "512", "bits", "and", "check", "the", "result", "can", "be", "represented", "in", "256", ".", "Following", "there", "is", "a", "32", "bit", "excerpt", "of", "this", "condition", ":", "a", "-", "b", "-", "80000000...
python
valid
63.75
yamcs/yamcs-python
yamcs-client/examples/commanding.py
https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/commanding.py#L24-L32
def issue_and_listen_to_command_history(): """Listen to command history updates of a single issued command.""" def tc_callback(rec): print('TC:', rec) command = processor.issue_command('/YSS/SIMULATOR/SWITCH_VOLTAGE_OFF', args={ 'voltage_num': 1, }, comment='im a comment') command.c...
[ "def", "issue_and_listen_to_command_history", "(", ")", ":", "def", "tc_callback", "(", "rec", ")", ":", "print", "(", "'TC:'", ",", "rec", ")", "command", "=", "processor", ".", "issue_command", "(", "'/YSS/SIMULATOR/SWITCH_VOLTAGE_OFF'", ",", "args", "=", "{",...
Listen to command history updates of a single issued command.
[ "Listen", "to", "command", "history", "updates", "of", "a", "single", "issued", "command", "." ]
python
train
40.777778
klmitch/turnstile
turnstile/limits.py
https://github.com/klmitch/turnstile/blob/8fe9a359b45e505d3192ab193ecf9be177ab1a17/turnstile/limits.py#L153-L157
def _decode(cls, value): """Decode the given value, reverting '%'-encoded groups.""" value = cls._DEC_RE.sub(lambda x: '%c' % int(x.group(1), 16), value) return json.loads(value)
[ "def", "_decode", "(", "cls", ",", "value", ")", ":", "value", "=", "cls", ".", "_DEC_RE", ".", "sub", "(", "lambda", "x", ":", "'%c'", "%", "int", "(", "x", ".", "group", "(", "1", ")", ",", "16", ")", ",", "value", ")", "return", "json", "....
Decode the given value, reverting '%'-encoded groups.
[ "Decode", "the", "given", "value", "reverting", "%", "-", "encoded", "groups", "." ]
python
train
39.8
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/cameras/turntable.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/turntable.py#L125-L132
def _update_rotation(self, event): """Update rotation parmeters based on mouse movement""" p1 = event.mouse_event.press_event.pos p2 = event.mouse_event.pos if self._event_value is None: self._event_value = self.azimuth, self.elevation self.azimuth = self._event_value...
[ "def", "_update_rotation", "(", "self", ",", "event", ")", ":", "p1", "=", "event", ".", "mouse_event", ".", "press_event", ".", "pos", "p2", "=", "event", ".", "mouse_event", ".", "pos", "if", "self", ".", "_event_value", "is", "None", ":", "self", "....
Update rotation parmeters based on mouse movement
[ "Update", "rotation", "parmeters", "based", "on", "mouse", "movement" ]
python
train
50.5
etingof/pysmi
pysmi/lexer/smi.py
https://github.com/etingof/pysmi/blob/379a0a384c81875731be51a054bdacced6260fd8/pysmi/lexer/smi.py#L194-L204
def t_UPPERCASE_IDENTIFIER(self, t): r'[A-Z][-a-zA-z0-9]*' if t.value in self.forbidden_words: raise error.PySmiLexerError("%s is forbidden" % t.value, lineno=t.lineno) if t.value[-1] == '-': raise error.PySmiLexerError("Identifier should not end with '-': %s" % t.value,...
[ "def", "t_UPPERCASE_IDENTIFIER", "(", "self", ",", "t", ")", ":", "if", "t", ".", "value", "in", "self", ".", "forbidden_words", ":", "raise", "error", ".", "PySmiLexerError", "(", "\"%s is forbidden\"", "%", "t", ".", "value", ",", "lineno", "=", "t", "...
r'[A-Z][-a-zA-z0-9]*
[ "r", "[", "A", "-", "Z", "]", "[", "-", "a", "-", "zA", "-", "z0", "-", "9", "]", "*" ]
python
valid
37.636364
HumanCellAtlas/dcp-cli
hca/dss/util/__init__.py
https://github.com/HumanCellAtlas/dcp-cli/blob/cc70817bc4e50944c709eaae160de0bf7a19f0f3/hca/dss/util/__init__.py#L15-L27
def iter_paths(src_dir): """ Function that recursively locates files within folder Note: scandir does not guarantee ordering :param src_dir: string for directory to be parsed through :return an iterable of DirEntry objects all files within the src_dir """ for x in scandir(os.path.join(src_d...
[ "def", "iter_paths", "(", "src_dir", ")", ":", "for", "x", "in", "scandir", "(", "os", ".", "path", ".", "join", "(", "src_dir", ")", ")", ":", "if", "x", ".", "is_dir", "(", "follow_symlinks", "=", "False", ")", ":", "for", "x", "in", "iter_paths"...
Function that recursively locates files within folder Note: scandir does not guarantee ordering :param src_dir: string for directory to be parsed through :return an iterable of DirEntry objects all files within the src_dir
[ "Function", "that", "recursively", "locates", "files", "within", "folder", "Note", ":", "scandir", "does", "not", "guarantee", "ordering", ":", "param", "src_dir", ":", "string", "for", "directory", "to", "be", "parsed", "through", ":", "return", "an", "iterab...
python
train
35.076923
shmir/PyIxExplorer
ixexplorer/ixe_app.py
https://github.com/shmir/PyIxExplorer/blob/d6946b9ce0e8961507cc912062e10c365d4beee2/ixexplorer/ixe_app.py#L156-L174
def start_transmit(self, blocking=False, start_packet_groups=True, *ports): """ Start transmit on ports. :param blocking: True - wait for traffic end, False - return after traffic start. :param start_packet_groups: True - clear time stamps and start collecting packet groups stats, False - don't...
[ "def", "start_transmit", "(", "self", ",", "blocking", "=", "False", ",", "start_packet_groups", "=", "True", ",", "*", "ports", ")", ":", "port_list", "=", "self", ".", "set_ports_list", "(", "*", "ports", ")", "if", "start_packet_groups", ":", "port_list_f...
Start transmit on ports. :param blocking: True - wait for traffic end, False - return after traffic start. :param start_packet_groups: True - clear time stamps and start collecting packet groups stats, False - don't. :param ports: list of ports to start traffic on, if empty start on all ports.
[ "Start", "transmit", "on", "ports", "." ]
python
train
50.789474
johnnoone/aioconsul
aioconsul/client/kv_endpoint.py
https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/kv_endpoint.py#L542-L579
async def execute(self, dc=None, token=None): """Execute stored operations Parameters: dc (str): Specify datacenter that will be used. Defaults to the agent's local datacenter. token (ObjectID): Token ID Returns: Collection: Results of o...
[ "async", "def", "execute", "(", "self", ",", "dc", "=", "None", ",", "token", "=", "None", ")", ":", "token_id", "=", "extract_attr", "(", "token", ",", "keys", "=", "[", "\"ID\"", "]", ")", "try", ":", "response", "=", "await", "self", ".", "_api"...
Execute stored operations Parameters: dc (str): Specify datacenter that will be used. Defaults to the agent's local datacenter. token (ObjectID): Token ID Returns: Collection: Results of operations. Raises: TransactionError: ...
[ "Execute", "stored", "operations" ]
python
train
34.447368
ml4ai/delphi
scripts/process_climis_unicef_ieconomics_data.py
https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/scripts/process_climis_unicef_ieconomics_data.py#L154-L205
def process_climis_crop_production_data(data_dir: str): """ Process CliMIS crop production data """ climis_crop_production_csvs = glob( "{data_dir}/Climis South Sudan Crop Production Data/" "Crops_EstimatedProductionConsumptionBalance*.csv" ) state_county_df = pd.read_csv( f"{da...
[ "def", "process_climis_crop_production_data", "(", "data_dir", ":", "str", ")", ":", "climis_crop_production_csvs", "=", "glob", "(", "\"{data_dir}/Climis South Sudan Crop Production Data/\"", "\"Crops_EstimatedProductionConsumptionBalance*.csv\"", ")", "state_county_df", "=", "pd"...
Process CliMIS crop production data
[ "Process", "CliMIS", "crop", "production", "data" ]
python
train
35.480769
pycontribs/pyrax
pyrax/base_identity.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/base_identity.py#L926-L939
def delete_user(self, user): """ ADMIN ONLY. Removes the user from the system. There is no 'undo' available, so you should be certain that the user specified is the user you wish to delete. """ user_id = utils.get_id(user) uri = "users/%s" % user_id resp, ...
[ "def", "delete_user", "(", "self", ",", "user", ")", ":", "user_id", "=", "utils", ".", "get_id", "(", "user", ")", "uri", "=", "\"users/%s\"", "%", "user_id", "resp", ",", "resp_body", "=", "self", ".", "method_delete", "(", "uri", ")", "if", "resp", ...
ADMIN ONLY. Removes the user from the system. There is no 'undo' available, so you should be certain that the user specified is the user you wish to delete.
[ "ADMIN", "ONLY", ".", "Removes", "the", "user", "from", "the", "system", ".", "There", "is", "no", "undo", "available", "so", "you", "should", "be", "certain", "that", "the", "user", "specified", "is", "the", "user", "you", "wish", "to", "delete", "." ]
python
train
43.071429
ejeschke/ginga
ginga/table/AstroTable.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/table/AstroTable.py#L99-L107
def set_data(self, data_ap, metadata=None): """Use this method to SHARE (not copy) the incoming table. """ self._data = data_ap if metadata: self.update_metadata(metadata) self.make_callback('modified')
[ "def", "set_data", "(", "self", ",", "data_ap", ",", "metadata", "=", "None", ")", ":", "self", ".", "_data", "=", "data_ap", "if", "metadata", ":", "self", ".", "update_metadata", "(", "metadata", ")", "self", ".", "make_callback", "(", "'modified'", ")...
Use this method to SHARE (not copy) the incoming table.
[ "Use", "this", "method", "to", "SHARE", "(", "not", "copy", ")", "the", "incoming", "table", "." ]
python
train
27.555556
tmr232/Sark
sark/code/function.py
https://github.com/tmr232/Sark/blob/bee62879c2aea553a3924d887e2b30f2a6008581/sark/code/function.py#L234-L251
def xrefs_from(self): """Xrefs from the function. This includes the xrefs from every line in the function, as `Xref` objects. Xrefs are filtered to exclude code references that are internal to the function. This means that every xrefs to the function's code will NOT be returned (yet, re...
[ "def", "xrefs_from", "(", "self", ")", ":", "for", "line", "in", "self", ".", "lines", ":", "for", "xref", "in", "line", ".", "xrefs_from", ":", "if", "xref", ".", "type", ".", "is_flow", ":", "continue", "if", "xref", ".", "to", "in", "self", "and...
Xrefs from the function. This includes the xrefs from every line in the function, as `Xref` objects. Xrefs are filtered to exclude code references that are internal to the function. This means that every xrefs to the function's code will NOT be returned (yet, references to the function'...
[ "Xrefs", "from", "the", "function", "." ]
python
train
39.277778
pvlib/pvlib-python
pvlib/irradiance.py
https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/irradiance.py#L448-L505
def poa_components(aoi, dni, poa_sky_diffuse, poa_ground_diffuse): r''' Determine in-plane irradiance components. Combines DNI with sky diffuse and ground-reflected irradiance to calculate total, direct and diffuse irradiance components in the plane of array. Parameters ---------- aoi : nu...
[ "def", "poa_components", "(", "aoi", ",", "dni", ",", "poa_sky_diffuse", ",", "poa_ground_diffuse", ")", ":", "poa_direct", "=", "np", ".", "maximum", "(", "dni", "*", "np", ".", "cos", "(", "np", ".", "radians", "(", "aoi", ")", ")", ",", "0", ")", ...
r''' Determine in-plane irradiance components. Combines DNI with sky diffuse and ground-reflected irradiance to calculate total, direct and diffuse irradiance components in the plane of array. Parameters ---------- aoi : numeric Angle of incidence of solar rays with respect to the modu...
[ "r", "Determine", "in", "-", "plane", "irradiance", "components", "." ]
python
train
33.724138
spyder-ide/spyder
spyder/widgets/dock.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/dock.py#L44-L53
def tab_pressed(self, event): """Method called when a tab from a QTabBar has been pressed.""" self.from_index = self.dock_tabbar.tabAt(event.pos()) self.dock_tabbar.setCurrentIndex(self.from_index) if event.button() == Qt.RightButton: if self.from_index == -1: ...
[ "def", "tab_pressed", "(", "self", ",", "event", ")", ":", "self", ".", "from_index", "=", "self", ".", "dock_tabbar", ".", "tabAt", "(", "event", ".", "pos", "(", ")", ")", "self", ".", "dock_tabbar", ".", "setCurrentIndex", "(", "self", ".", "from_in...
Method called when a tab from a QTabBar has been pressed.
[ "Method", "called", "when", "a", "tab", "from", "a", "QTabBar", "has", "been", "pressed", "." ]
python
train
40.1
cjdrake/pyeda
pyeda/boolalg/bfarray.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/bfarray.py#L1001-L1007
def _uint2farray(ftype, num, length=None): """Convert an unsigned integer to an farray.""" if num < 0: raise ValueError("expected num >= 0") else: objs = _uint2objs(ftype, num, length) return farray(objs)
[ "def", "_uint2farray", "(", "ftype", ",", "num", ",", "length", "=", "None", ")", ":", "if", "num", "<", "0", ":", "raise", "ValueError", "(", "\"expected num >= 0\"", ")", "else", ":", "objs", "=", "_uint2objs", "(", "ftype", ",", "num", ",", "length"...
Convert an unsigned integer to an farray.
[ "Convert", "an", "unsigned", "integer", "to", "an", "farray", "." ]
python
train
33.428571
erikrose/more-itertools
more_itertools/more.py
https://github.com/erikrose/more-itertools/blob/6a91b4e25c8e12fcf9fc2b53cf8ee0fba293e6f9/more_itertools/more.py#L1531-L1603
def numeric_range(*args): """An extension of the built-in ``range()`` function whose arguments can be any orderable numeric type. With only *stop* specified, *start* defaults to ``0`` and *step* defaults to ``1``. The output items will match the type of *stop*: >>> list(numeric_range(3.5)) ...
[ "def", "numeric_range", "(", "*", "args", ")", ":", "argc", "=", "len", "(", "args", ")", "if", "argc", "==", "1", ":", "stop", ",", "=", "args", "start", "=", "type", "(", "stop", ")", "(", "0", ")", "step", "=", "1", "elif", "argc", "==", "...
An extension of the built-in ``range()`` function whose arguments can be any orderable numeric type. With only *stop* specified, *start* defaults to ``0`` and *step* defaults to ``1``. The output items will match the type of *stop*: >>> list(numeric_range(3.5)) [0.0, 1.0, 2.0, 3.0] Wi...
[ "An", "extension", "of", "the", "built", "-", "in", "range", "()", "function", "whose", "arguments", "can", "be", "any", "orderable", "numeric", "type", "." ]
python
train
33.643836
todstoychev/signal-dispatcher
signal_dispatcher/signal_dispatcher.py
https://github.com/todstoychev/signal-dispatcher/blob/77131d119045973d65434abbcd6accdfa9cc327a/signal_dispatcher/signal_dispatcher.py#L26-L37
def register_handler(alias: str, handler: callable): """ Used to register handler at the dispatcher. :param alias: Signal alias to match handler to. :param handler: Handler. Some callable. :return: """ if SignalDispatcher.handlers.get(alias) is None: ...
[ "def", "register_handler", "(", "alias", ":", "str", ",", "handler", ":", "callable", ")", ":", "if", "SignalDispatcher", ".", "handlers", ".", "get", "(", "alias", ")", "is", "None", ":", "SignalDispatcher", ".", "handlers", "[", "alias", "]", "=", "[",...
Used to register handler at the dispatcher. :param alias: Signal alias to match handler to. :param handler: Handler. Some callable. :return:
[ "Used", "to", "register", "handler", "at", "the", "dispatcher", "." ]
python
train
36
vaab/colour
colour.py
https://github.com/vaab/colour/blob/11f138eb7841d2045160b378a2eec0c2321144c0/colour.py#L370-L475
def rgb2hsl(rgb): """Convert RGB representation towards HSL :param r: Red amount (float between 0 and 1) :param g: Green amount (float between 0 and 1) :param b: Blue amount (float between 0 and 1) :rtype: 3-uple for HSL values in float between 0 and 1 This algorithm came from: http://www....
[ "def", "rgb2hsl", "(", "rgb", ")", ":", "r", ",", "g", ",", "b", "=", "[", "float", "(", "v", ")", "for", "v", "in", "rgb", "]", "for", "name", ",", "v", "in", "{", "'Red'", ":", "r", ",", "'Green'", ":", "g", ",", "'Blue'", ":", "b", "}"...
Convert RGB representation towards HSL :param r: Red amount (float between 0 and 1) :param g: Green amount (float between 0 and 1) :param b: Blue amount (float between 0 and 1) :rtype: 3-uple for HSL values in float between 0 and 1 This algorithm came from: http://www.easyrgb.com/index.php?X=M...
[ "Convert", "RGB", "representation", "towards", "HSL" ]
python
train
26.377358
wagtail/django-modelcluster
modelcluster/models.py
https://github.com/wagtail/django-modelcluster/blob/bfc8bd755af0ddd49e2aee2f2ca126921573d38b/modelcluster/models.py#L38-L54
def get_serializable_data_for_fields(model): """ Return a serialised version of the model's fields which exist as local database columns (i.e. excluding m2m and incoming foreign key relations) """ pk_field = model._meta.pk # If model is a child via multitable inheritance, use parent's pk whi...
[ "def", "get_serializable_data_for_fields", "(", "model", ")", ":", "pk_field", "=", "model", ".", "_meta", ".", "pk", "# If model is a child via multitable inheritance, use parent's pk", "while", "pk_field", ".", "remote_field", "and", "pk_field", ".", "remote_field", "."...
Return a serialised version of the model's fields which exist as local database columns (i.e. excluding m2m and incoming foreign key relations)
[ "Return", "a", "serialised", "version", "of", "the", "model", "s", "fields", "which", "exist", "as", "local", "database", "columns", "(", "i", ".", "e", ".", "excluding", "m2m", "and", "incoming", "foreign", "key", "relations", ")" ]
python
test
36.294118
openstack/networking-cisco
networking_cisco/db/migration/alembic_migrations/versions/mitaka/expand/9148d96f9b39_rename_tenantid_to_projectid.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/db/migration/alembic_migrations/versions/mitaka/expand/9148d96f9b39_rename_tenantid_to_projectid.py#L81-L96
def get_data(): """Returns combined list of tuples: [(table, column)]. List is built, based on retrieved tables, where column with name ``tenant_id`` exists. """ output = [] tables = get_tables() for table in tables: columns = get_columns(table) for column in columns: ...
[ "def", "get_data", "(", ")", ":", "output", "=", "[", "]", "tables", "=", "get_tables", "(", ")", "for", "table", "in", "tables", ":", "columns", "=", "get_columns", "(", "table", ")", "for", "column", "in", "columns", ":", "if", "column", "[", "'nam...
Returns combined list of tuples: [(table, column)]. List is built, based on retrieved tables, where column with name ``tenant_id`` exists.
[ "Returns", "combined", "list", "of", "tuples", ":", "[", "(", "table", "column", ")", "]", ".", "List", "is", "built", "based", "on", "retrieved", "tables", "where", "column", "with", "name", "tenant_id", "exists", "." ]
python
train
25.6875
metagriffin/fso
fso/filesystemoverlay.py
https://github.com/metagriffin/fso/blob/c37701fbfdfde359a2044eb9420abe569a7b35e4/fso/filesystemoverlay.py#L321-L328
def _stat(self, path): '''IMPORTANT: expects `path`'s parent to already be deref()'erenced.''' if path not in self.entries: return OverlayStat(*self.originals['os:stat'](path)[:10], st_overlay=0) st = self.entries[path].stat if stat.S_ISLNK(st.st_mode): return self._stat(self.deref(path)) ...
[ "def", "_stat", "(", "self", ",", "path", ")", ":", "if", "path", "not", "in", "self", ".", "entries", ":", "return", "OverlayStat", "(", "*", "self", ".", "originals", "[", "'os:stat'", "]", "(", "path", ")", "[", ":", "10", "]", ",", "st_overlay"...
IMPORTANT: expects `path`'s parent to already be deref()'erenced.
[ "IMPORTANT", ":", "expects", "path", "s", "parent", "to", "already", "be", "deref", "()", "erenced", "." ]
python
valid
40.5
taborlab/FlowCal
FlowCal/io.py
https://github.com/taborlab/FlowCal/blob/031a7af82acb1d46879a8e384a1a00f27f0bdc7a/FlowCal/io.py#L1318-L1358
def range(self, channels=None): """ Get the range of the specified channel(s). The range is a two-element list specifying the smallest and largest values that an event in a channel should have. Note that with floating point data, some events could have values outside the ...
[ "def", "range", "(", "self", ",", "channels", "=", "None", ")", ":", "# Check default", "if", "channels", "is", "None", ":", "channels", "=", "self", ".", "_channels", "# Get numerical indices of channels", "channels", "=", "self", ".", "_name_to_index", "(", ...
Get the range of the specified channel(s). The range is a two-element list specifying the smallest and largest values that an event in a channel should have. Note that with floating point data, some events could have values outside the range in either direction due to instrument compens...
[ "Get", "the", "range", "of", "the", "specified", "channel", "(", "s", ")", "." ]
python
train
34.073171
bram85/topydo
topydo/lib/ListFormat.py
https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/lib/ListFormat.py#L99-L109
def _truncate(p_str, p_repl): """ Returns p_str with truncated and ended with '...' version of p_repl. Place of the truncation is calculated depending on p_max_width. """ # 4 is for '...' and an extra space at the end text_lim = _columns() - len(escape_ansi(p_str)) - 4 truncated_str = re.su...
[ "def", "_truncate", "(", "p_str", ",", "p_repl", ")", ":", "# 4 is for '...' and an extra space at the end", "text_lim", "=", "_columns", "(", ")", "-", "len", "(", "escape_ansi", "(", "p_str", ")", ")", "-", "4", "truncated_str", "=", "re", ".", "sub", "(",...
Returns p_str with truncated and ended with '...' version of p_repl. Place of the truncation is calculated depending on p_max_width.
[ "Returns", "p_str", "with", "truncated", "and", "ended", "with", "...", "version", "of", "p_repl", "." ]
python
train
35.454545
meyersj/geotweet
geotweet/osm.py
https://github.com/meyersj/geotweet/blob/1a6b55f98adf34d1b91f172d9187d599616412d9/geotweet/osm.py#L86-L89
def url2tmp(self, root, url): """ convert url path to filename """ filename = url.rsplit('/', 1)[-1] return os.path.join(root, filename)
[ "def", "url2tmp", "(", "self", ",", "root", ",", "url", ")", ":", "filename", "=", "url", ".", "rsplit", "(", "'/'", ",", "1", ")", "[", "-", "1", "]", "return", "os", ".", "path", ".", "join", "(", "root", ",", "filename", ")" ]
convert url path to filename
[ "convert", "url", "path", "to", "filename" ]
python
train
39.25
biocore/burrito-fillings
bfillings/clearcut.py
https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/clearcut.py#L226-L291
def build_tree_from_alignment(aln, moltype=DNA, best_tree=False, params={},\ working_dir='/tmp'): """Returns a tree from Alignment object aln. aln: an cogent.core.alignment.Alignment object, or data that can be used to build one. - Clearcut only accepts aligned sequences. Alignment object use...
[ "def", "build_tree_from_alignment", "(", "aln", ",", "moltype", "=", "DNA", ",", "best_tree", "=", "False", ",", "params", "=", "{", "}", ",", "working_dir", "=", "'/tmp'", ")", ":", "params", "[", "'--out'", "]", "=", "get_tmp_filename", "(", "working_dir...
Returns a tree from Alignment object aln. aln: an cogent.core.alignment.Alignment object, or data that can be used to build one. - Clearcut only accepts aligned sequences. Alignment object used to handle unaligned sequences. moltype: a cogent.core.moltype object. - NOTE: If molty...
[ "Returns", "a", "tree", "from", "Alignment", "object", "aln", "." ]
python
train
34
bitcraze/crazyflie-lib-python
cflib/bootloader/cloader.py
https://github.com/bitcraze/crazyflie-lib-python/blob/f6ebb4eb315bbe6e02db518936ac17fb615b2af8/cflib/bootloader/cloader.py#L336-L361
def read_flash(self, addr=0xFF, page=0x00): """Read back a flash page from the Crazyflie and return it""" buff = bytearray() page_size = self.targets[addr].page_size for i in range(0, int(math.ceil(page_size / 25.0))): pk = None retry_counter = 5 whi...
[ "def", "read_flash", "(", "self", ",", "addr", "=", "0xFF", ",", "page", "=", "0x00", ")", ":", "buff", "=", "bytearray", "(", ")", "page_size", "=", "self", ".", "targets", "[", "addr", "]", ".", "page_size", "for", "i", "in", "range", "(", "0", ...
Read back a flash page from the Crazyflie and return it
[ "Read", "back", "a", "flash", "page", "from", "the", "Crazyflie", "and", "return", "it" ]
python
train
35.884615
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/scrappers/grada_cz.py
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/grada_cz.py#L54-L80
def _parse_title_url(html_chunk): """ Parse title/name of the book and URL of the book. Args: html_chunk (obj): HTMLElement containing slice of the page with details. Returns: tuple: (title, url), both as strings. """ title = html_chunk.find("div", {"class": "comment"}) if...
[ "def", "_parse_title_url", "(", "html_chunk", ")", ":", "title", "=", "html_chunk", ".", "find", "(", "\"div\"", ",", "{", "\"class\"", ":", "\"comment\"", "}", ")", "if", "not", "title", ":", "return", "_parse_alt_title", "(", "html_chunk", ")", ",", "Non...
Parse title/name of the book and URL of the book. Args: html_chunk (obj): HTMLElement containing slice of the page with details. Returns: tuple: (title, url), both as strings.
[ "Parse", "title", "/", "name", "of", "the", "book", "and", "URL", "of", "the", "book", "." ]
python
train
26.111111
pixelogik/NearPy
nearpy/engine.py
https://github.com/pixelogik/NearPy/blob/1b534b864d320d875508e95cd2b76b6d8c07a90b/nearpy/engine.py#L180-L191
def _get_candidates(self, v): """ Collect candidates from all buckets from all hashes """ candidates = [] for lshash in self.lshashes: for bucket_key in lshash.hash_vector(v, querying=True): bucket_content = self.storage.get_bucket( lshash.hash_nam...
[ "def", "_get_candidates", "(", "self", ",", "v", ")", ":", "candidates", "=", "[", "]", "for", "lshash", "in", "self", ".", "lshashes", ":", "for", "bucket_key", "in", "lshash", ".", "hash_vector", "(", "v", ",", "querying", "=", "True", ")", ":", "b...
Collect candidates from all buckets from all hashes
[ "Collect", "candidates", "from", "all", "buckets", "from", "all", "hashes" ]
python
train
43
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/service_reflection.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/service_reflection.py#L189-L203
def _GetResponseClass(self, method_descriptor): """Returns the class of the response protocol message. Args: method_descriptor: Descriptor of the method for which to return the response protocol message class. Returns: A class that represents the output protocol message of the specifie...
[ "def", "_GetResponseClass", "(", "self", ",", "method_descriptor", ")", ":", "if", "method_descriptor", ".", "containing_service", "!=", "self", ".", "descriptor", ":", "raise", "RuntimeError", "(", "'GetResponseClass() given method descriptor for wrong service type.'", ")"...
Returns the class of the response protocol message. Args: method_descriptor: Descriptor of the method for which to return the response protocol message class. Returns: A class that represents the output protocol message of the specified method.
[ "Returns", "the", "class", "of", "the", "response", "protocol", "message", "." ]
python
train
37.066667
jtambasco/modesolverpy
modesolverpy/structure_base.py
https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/structure_base.py#L392-L415
def change_wavelength(self, wavelength): ''' Changes the wavelength of the structure. This will affect the mode solver and potentially the refractive indices used (provided functions were provided as refractive indices). Args: wavelength (float): The new wav...
[ "def", "change_wavelength", "(", "self", ",", "wavelength", ")", ":", "for", "name", ",", "slab", "in", "self", ".", "slabs", ".", "items", "(", ")", ":", "const_args", "=", "slab", ".", "_const_args", "mat_args", "=", "slab", ".", "_mat_params", "const_...
Changes the wavelength of the structure. This will affect the mode solver and potentially the refractive indices used (provided functions were provided as refractive indices). Args: wavelength (float): The new wavelength.
[ "Changes", "the", "wavelength", "of", "the", "structure", "." ]
python
train
27.625
CalebBell/thermo
thermo/viscosity.py
https://github.com/CalebBell/thermo/blob/3857ed023a3e64fd3039a32d53576c24990ef1c3/thermo/viscosity.py#L1017-L1072
def Yoon_Thodos(T, Tc, Pc, MW): r'''Calculates the viscosity of a gas using an emperical formula developed in [1]_. .. math:: \eta \xi \times 10^8 = 46.10 T_r^{0.618} - 20.40 \exp(-0.449T_r) + 1 9.40\exp(-4.058T_r)+1 \xi = 2173.424 T_c^{1/6} MW^{-1/2} P_c^{-2/3} Parameters ...
[ "def", "Yoon_Thodos", "(", "T", ",", "Tc", ",", "Pc", ",", "MW", ")", ":", "Tr", "=", "T", "/", "Tc", "xi", "=", "2173.4241", "*", "Tc", "**", "(", "1", "/", "6.", ")", "/", "(", "MW", "**", "0.5", "*", "Pc", "**", "(", "2", "/", "3.", ...
r'''Calculates the viscosity of a gas using an emperical formula developed in [1]_. .. math:: \eta \xi \times 10^8 = 46.10 T_r^{0.618} - 20.40 \exp(-0.449T_r) + 1 9.40\exp(-4.058T_r)+1 \xi = 2173.424 T_c^{1/6} MW^{-1/2} P_c^{-2/3} Parameters ---------- T : float Te...
[ "r", "Calculates", "the", "viscosity", "of", "a", "gas", "using", "an", "emperical", "formula", "developed", "in", "[", "1", "]", "_", "." ]
python
valid
28.214286
j3ffhubb/pymarshal
pymarshal/api_docs/routes.py
https://github.com/j3ffhubb/pymarshal/blob/42cd1cccfabfdce5af633358a641fcd5183ee192/pymarshal/api_docs/routes.py#L287-L324
def factory( description="", codes=[200], response_example=None, response_ctor=None, ): """ desc: Describes a response to an API call args: - name: description type: str desc: A description of the condition that ca...
[ "def", "factory", "(", "description", "=", "\"\"", ",", "codes", "=", "[", "200", "]", ",", "response_example", "=", "None", ",", "response_ctor", "=", "None", ",", ")", ":", "return", "RouteMethodResponse", "(", "description", ",", "codes", ",", "response...
desc: Describes a response to an API call args: - name: description type: str desc: A description of the condition that causes this response required: false default: "" - name: codes type: int ...
[ "desc", ":", "Describes", "a", "response", "to", "an", "API", "call", "args", ":", "-", "name", ":", "description", "type", ":", "str", "desc", ":", "A", "description", "of", "the", "condition", "that", "causes", "this", "response", "required", ":", "fal...
python
train
30.736842
andreasjansson/head-in-the-clouds
headintheclouds/dependencies/PyDbLite/PyDbLite_SQL.py
https://github.com/andreasjansson/head-in-the-clouds/blob/32c1d00d01036834dc94368e7f38b0afd3f7a82f/headintheclouds/dependencies/PyDbLite/PyDbLite_SQL.py#L147-L152
def _make_record(self,row): """Make a record dictionary from the result of a fetch_""" res = dict(zip(self.all_fields,row)) for k in self.types: res[k] = self.types[k](res[k]) return res
[ "def", "_make_record", "(", "self", ",", "row", ")", ":", "res", "=", "dict", "(", "zip", "(", "self", ".", "all_fields", ",", "row", ")", ")", "for", "k", "in", "self", ".", "types", ":", "res", "[", "k", "]", "=", "self", ".", "types", "[", ...
Make a record dictionary from the result of a fetch_
[ "Make", "a", "record", "dictionary", "from", "the", "result", "of", "a", "fetch_" ]
python
train
38.333333
jonathf/chaospy
chaospy/distributions/operators/negative.py
https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/distributions/operators/negative.py#L48-L50
def _pdf(self, xloc, dist, cache): """Probability density function.""" return evaluation.evaluate_density(dist, -xloc, cache=cache)
[ "def", "_pdf", "(", "self", ",", "xloc", ",", "dist", ",", "cache", ")", ":", "return", "evaluation", ".", "evaluate_density", "(", "dist", ",", "-", "xloc", ",", "cache", "=", "cache", ")" ]
Probability density function.
[ "Probability", "density", "function", "." ]
python
train
48.333333
rigetti/grove
grove/pyqaoa/numpartition_qaoa.py
https://github.com/rigetti/grove/blob/dc6bf6ec63e8c435fe52b1e00f707d5ce4cdb9b3/grove/pyqaoa/numpartition_qaoa.py#L25-L57
def numpart_qaoa(asset_list, A=1.0, minimizer_kwargs=None, steps=1): """ generate number partition driver and cost functions :param asset_list: list to binary partition :param A: (float) optional constant for level separation. Default=1. :param minimizer_kwargs: Arguments for the QAOA minimizer ...
[ "def", "numpart_qaoa", "(", "asset_list", ",", "A", "=", "1.0", ",", "minimizer_kwargs", "=", "None", ",", "steps", "=", "1", ")", ":", "cost_operators", "=", "[", "]", "ref_operators", "=", "[", "]", "for", "ii", "in", "range", "(", "len", "(", "ass...
generate number partition driver and cost functions :param asset_list: list to binary partition :param A: (float) optional constant for level separation. Default=1. :param minimizer_kwargs: Arguments for the QAOA minimizer :param steps: (int) number of steps approximating the solution.
[ "generate", "number", "partition", "driver", "and", "cost", "functions" ]
python
train
42.606061
senaite/senaite.core
bika/lims/content/organisation.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/content/organisation.py#L174-L179
def Title(self): """Return the name of the Organisation """ field = self.getField("Name") field = field and field.get(self) or "" return safe_unicode(field).encode("utf-8")
[ "def", "Title", "(", "self", ")", ":", "field", "=", "self", ".", "getField", "(", "\"Name\"", ")", "field", "=", "field", "and", "field", ".", "get", "(", "self", ")", "or", "\"\"", "return", "safe_unicode", "(", "field", ")", ".", "encode", "(", ...
Return the name of the Organisation
[ "Return", "the", "name", "of", "the", "Organisation" ]
python
train
34.5
django-import-export/django-import-export
import_export/resources.py
https://github.com/django-import-export/django-import-export/blob/127f00d03fd0ad282615b064b7f444a639e6ff0c/import_export/resources.py#L359-L376
def import_obj(self, obj, data, dry_run): """ Traverses every field in this Resource and calls :meth:`~import_export.resources.Resource.import_field`. If ``import_field()`` results in a ``ValueError`` being raised for one of more fields, those errors are captured and reraised as ...
[ "def", "import_obj", "(", "self", ",", "obj", ",", "data", ",", "dry_run", ")", ":", "errors", "=", "{", "}", "for", "field", "in", "self", ".", "get_import_fields", "(", ")", ":", "if", "isinstance", "(", "field", ".", "widget", ",", "widgets", ".",...
Traverses every field in this Resource and calls :meth:`~import_export.resources.Resource.import_field`. If ``import_field()`` results in a ``ValueError`` being raised for one of more fields, those errors are captured and reraised as a single, multi-field ValidationError.
[ "Traverses", "every", "field", "in", "this", "Resource", "and", "calls", ":", "meth", ":", "~import_export", ".", "resources", ".", "Resource", ".", "import_field", ".", "If", "import_field", "()", "results", "in", "a", "ValueError", "being", "raised", "for", ...
python
train
43.722222
samjabrahams/anchorhub
anchorhub/collector.py
https://github.com/samjabrahams/anchorhub/blob/5ade359b08297d4003a5f477389c01de9e634b54/anchorhub/collector.py#L49-L76
def collect(self, file_paths): """ Takes in a list of string file_paths, and parses through them using the converter, strategies, and switches defined at object initialization. It returns two dictionaries- the first maps from file_path strings to inner dictionaries, and ...
[ "def", "collect", "(", "self", ",", "file_paths", ")", ":", "for", "file_path", "in", "file_paths", ":", "self", ".", "_anchors", "[", "file_path", "]", ",", "d", "=", "self", ".", "collect_single_file", "(", "file_path", ")", "if", "len", "(", "d", ")...
Takes in a list of string file_paths, and parses through them using the converter, strategies, and switches defined at object initialization. It returns two dictionaries- the first maps from file_path strings to inner dictionaries, and those inner dictionaries map from AnchorHub...
[ "Takes", "in", "a", "list", "of", "string", "file_paths", "and", "parses", "through", "them", "using", "the", "converter", "strategies", "and", "switches", "defined", "at", "object", "initialization", "." ]
python
train
46.25
CivicSpleen/ambry
ambry/orm/partition.py
https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/partition.py#L1330-L1385
def dimension_set(self, p_dim, s_dim=None, dimensions=None, extant=set()): """ Return a dict that describes the combination of one or two dimensions, for a plot :param p_dim: :param s_dim: :param dimensions: :param extant: :return: """ if not dim...
[ "def", "dimension_set", "(", "self", ",", "p_dim", ",", "s_dim", "=", "None", ",", "dimensions", "=", "None", ",", "extant", "=", "set", "(", ")", ")", ":", "if", "not", "dimensions", ":", "dimensions", "=", "self", ".", "primary_dimensions", "key", "=...
Return a dict that describes the combination of one or two dimensions, for a plot :param p_dim: :param s_dim: :param dimensions: :param extant: :return:
[ "Return", "a", "dict", "that", "describes", "the", "combination", "of", "one", "or", "two", "dimensions", "for", "a", "plot" ]
python
train
28.696429
gem/oq-engine
openquake/commonlib/oqvalidation.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L176-L183
def get_reqv(self): """ :returns: an instance of class:`RjbEquivalent` if reqv_hdf5 is set """ if 'reqv' not in self.inputs: return return {key: valid.RjbEquivalent(value) for key, value in self.inputs['reqv'].items()}
[ "def", "get_reqv", "(", "self", ")", ":", "if", "'reqv'", "not", "in", "self", ".", "inputs", ":", "return", "return", "{", "key", ":", "valid", ".", "RjbEquivalent", "(", "value", ")", "for", "key", ",", "value", "in", "self", ".", "inputs", "[", ...
:returns: an instance of class:`RjbEquivalent` if reqv_hdf5 is set
[ ":", "returns", ":", "an", "instance", "of", "class", ":", "RjbEquivalent", "if", "reqv_hdf5", "is", "set" ]
python
train
34.875
wndhydrnt/python-oauth2
oauth2/store/redisdb.py
https://github.com/wndhydrnt/python-oauth2/blob/abe3bf5f27bda2ff737cab387b040e2e6e85c2e2/oauth2/store/redisdb.py#L99-L114
def save_token(self, access_token): """ Stores the access token and additional data in redis. See :class:`oauth2.store.AccessTokenStore`. """ self.write(access_token.token, access_token.__dict__) unique_token_key = self._unique_token_key(access_token.client_id, ...
[ "def", "save_token", "(", "self", ",", "access_token", ")", ":", "self", ".", "write", "(", "access_token", ".", "token", ",", "access_token", ".", "__dict__", ")", "unique_token_key", "=", "self", ".", "_unique_token_key", "(", "access_token", ".", "client_id...
Stores the access token and additional data in redis. See :class:`oauth2.store.AccessTokenStore`.
[ "Stores", "the", "access", "token", "and", "additional", "data", "in", "redis", "." ]
python
train
39.375
jaredLunde/redis_structures
redis_structures/__init__.py
https://github.com/jaredLunde/redis_structures/blob/b9cce5f5c85db5e12c292633ff8d04e3ae053294/redis_structures/__init__.py#L703-L705
def size(self): """ -> #int number of keys in this instance """ return int(self._client.hget(self._bucket_key, self.key_prefix) or 0)
[ "def", "size", "(", "self", ")", ":", "return", "int", "(", "self", ".", "_client", ".", "hget", "(", "self", ".", "_bucket_key", ",", "self", ".", "key_prefix", ")", "or", "0", ")" ]
-> #int number of keys in this instance
[ "-", ">", "#int", "number", "of", "keys", "in", "this", "instance" ]
python
train
49
T-002/pycast
pycast/methods/exponentialsmoothing.py
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/methods/exponentialsmoothing.py#L453-L467
def initialTrendSmoothingFactors(self, timeSeries): """ Calculate the initial Trend smoothing Factor b0. Explanation: http://en.wikipedia.org/wiki/Exponential_smoothing#Triple_exponential_smoothing :return: Returns the initial trend smoothing factor b0 """ result...
[ "def", "initialTrendSmoothingFactors", "(", "self", ",", "timeSeries", ")", ":", "result", "=", "0.0", "seasonLength", "=", "self", ".", "get_parameter", "(", "\"seasonLength\"", ")", "k", "=", "min", "(", "len", "(", "timeSeries", ")", "-", "seasonLength", ...
Calculate the initial Trend smoothing Factor b0. Explanation: http://en.wikipedia.org/wiki/Exponential_smoothing#Triple_exponential_smoothing :return: Returns the initial trend smoothing factor b0
[ "Calculate", "the", "initial", "Trend", "smoothing", "Factor", "b0", "." ]
python
train
44.266667
wavefrontHQ/python-client
wavefront_api_client/api/user_api.py
https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/user_api.py#L1220-L1241
def update_user(self, id, **kwargs): # noqa: E501 """Update user with given user groups and permissions. # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.updat...
[ "def", "update_user", "(", "self", ",", "id", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "update_user_with...
Update user with given user groups and permissions. # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_user(id, async_req=True) >>> result = thread.get() ...
[ "Update", "user", "with", "given", "user", "groups", "and", "permissions", ".", "#", "noqa", ":", "E501" ]
python
train
48.5
dw/mitogen
mitogen/service.py
https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/mitogen/service.py#L687-L694
def propagate_paths_and_modules(self, context, paths, modules): """ One size fits all method to ensure a target context has been preloaded with a set of small files and Python modules. """ for path in paths: self.propagate_to(context, mitogen.core.to_text(path)) ...
[ "def", "propagate_paths_and_modules", "(", "self", ",", "context", ",", "paths", ",", "modules", ")", ":", "for", "path", "in", "paths", ":", "self", ".", "propagate_to", "(", "context", ",", "mitogen", ".", "core", ".", "to_text", "(", "path", ")", ")",...
One size fits all method to ensure a target context has been preloaded with a set of small files and Python modules.
[ "One", "size", "fits", "all", "method", "to", "ensure", "a", "target", "context", "has", "been", "preloaded", "with", "a", "set", "of", "small", "files", "and", "Python", "modules", "." ]
python
train
46.375
bokeh/bokeh
bokeh/util/serialization.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/util/serialization.py#L352-L384
def transform_series(series, force_list=False, buffers=None): ''' Transforms a Pandas series into serialized form Args: series (pd.Series) : the Pandas series to transform force_list (bool, optional) : whether to only output to standard lists This function can encode some dtypes usi...
[ "def", "transform_series", "(", "series", ",", "force_list", "=", "False", ",", "buffers", "=", "None", ")", ":", "# not checking for pd here, this function should only be called if it", "# is already known that series is a Pandas Series type", "if", "isinstance", "(", "series"...
Transforms a Pandas series into serialized form Args: series (pd.Series) : the Pandas series to transform force_list (bool, optional) : whether to only output to standard lists This function can encode some dtypes using a binary encoding, but setting this argument to True wi...
[ "Transforms", "a", "Pandas", "series", "into", "serialized", "form" ]
python
train
40.818182
tensorflow/tensor2tensor
tensor2tensor/layers/common_attention.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_attention.py#L1104-L1118
def combine_first_two_dimensions(x): """Reshape x so that the first two dimension become one. Args: x: a Tensor with shape [a, b, ...] Returns: a Tensor with shape [ab, ...] """ ret = tf.reshape(x, tf.concat([[-1], common_layers.shape_list(x)[2:]], 0)) old_shape = x.get_shape().dims a, b = old_s...
[ "def", "combine_first_two_dimensions", "(", "x", ")", ":", "ret", "=", "tf", ".", "reshape", "(", "x", ",", "tf", ".", "concat", "(", "[", "[", "-", "1", "]", ",", "common_layers", ".", "shape_list", "(", "x", ")", "[", "2", ":", "]", "]", ",", ...
Reshape x so that the first two dimension become one. Args: x: a Tensor with shape [a, b, ...] Returns: a Tensor with shape [ab, ...]
[ "Reshape", "x", "so", "that", "the", "first", "two", "dimension", "become", "one", "." ]
python
train
27.533333
wangwenpei/fantasy
fantasy/utils.py
https://github.com/wangwenpei/fantasy/blob/0fe92059bd868f14da84235beb05b217b1d46e4a/fantasy/utils.py#L14-L26
def get_config(app, prefix='hive_'): """Conveniently get the security configuration for the specified application without the annoying 'SECURITY_' prefix. :param app: The application to inspect """ items = app.config.items() prefix = prefix.upper() def strip_prefix(tup): return (tu...
[ "def", "get_config", "(", "app", ",", "prefix", "=", "'hive_'", ")", ":", "items", "=", "app", ".", "config", ".", "items", "(", ")", "prefix", "=", "prefix", ".", "upper", "(", ")", "def", "strip_prefix", "(", "tup", ")", ":", "return", "(", "tup"...
Conveniently get the security configuration for the specified application without the annoying 'SECURITY_' prefix. :param app: The application to inspect
[ "Conveniently", "get", "the", "security", "configuration", "for", "the", "specified", "application", "without", "the", "annoying", "SECURITY_", "prefix", "." ]
python
test
32.230769