repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
twilio/twilio-python
twilio/rest/taskrouter/v1/workspace/task_queue/__init__.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/taskrouter/v1/workspace/task_queue/__init__.py#L617-L641
def update(self, friendly_name=values.unset, target_workers=values.unset, reservation_activity_sid=values.unset, assignment_activity_sid=values.unset, max_reserved_workers=values.unset, task_order=values.unset): """ Update the TaskQueueInstance :para...
[ "def", "update", "(", "self", ",", "friendly_name", "=", "values", ".", "unset", ",", "target_workers", "=", "values", ".", "unset", ",", "reservation_activity_sid", "=", "values", ".", "unset", ",", "assignment_activity_sid", "=", "values", ".", "unset", ",",...
Update the TaskQueueInstance :param unicode friendly_name: Human readable description of this TaskQueue :param unicode target_workers: A string describing the Worker selection criteria for any Tasks that enter this TaskQueue. :param unicode reservation_activity_sid: ActivitySID that will be ass...
[ "Update", "the", "TaskQueueInstance" ]
python
train
gitenberg-dev/gitberg
gitenberg/workflow.py
https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/workflow.py#L43-L57
def upload_list(book_id_list, rdf_library=None): """ Uses the fetch, make, push subcommands to add a list of pg books """ with open(book_id_list, 'r') as f: cache = {} for book_id in f: book_id = book_id.strip() try: if int(book_id) in missing_pgid: ...
[ "def", "upload_list", "(", "book_id_list", ",", "rdf_library", "=", "None", ")", ":", "with", "open", "(", "book_id_list", ",", "'r'", ")", "as", "f", ":", "cache", "=", "{", "}", "for", "book_id", "in", "f", ":", "book_id", "=", "book_id", ".", "str...
Uses the fetch, make, push subcommands to add a list of pg books
[ "Uses", "the", "fetch", "make", "push", "subcommands", "to", "add", "a", "list", "of", "pg", "books" ]
python
train
DeepHorizons/iarm
iarm/arm_instructions/arithmetic.py
https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/arithmetic.py#L151-L177
def CMP(self, params): """ CMP Rm, Rn CMP Rm, #imm8 Subtract Rn or imm8 from Rm, set the NZCV flags, and discard the result Rm and Rn can be R0-R14 """ Rm, Rn = self.get_two_parameters(self.TWO_PARAMETER_COMMA_SEPARATED, params) if self.is_register(Rn): ...
[ "def", "CMP", "(", "self", ",", "params", ")", ":", "Rm", ",", "Rn", "=", "self", ".", "get_two_parameters", "(", "self", ".", "TWO_PARAMETER_COMMA_SEPARATED", ",", "params", ")", "if", "self", ".", "is_register", "(", "Rn", ")", ":", "# CMP Rm, Rn", "se...
CMP Rm, Rn CMP Rm, #imm8 Subtract Rn or imm8 from Rm, set the NZCV flags, and discard the result Rm and Rn can be R0-R14
[ "CMP", "Rm", "Rn", "CMP", "Rm", "#imm8" ]
python
train
chemlab/chemlab
chemlab/core/spacegroup/spacegroup.py
https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/spacegroup.py#L256-L276
def symmetry_normalised_reflections(self, hkl): """Returns an array of same size as *hkl*, containing the corresponding symmetry-equivalent reflections of lowest indices. Example: >>> from ase.lattice.spacegroup import Spacegroup >>> sg = Spacegroup(225) # fcc ...
[ "def", "symmetry_normalised_reflections", "(", "self", ",", "hkl", ")", ":", "hkl", "=", "np", ".", "array", "(", "hkl", ",", "dtype", "=", "int", ",", "ndmin", "=", "2", ")", "normalised", "=", "np", ".", "empty", "(", "hkl", ".", "shape", ",", "i...
Returns an array of same size as *hkl*, containing the corresponding symmetry-equivalent reflections of lowest indices. Example: >>> from ase.lattice.spacegroup import Spacegroup >>> sg = Spacegroup(225) # fcc >>> sg.symmetry_normalised_reflections([[2, 0, 0], [0, 2, 0...
[ "Returns", "an", "array", "of", "same", "size", "as", "*", "hkl", "*", "containing", "the", "corresponding", "symmetry", "-", "equivalent", "reflections", "of", "lowest", "indices", "." ]
python
train
signalfx/signalfx-python
examples/signalflow/dataframe.py
https://github.com/signalfx/signalfx-python/blob/650eb9a2b301bcc795e4e3a8c031574ade69849d/examples/signalflow/dataframe.py#L20-L42
def get_data_frame(client, program, start, stop, resolution=None): """Executes the given program across the given time range (expressed in millisecond timestamps since Epoch), and returns a Pandas DataFrame containing the results, indexed by output timestamp. If the program contains multiple publish() ...
[ "def", "get_data_frame", "(", "client", ",", "program", ",", "start", ",", "stop", ",", "resolution", "=", "None", ")", ":", "data", "=", "{", "}", "metadata", "=", "{", "}", "c", "=", "client", ".", "execute", "(", "program", ",", "start", "=", "s...
Executes the given program across the given time range (expressed in millisecond timestamps since Epoch), and returns a Pandas DataFrame containing the results, indexed by output timestamp. If the program contains multiple publish() calls, their outputs are merged into the returned DataFrame.
[ "Executes", "the", "given", "program", "across", "the", "given", "time", "range", "(", "expressed", "in", "millisecond", "timestamps", "since", "Epoch", ")", "and", "returns", "a", "Pandas", "DataFrame", "containing", "the", "results", "indexed", "by", "output",...
python
train
voxpupuli/pypuppetdb
pypuppetdb/api.py
https://github.com/voxpupuli/pypuppetdb/blob/cedeecf48014b4ad5b8e2513ca8230c814f45603/pypuppetdb/api.py#L643-L653
def catalog(self, node): """Get the available catalog for a given node. :param node: (Required) The name of the PuppetDB node. :type: :obj:`string` :returns: An instance of Catalog :rtype: :class:`pypuppetdb.types.Catalog` """ catalogs = self.catalogs(path=node)...
[ "def", "catalog", "(", "self", ",", "node", ")", ":", "catalogs", "=", "self", ".", "catalogs", "(", "path", "=", "node", ")", "return", "next", "(", "x", "for", "x", "in", "catalogs", ")" ]
Get the available catalog for a given node. :param node: (Required) The name of the PuppetDB node. :type: :obj:`string` :returns: An instance of Catalog :rtype: :class:`pypuppetdb.types.Catalog`
[ "Get", "the", "available", "catalog", "for", "a", "given", "node", "." ]
python
valid
ioos/compliance-checker
compliance_checker/cfutil.py
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L135-L149
def get_sea_names(): ''' Returns a list of NODC sea names source of list: https://www.nodc.noaa.gov/General/NODC-Archive/seanamelist.txt ''' global _SEA_NAMES if _SEA_NAMES is None: buf = {} with open(resource_filename('compliance_checker', 'data/seanames.csv'), 'r') as f: ...
[ "def", "get_sea_names", "(", ")", ":", "global", "_SEA_NAMES", "if", "_SEA_NAMES", "is", "None", ":", "buf", "=", "{", "}", "with", "open", "(", "resource_filename", "(", "'compliance_checker'", ",", "'data/seanames.csv'", ")", ",", "'r'", ")", "as", "f", ...
Returns a list of NODC sea names source of list: https://www.nodc.noaa.gov/General/NODC-Archive/seanamelist.txt
[ "Returns", "a", "list", "of", "NODC", "sea", "names" ]
python
train
KieranWynn/pyquaternion
pyquaternion/quaternion.py
https://github.com/KieranWynn/pyquaternion/blob/d2aad7f3fb0d4b9cc23aa72b390e9b2e1273eae9/pyquaternion/quaternion.py#L159-L233
def _from_matrix(cls, matrix): """Initialise from matrix representation Create a Quaternion by specifying the 3x3 rotation or 4x4 transformation matrix (as a numpy array) from which the quaternion's rotation should be created. """ try: shape = matrix.shape e...
[ "def", "_from_matrix", "(", "cls", ",", "matrix", ")", ":", "try", ":", "shape", "=", "matrix", ".", "shape", "except", "AttributeError", ":", "raise", "TypeError", "(", "\"Invalid matrix type: Input must be a 3x3 or 4x4 numpy array or matrix\"", ")", "if", "shape", ...
Initialise from matrix representation Create a Quaternion by specifying the 3x3 rotation or 4x4 transformation matrix (as a numpy array) from which the quaternion's rotation should be created.
[ "Initialise", "from", "matrix", "representation" ]
python
train
wrongwaycn/ssdb-py
ssdb/client.py
https://github.com/wrongwaycn/ssdb-py/blob/ce7b1542f0faa06fe71a60c667fe15992af0f621/ssdb/client.py#L495-L521
def setbit(self, name, offset, val): """ Flag the ``offset`` in ``name`` as ``value``. Returns a boolean indicating the previous value of ``offset``. Like **Redis.SETBIT** :param string name: the key name :param int offset: the bit position :para...
[ "def", "setbit", "(", "self", ",", "name", ",", "offset", ",", "val", ")", ":", "val", "=", "int", "(", "get_boolean", "(", "'val'", ",", "val", ")", ")", "offset", "=", "get_positive_integer", "(", "'offset'", ",", "offset", ")", "return", "self", "...
Flag the ``offset`` in ``name`` as ``value``. Returns a boolean indicating the previous value of ``offset``. Like **Redis.SETBIT** :param string name: the key name :param int offset: the bit position :param bool val: the bit value :return: the previous b...
[ "Flag", "the", "offset", "in", "name", "as", "value", ".", "Returns", "a", "boolean", "indicating", "the", "previous", "value", "of", "offset", "." ]
python
train
senaite/senaite.core
bika/lims/browser/workflow/analysisrequest.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/workflow/analysisrequest.py#L445-L450
def is_hidden(self, service): """Returns whether the request Hidden param for the given obj is True """ uid = api.get_uid(service) hidden_ans = self.request.form.get("Hidden", {}) return hidden_ans.get(uid, "") == "on"
[ "def", "is_hidden", "(", "self", ",", "service", ")", ":", "uid", "=", "api", ".", "get_uid", "(", "service", ")", "hidden_ans", "=", "self", ".", "request", ".", "form", ".", "get", "(", "\"Hidden\"", ",", "{", "}", ")", "return", "hidden_ans", ".",...
Returns whether the request Hidden param for the given obj is True
[ "Returns", "whether", "the", "request", "Hidden", "param", "for", "the", "given", "obj", "is", "True" ]
python
train
stefanfoulis/django-sendsms
sendsms/backends/smsglobal.py
https://github.com/stefanfoulis/django-sendsms/blob/375f469789866853253eceba936ebcff98e83c07/sendsms/backends/smsglobal.py#L109-L125
def _parse_response(self, result_page): """ Takes a result page of sending the sms, returns an extracted tuple: ('numeric_err_code', '<sent_queued_message_id>', '<smsglobalmsgid>') Returns None if unable to extract info from result_page, it should be safe to assume that it wa...
[ "def", "_parse_response", "(", "self", ",", "result_page", ")", ":", "# Sample result_page, single line -> \"OK: 0; Sent queued message ID: 2063619577732703 SMSGlobalMsgID:6171799108850954\"", "resultline", "=", "result_page", ".", "splitlines", "(", ")", "[", "0", "]", "# get ...
Takes a result page of sending the sms, returns an extracted tuple: ('numeric_err_code', '<sent_queued_message_id>', '<smsglobalmsgid>') Returns None if unable to extract info from result_page, it should be safe to assume that it was either a failed result or worse, the interface con...
[ "Takes", "a", "result", "page", "of", "sending", "the", "sms", "returns", "an", "extracted", "tuple", ":", "(", "numeric_err_code", "<sent_queued_message_id", ">", "<smsglobalmsgid", ">", ")", "Returns", "None", "if", "unable", "to", "extract", "info", "from", ...
python
train
waqasbhatti/astrobase
astrobase/varbase/autocorr.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/varbase/autocorr.py#L20-L57
def _autocorr_func1(mags, lag, maglen, magmed, magstd): '''Calculates the autocorr of mag series for specific lag. This version of the function is taken from: Kim et al. (`2011 <https://dx.doi.org/10.1088/0004-637X/735/2/68>`_) Parameters ---------- mags : np.array This is the magnitu...
[ "def", "_autocorr_func1", "(", "mags", ",", "lag", ",", "maglen", ",", "magmed", ",", "magstd", ")", ":", "lagindex", "=", "nparange", "(", "1", ",", "maglen", "-", "lag", ")", "products", "=", "(", "mags", "[", "lagindex", "]", "-", "magmed", ")", ...
Calculates the autocorr of mag series for specific lag. This version of the function is taken from: Kim et al. (`2011 <https://dx.doi.org/10.1088/0004-637X/735/2/68>`_) Parameters ---------- mags : np.array This is the magnitudes array. MUST NOT have any nans. lag : float The...
[ "Calculates", "the", "autocorr", "of", "mag", "series", "for", "specific", "lag", "." ]
python
valid
msmbuilder/msmbuilder
msmbuilder/decomposition/tica.py
https://github.com/msmbuilder/msmbuilder/blob/556a93a170782f47be53f4a1e9d740fb1c8272b3/msmbuilder/decomposition/tica.py#L261-L290
def fit(self, sequences, y=None): """Fit the model with a collection of sequences. This method is not online. Any state accumulated from previous calls to fit() or partial_fit() will be cleared. For online learning, use `partial_fit`. Parameters ---------- sequ...
[ "def", "fit", "(", "self", ",", "sequences", ",", "y", "=", "None", ")", ":", "self", ".", "_initialized", "=", "False", "check_iter_of_sequences", "(", "sequences", ",", "max_iter", "=", "3", ")", "# we might be lazy-loading", "for", "X", "in", "sequences",...
Fit the model with a collection of sequences. This method is not online. Any state accumulated from previous calls to fit() or partial_fit() will be cleared. For online learning, use `partial_fit`. Parameters ---------- sequences: list of array-like, each of shape (n_s...
[ "Fit", "the", "model", "with", "a", "collection", "of", "sequences", "." ]
python
train
FocusLab/Albertson
albertson/base.py
https://github.com/FocusLab/Albertson/blob/a42f9873559df9188c40c34fdffb079d78eaa3fe/albertson/base.py#L102-L117
def create_table(self): ''' Hook point for overriding how the CounterPool creates a new table in DynamooDB ''' table = self.conn.create_table( name=self.get_table_name(), schema=self.get_schema(), read_units=self.get_read_units(), w...
[ "def", "create_table", "(", "self", ")", ":", "table", "=", "self", ".", "conn", ".", "create_table", "(", "name", "=", "self", ".", "get_table_name", "(", ")", ",", "schema", "=", "self", ".", "get_schema", "(", ")", ",", "read_units", "=", "self", ...
Hook point for overriding how the CounterPool creates a new table in DynamooDB
[ "Hook", "point", "for", "overriding", "how", "the", "CounterPool", "creates", "a", "new", "table", "in", "DynamooDB" ]
python
valid
StackStorm/pybind
pybind/slxos/v17s_1_02/interface_vlan/vlan/ip/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/interface_vlan/vlan/ip/__init__.py#L199-L220
def _set_igmpVlan(self, v, load=False): """ Setter method for igmpVlan, mapped from YANG variable /interface_vlan/vlan/ip/igmpVlan (container) If this variable is read-only (config: false) in the source YANG file, then _set_igmpVlan is considered as a private method. Backends looking to populate thi...
[ "def", "_set_igmpVlan", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base"...
Setter method for igmpVlan, mapped from YANG variable /interface_vlan/vlan/ip/igmpVlan (container) If this variable is read-only (config: false) in the source YANG file, then _set_igmpVlan is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set...
[ "Setter", "method", "for", "igmpVlan", "mapped", "from", "YANG", "variable", "/", "interface_vlan", "/", "vlan", "/", "ip", "/", "igmpVlan", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in...
python
train
ziwenxie/netease-dl
netease/download.py
https://github.com/ziwenxie/netease-dl/blob/84b226fc07b10f7f66580f0fc69f10356f66b5c3/netease/download.py#L222-L234
def download_user_playlists_by_id(self, user_id): """Download user's playlists by his/her id. :params user_id: user id. """ try: playlist = self.crawler.get_user_playlists(user_id) except RequestException as exception: click.echo(exception) else:...
[ "def", "download_user_playlists_by_id", "(", "self", ",", "user_id", ")", ":", "try", ":", "playlist", "=", "self", ".", "crawler", ".", "get_user_playlists", "(", "user_id", ")", "except", "RequestException", "as", "exception", ":", "click", ".", "echo", "(",...
Download user's playlists by his/her id. :params user_id: user id.
[ "Download", "user", "s", "playlists", "by", "his", "/", "her", "id", "." ]
python
train
wuher/devil
devil/resource.py
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/resource.py#L255-L270
def _validate_input_data(self, data, request): """ Validate input data. :param request: the HTTP request :param data: the parsed data :return: if validation is performed and succeeds the data is converted into whatever format the validation uses (by default Django's ...
[ "def", "_validate_input_data", "(", "self", ",", "data", ",", "request", ")", ":", "validator", "=", "self", ".", "_get_input_validator", "(", "request", ")", "if", "isinstance", "(", "data", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "map"...
Validate input data. :param request: the HTTP request :param data: the parsed data :return: if validation is performed and succeeds the data is converted into whatever format the validation uses (by default Django's Forms) If not, the data is returned unchanged...
[ "Validate", "input", "data", "." ]
python
train
jameshilliard/hlk-sw16
hlk_sw16/protocol.py
https://github.com/jameshilliard/hlk-sw16/blob/4f0c5a7b76b42167f4dc9d2aa6312c7518a8cd56/hlk_sw16/protocol.py#L235-L239
def register_status_callback(self, callback, switch): """Register a callback which will fire when state changes.""" if self.status_callbacks.get(switch, None) is None: self.status_callbacks[switch] = [] self.status_callbacks[switch].append(callback)
[ "def", "register_status_callback", "(", "self", ",", "callback", ",", "switch", ")", ":", "if", "self", ".", "status_callbacks", ".", "get", "(", "switch", ",", "None", ")", "is", "None", ":", "self", ".", "status_callbacks", "[", "switch", "]", "=", "["...
Register a callback which will fire when state changes.
[ "Register", "a", "callback", "which", "will", "fire", "when", "state", "changes", "." ]
python
train
tdryer/hangups
hangups/client.py
https://github.com/tdryer/hangups/blob/85c0bf0a57698d077461283895707260f9dbf931/hangups/client.py#L400-L436
async def _pb_request(self, endpoint, request_pb, response_pb): """Send a Protocol Buffer formatted chat API request. Args: endpoint (str): The chat API endpoint to use. request_pb: The request body as a Protocol Buffer message. response_pb: The response body as a Pr...
[ "async", "def", "_pb_request", "(", "self", ",", "endpoint", ",", "request_pb", ",", "response_pb", ")", ":", "logger", ".", "debug", "(", "'Sending Protocol Buffer request %s:\\n%s'", ",", "endpoint", ",", "request_pb", ")", "res", "=", "await", "self", ".", ...
Send a Protocol Buffer formatted chat API request. Args: endpoint (str): The chat API endpoint to use. request_pb: The request body as a Protocol Buffer message. response_pb: The response body as a Protocol Buffer message. Raises: NetworkError: If the re...
[ "Send", "a", "Protocol", "Buffer", "formatted", "chat", "API", "request", "." ]
python
valid
rhayes777/PyAutoFit
autofit/optimize/optimizer.py
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/optimizer.py#L1-L29
def grid(fitness_function, no_dimensions, step_size): """ Grid search using a fitness function over a given number of dimensions and a given step size between inclusive limits of 0 and 1. Parameters ---------- fitness_function: function A function that takes a tuple of floats as an argu...
[ "def", "grid", "(", "fitness_function", ",", "no_dimensions", ",", "step_size", ")", ":", "best_fitness", "=", "float", "(", "\"-inf\"", ")", "best_arguments", "=", "None", "for", "arguments", "in", "make_lists", "(", "no_dimensions", ",", "step_size", ")", ":...
Grid search using a fitness function over a given number of dimensions and a given step size between inclusive limits of 0 and 1. Parameters ---------- fitness_function: function A function that takes a tuple of floats as an argument no_dimensions: int The number of dimensions of th...
[ "Grid", "search", "using", "a", "fitness", "function", "over", "a", "given", "number", "of", "dimensions", "and", "a", "given", "step", "size", "between", "inclusive", "limits", "of", "0", "and", "1", "." ]
python
train
KeithSSmith/switcheo-python
switcheo/authenticated_client.py
https://github.com/KeithSSmith/switcheo-python/blob/22f943dea1ad7d692b2bfcd9f0822ec80f4641a6/switcheo/authenticated_client.py#L595-L651
def execute_order(self, order_params, private_key): """ This function executes the order created before it and signs the transaction to be submitted to the blockchain. Execution of this function is as follows:: execute_order(order_params=create_order, private_key=kp) The ex...
[ "def", "execute_order", "(", "self", ",", "order_params", ",", "private_key", ")", ":", "order_id", "=", "order_params", "[", "'id'", "]", "api_params", "=", "self", ".", "sign_execute_order_function", "[", "self", ".", "blockchain", "]", "(", "order_params", ...
This function executes the order created before it and signs the transaction to be submitted to the blockchain. Execution of this function is as follows:: execute_order(order_params=create_order, private_key=kp) The expected return result for this function is the same as the execute_order ...
[ "This", "function", "executes", "the", "order", "created", "before", "it", "and", "signs", "the", "transaction", "to", "be", "submitted", "to", "the", "blockchain", ".", "Execution", "of", "this", "function", "is", "as", "follows", "::" ]
python
train
pazz/alot
alot/settings/utils.py
https://github.com/pazz/alot/blob/d0297605c0ec1c6b65f541d0fd5b69ac5a0f4ded/alot/settings/utils.py#L14-L82
def read_config(configpath=None, specpath=None, checks=None, report_extra=False): """ get a (validated) config object for given config file path. :param configpath: path to config-file or a list of lines as its content :type configpath: str or list(str) :param specpath: path to spec...
[ "def", "read_config", "(", "configpath", "=", "None", ",", "specpath", "=", "None", ",", "checks", "=", "None", ",", "report_extra", "=", "False", ")", ":", "checks", "=", "checks", "or", "{", "}", "try", ":", "config", "=", "ConfigObj", "(", "infile",...
get a (validated) config object for given config file path. :param configpath: path to config-file or a list of lines as its content :type configpath: str or list(str) :param specpath: path to spec-file :type specpath: str :param checks: custom checks to use for validator. see `validate doc...
[ "get", "a", "(", "validated", ")", "config", "object", "for", "given", "config", "file", "path", "." ]
python
train
shawnsilva/steamwebapi
steamwebapi/profiles.py
https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/profiles.py#L76-L84
def personastate(self): """Return the Persona State of the Users Profile""" if self._personastate == None: return None elif self._personastate in self.PersonaState: return self.PersonaState[self._personastate] else: #Invalid State return No...
[ "def", "personastate", "(", "self", ")", ":", "if", "self", ".", "_personastate", "==", "None", ":", "return", "None", "elif", "self", ".", "_personastate", "in", "self", ".", "PersonaState", ":", "return", "self", ".", "PersonaState", "[", "self", ".", ...
Return the Persona State of the Users Profile
[ "Return", "the", "Persona", "State", "of", "the", "Users", "Profile" ]
python
train
tensorflow/probability
tensorflow_probability/python/vi/csiszar_divergence.py
https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/vi/csiszar_divergence.py#L550-L585
def jeffreys(logu, name=None): """The Jeffreys Csiszar-function in log-space. A Csiszar-function is a member of, ```none F = { f:R_+ to R : f convex }. ``` The Jeffreys Csiszar-function is: ```none f(u) = 0.5 ( u log(u) - log(u) ) = 0.5 kl_forward + 0.5 kl_reverse = symmetrized_csiszar...
[ "def", "jeffreys", "(", "logu", ",", "name", "=", "None", ")", ":", "with", "tf", ".", "compat", ".", "v1", ".", "name_scope", "(", "name", ",", "\"jeffreys\"", ",", "[", "logu", "]", ")", ":", "logu", "=", "tf", ".", "convert_to_tensor", "(", "val...
The Jeffreys Csiszar-function in log-space. A Csiszar-function is a member of, ```none F = { f:R_+ to R : f convex }. ``` The Jeffreys Csiszar-function is: ```none f(u) = 0.5 ( u log(u) - log(u) ) = 0.5 kl_forward + 0.5 kl_reverse = symmetrized_csiszar_function(kl_reverse) = symme...
[ "The", "Jeffreys", "Csiszar", "-", "function", "in", "log", "-", "space", "." ]
python
test
pepkit/peppy
peppy/utils.py
https://github.com/pepkit/peppy/blob/f0f725e1557936b81c86573a77400e6f8da78f05/peppy/utils.py#L393-L409
def standard_stream_redirector(stream): """ Temporarily redirect stdout and stderr to another stream. This can be useful for capturing messages for easier inspection, or for rerouting and essentially ignoring them, with the destination as something like an opened os.devnull. :param FileIO[str]...
[ "def", "standard_stream_redirector", "(", "stream", ")", ":", "import", "sys", "genuine_stdout", ",", "genuine_stderr", "=", "sys", ".", "stdout", ",", "sys", ".", "stderr", "sys", ".", "stdout", ",", "sys", ".", "stderr", "=", "stream", ",", "stream", "tr...
Temporarily redirect stdout and stderr to another stream. This can be useful for capturing messages for easier inspection, or for rerouting and essentially ignoring them, with the destination as something like an opened os.devnull. :param FileIO[str] stream: temporary proxy for standard streams
[ "Temporarily", "redirect", "stdout", "and", "stderr", "to", "another", "stream", "." ]
python
train
tonybaloney/wily
wily/decorators.py
https://github.com/tonybaloney/wily/blob/bae259354a91b57d56603f0ca7403186f086a84c/wily/decorators.py#L11-L20
def add_version(f): """ Add the version of wily to the help heading. :param f: function to decorate :return: decorated function """ doc = f.__doc__ f.__doc__ = "Version: " + __version__ + "\n\n" + doc return f
[ "def", "add_version", "(", "f", ")", ":", "doc", "=", "f", ".", "__doc__", "f", ".", "__doc__", "=", "\"Version: \"", "+", "__version__", "+", "\"\\n\\n\"", "+", "doc", "return", "f" ]
Add the version of wily to the help heading. :param f: function to decorate :return: decorated function
[ "Add", "the", "version", "of", "wily", "to", "the", "help", "heading", "." ]
python
train
acutesoftware/virtual-AI-simulator
vais/character.py
https://github.com/acutesoftware/virtual-AI-simulator/blob/57de679a5b1a58c38fefe6aea58af1f3a7e79c58/vais/character.py#L198-L219
def _parse_char_line_to_self(self, k,v): """ takes a line from a saved file split into key and values and updates the appropriate self parameters of character. """ k = k.strip(' ').strip('\n') v = v.strip(' ').strip('\n') # print('_parse_char_line_to_self(self, k,v...
[ "def", "_parse_char_line_to_self", "(", "self", ",", "k", ",", "v", ")", ":", "k", "=", "k", ".", "strip", "(", "' '", ")", ".", "strip", "(", "'\\n'", ")", "v", "=", "v", ".", "strip", "(", "' '", ")", ".", "strip", "(", "'\\n'", ")", "# print...
takes a line from a saved file split into key and values and updates the appropriate self parameters of character.
[ "takes", "a", "line", "from", "a", "saved", "file", "split", "into", "key", "and", "values", "and", "updates", "the", "appropriate", "self", "parameters", "of", "character", "." ]
python
train
apple/turicreate
src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/python_message.py#L761-L770
def _IsPresent(item): """Given a (FieldDescriptor, value) tuple from _fields, return true if the value should be included in the list returned by ListFields().""" if item[0].label == _FieldDescriptor.LABEL_REPEATED: return bool(item[1]) elif item[0].cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE: return ...
[ "def", "_IsPresent", "(", "item", ")", ":", "if", "item", "[", "0", "]", ".", "label", "==", "_FieldDescriptor", ".", "LABEL_REPEATED", ":", "return", "bool", "(", "item", "[", "1", "]", ")", "elif", "item", "[", "0", "]", ".", "cpp_type", "==", "_...
Given a (FieldDescriptor, value) tuple from _fields, return true if the value should be included in the list returned by ListFields().
[ "Given", "a", "(", "FieldDescriptor", "value", ")", "tuple", "from", "_fields", "return", "true", "if", "the", "value", "should", "be", "included", "in", "the", "list", "returned", "by", "ListFields", "()", "." ]
python
train
JarryShaw/PyPCAPKit
src/const/hip/registration.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/const/hip/registration.py#L17-L23
def get(key, default=-1): """Backport support for original codes.""" if isinstance(key, int): return Registration(key) if key not in Registration._member_map_: extend_enum(Registration, key, default) return Registration[key]
[ "def", "get", "(", "key", ",", "default", "=", "-", "1", ")", ":", "if", "isinstance", "(", "key", ",", "int", ")", ":", "return", "Registration", "(", "key", ")", "if", "key", "not", "in", "Registration", ".", "_member_map_", ":", "extend_enum", "("...
Backport support for original codes.
[ "Backport", "support", "for", "original", "codes", "." ]
python
train
peterbrittain/asciimatics
asciimatics/screen.py
https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/asciimatics/screen.py#L83-L91
def set(self, x, y, value): """ Set the cell value from the specified location :param x: The column (x coord) of the character. :param y: The row (y coord) of the character. :param value: A 5-tuple of (unicode, foreground, attributes, background, width). """ self...
[ "def", "set", "(", "self", ",", "x", ",", "y", ",", "value", ")", ":", "self", ".", "_double_buffer", "[", "y", "]", "[", "x", "]", "=", "value" ]
Set the cell value from the specified location :param x: The column (x coord) of the character. :param y: The row (y coord) of the character. :param value: A 5-tuple of (unicode, foreground, attributes, background, width).
[ "Set", "the", "cell", "value", "from", "the", "specified", "location" ]
python
train
ui/django-post_office
post_office/utils.py
https://github.com/ui/django-post_office/blob/03e1ffb69829b475402f0f3ecd9f8a90af7da4bd/post_office/utils.py#L122-L141
def parse_emails(emails): """ A function that returns a list of valid email addresses. This function will also convert a single email address into a list of email addresses. None value is also converted into an empty list. """ if isinstance(emails, string_types): emails = [emails] ...
[ "def", "parse_emails", "(", "emails", ")", ":", "if", "isinstance", "(", "emails", ",", "string_types", ")", ":", "emails", "=", "[", "emails", "]", "elif", "emails", "is", "None", ":", "emails", "=", "[", "]", "for", "email", "in", "emails", ":", "t...
A function that returns a list of valid email addresses. This function will also convert a single email address into a list of email addresses. None value is also converted into an empty list.
[ "A", "function", "that", "returns", "a", "list", "of", "valid", "email", "addresses", ".", "This", "function", "will", "also", "convert", "a", "single", "email", "address", "into", "a", "list", "of", "email", "addresses", ".", "None", "value", "is", "also"...
python
train
casacore/python-casacore
casacore/functionals/functional.py
https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/functionals/functional.py#L122-L141
def fdf(self, x): """Calculate the value of the functional for the specified arguments, and the derivatives with respect to the parameters (taking any specified mask into account). :param x: the value(s) to evaluate at """ x = self._flatten(x) n = 1 if has...
[ "def", "fdf", "(", "self", ",", "x", ")", ":", "x", "=", "self", ".", "_flatten", "(", "x", ")", "n", "=", "1", "if", "hasattr", "(", "x", ",", "\"__len__\"", ")", ":", "n", "=", "len", "(", "x", ")", "if", "self", ".", "_dtype", "==", "0",...
Calculate the value of the functional for the specified arguments, and the derivatives with respect to the parameters (taking any specified mask into account). :param x: the value(s) to evaluate at
[ "Calculate", "the", "value", "of", "the", "functional", "for", "the", "specified", "arguments", "and", "the", "derivatives", "with", "respect", "to", "the", "parameters", "(", "taking", "any", "specified", "mask", "into", "account", ")", "." ]
python
train
boppreh/keyboard
keyboard/__init__.py
https://github.com/boppreh/keyboard/blob/dbb73dfff484f733d5fed8dbc53301af5b6c7f50/keyboard/__init__.py#L794-L809
def restore_state(scan_codes): """ Given a list of scan_codes ensures these keys, and only these keys, are pressed. Pairs well with `stash_state`, alternative to `restore_modifiers`. """ _listener.is_replaying = True with _pressed_events_lock: current = set(_pressed_events) target =...
[ "def", "restore_state", "(", "scan_codes", ")", ":", "_listener", ".", "is_replaying", "=", "True", "with", "_pressed_events_lock", ":", "current", "=", "set", "(", "_pressed_events", ")", "target", "=", "set", "(", "scan_codes", ")", "for", "scan_code", "in",...
Given a list of scan_codes ensures these keys, and only these keys, are pressed. Pairs well with `stash_state`, alternative to `restore_modifiers`.
[ "Given", "a", "list", "of", "scan_codes", "ensures", "these", "keys", "and", "only", "these", "keys", "are", "pressed", ".", "Pairs", "well", "with", "stash_state", "alternative", "to", "restore_modifiers", "." ]
python
train
wreckage/django-happenings
happenings/utils/common.py
https://github.com/wreckage/django-happenings/blob/7bca5576efa6cd4c4e87356bf9e5b8cd538ae91d/happenings/utils/common.py#L30-L34
def _inc_day(year, month, day, net): """Increments the day by converting to a datetime.date().""" d = date(year, month, day) new_d = d + timezone.timedelta(days=net) return new_d.year, new_d.month, new_d.day
[ "def", "_inc_day", "(", "year", ",", "month", ",", "day", ",", "net", ")", ":", "d", "=", "date", "(", "year", ",", "month", ",", "day", ")", "new_d", "=", "d", "+", "timezone", ".", "timedelta", "(", "days", "=", "net", ")", "return", "new_d", ...
Increments the day by converting to a datetime.date().
[ "Increments", "the", "day", "by", "converting", "to", "a", "datetime", ".", "date", "()", "." ]
python
test
zabertech/python-swampyer
swampyer/__init__.py
https://github.com/zabertech/python-swampyer/blob/31b040e7570455718709a496d6d9faacfb372a00/swampyer/__init__.py#L692-L700
def handle_challenge(self,data): """ Executed when the server requests additional authentication """ # Send challenge response self.send_message(AUTHENTICATE( signature = self.password, extra = {} ))
[ "def", "handle_challenge", "(", "self", ",", "data", ")", ":", "# Send challenge response", "self", ".", "send_message", "(", "AUTHENTICATE", "(", "signature", "=", "self", ".", "password", ",", "extra", "=", "{", "}", ")", ")" ]
Executed when the server requests additional authentication
[ "Executed", "when", "the", "server", "requests", "additional", "authentication" ]
python
train
inasafe/inasafe
safe/report/extractors/action_notes.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/extractors/action_notes.py#L204-L235
def action_checklist_report_extractor(impact_report, component_metadata): """Extracting action checklist of the impact layer to its own report. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_report.Imp...
[ "def", "action_checklist_report_extractor", "(", "impact_report", ",", "component_metadata", ")", ":", "context", "=", "{", "}", "extra_args", "=", "component_metadata", ".", "extra_args", "components_list", "=", "resolve_from_dictionary", "(", "extra_args", ",", "'comp...
Extracting action checklist of the impact layer to its own report. :param impact_report: the impact report that acts as a proxy to fetch all the data that extractor needed :type impact_report: safe.report.impact_report.ImpactReport :param component_metadata: the component metadata. Used to obtain ...
[ "Extracting", "action", "checklist", "of", "the", "impact", "layer", "to", "its", "own", "report", "." ]
python
train
openspending/babbage
babbage/model/aggregate.py
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/model/aggregate.py#L22-L32
def bind(self, cube): """ When one column needs to match, use the key. """ if self.measure: table, column = self.measure.bind(cube) else: table, column = cube.fact_table, cube.fact_pk # apply the SQL aggregation function: column = getattr(func, self.functi...
[ "def", "bind", "(", "self", ",", "cube", ")", ":", "if", "self", ".", "measure", ":", "table", ",", "column", "=", "self", ".", "measure", ".", "bind", "(", "cube", ")", "else", ":", "table", ",", "column", "=", "cube", ".", "fact_table", ",", "c...
When one column needs to match, use the key.
[ "When", "one", "column", "needs", "to", "match", "use", "the", "key", "." ]
python
train
DataBiosphere/dsub
dsub/providers/local.py
https://github.com/DataBiosphere/dsub/blob/443ce31daa6023dc2fd65ef2051796e19d18d5a7/dsub/providers/local.py#L566-L580
def _datetime_in_range(self, dt, dt_min=None, dt_max=None): """Determine if the provided time is within the range, inclusive.""" # The pipelines API stores operation create-time with second granularity. # We mimic this behavior in the local provider by truncating to seconds. dt = dt.replace(microsecond=...
[ "def", "_datetime_in_range", "(", "self", ",", "dt", ",", "dt_min", "=", "None", ",", "dt_max", "=", "None", ")", ":", "# The pipelines API stores operation create-time with second granularity.", "# We mimic this behavior in the local provider by truncating to seconds.", "dt", ...
Determine if the provided time is within the range, inclusive.
[ "Determine", "if", "the", "provided", "time", "is", "within", "the", "range", "inclusive", "." ]
python
valid
pyviz/param
param/parameterized.py
https://github.com/pyviz/param/blob/8f0dafa78defa883247b40635f96cc6d5c1b3481/param/parameterized.py#L1231-L1255
def params(self_, parameter_name=None): """ Return the Parameters of this class as the dictionary {name: parameter_object} Includes Parameters from this class and its superclasses. """ if self_.self is not None and self_.self._instance__params: self_....
[ "def", "params", "(", "self_", ",", "parameter_name", "=", "None", ")", ":", "if", "self_", ".", "self", "is", "not", "None", "and", "self_", ".", "self", ".", "_instance__params", ":", "self_", ".", "warning", "(", "'The Parameterized instance has instance '"...
Return the Parameters of this class as the dictionary {name: parameter_object} Includes Parameters from this class and its superclasses.
[ "Return", "the", "Parameters", "of", "this", "class", "as", "the", "dictionary", "{", "name", ":", "parameter_object", "}" ]
python
train
wakatime/wakatime
wakatime/packages/pygments/util.py
https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/pygments/util.py#L170-L180
def doctype_matches(text, regex): """Check if the doctype matches a regular expression (if present). Note that this method only checks the first part of a DOCTYPE. eg: 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' """ m = doctype_lookup_re.match(text) if m is None: return False d...
[ "def", "doctype_matches", "(", "text", ",", "regex", ")", ":", "m", "=", "doctype_lookup_re", ".", "match", "(", "text", ")", "if", "m", "is", "None", ":", "return", "False", "doctype", "=", "m", ".", "group", "(", "2", ")", "return", "re", ".", "c...
Check if the doctype matches a regular expression (if present). Note that this method only checks the first part of a DOCTYPE. eg: 'html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
[ "Check", "if", "the", "doctype", "matches", "a", "regular", "expression", "(", "if", "present", ")", "." ]
python
train
raamana/mrivis
mrivis/workflow.py
https://github.com/raamana/mrivis/blob/199ad096b8a1d825f69109e7218a81b2f1cec756/mrivis/workflow.py#L714-L740
def _get_checkers(slice_shape, patch_size): """Creates checkerboard of a given tile size, filling a given slice.""" if patch_size is not None: patch_size = check_patch_size(patch_size) else: # 7 patches in each axis, min voxels/patch = 3 # TODO make 7 a user settable parameter ...
[ "def", "_get_checkers", "(", "slice_shape", ",", "patch_size", ")", ":", "if", "patch_size", "is", "not", "None", ":", "patch_size", "=", "check_patch_size", "(", "patch_size", ")", "else", ":", "# 7 patches in each axis, min voxels/patch = 3", "# TODO make 7 a user set...
Creates checkerboard of a given tile size, filling a given slice.
[ "Creates", "checkerboard", "of", "a", "given", "tile", "size", "filling", "a", "given", "slice", "." ]
python
train
quodlibet/mutagen
mutagen/_senf/_temp.py
https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/_senf/_temp.py#L54-L75
def mkstemp(suffix=None, prefix=None, dir=None, text=False): """ Args: suffix (`pathlike` or `None`): suffix or `None` to use the default prefix (`pathlike` or `None`): prefix or `None` to use the default dir (`pathlike` or `None`): temp dir or `None` to use the default text (boo...
[ "def", "mkstemp", "(", "suffix", "=", "None", ",", "prefix", "=", "None", ",", "dir", "=", "None", ",", "text", "=", "False", ")", ":", "suffix", "=", "fsnative", "(", ")", "if", "suffix", "is", "None", "else", "path2fsn", "(", "suffix", ")", "pref...
Args: suffix (`pathlike` or `None`): suffix or `None` to use the default prefix (`pathlike` or `None`): prefix or `None` to use the default dir (`pathlike` or `None`): temp dir or `None` to use the default text (bool): if the file should be opened in text mode Returns: Tuple[...
[ "Args", ":", "suffix", "(", "pathlike", "or", "None", ")", ":", "suffix", "or", "None", "to", "use", "the", "default", "prefix", "(", "pathlike", "or", "None", ")", ":", "prefix", "or", "None", "to", "use", "the", "default", "dir", "(", "pathlike", "...
python
train
nickjj/ansigenome
ansigenome/utils.py
https://github.com/nickjj/ansigenome/blob/70cd98d7a23d36c56f4e713ea820cfb4c485c81c/ansigenome/utils.py#L59-L68
def file_to_string(path): """ Return the contents of a file when given a path. """ if not os.path.exists(path): ui.error(c.MESSAGES["path_missing"], path) sys.exit(1) with codecs.open(path, "r", "UTF-8") as contents: return contents.read()
[ "def", "file_to_string", "(", "path", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "ui", ".", "error", "(", "c", ".", "MESSAGES", "[", "\"path_missing\"", "]", ",", "path", ")", "sys", ".", "exit", "(", "1", ")"...
Return the contents of a file when given a path.
[ "Return", "the", "contents", "of", "a", "file", "when", "given", "a", "path", "." ]
python
train
robert-b-clarke/nre-darwin-py
nredarwin/webservice.py
https://github.com/robert-b-clarke/nre-darwin-py/blob/6b0b181770e085dc7f71fbd2eb3fe779f653da62/nredarwin/webservice.py#L601-L612
def previous_calling_points(self): """ A list of CallingPoint objects. This is the list of all previous calling points for the service, including all associated services if multiple services join together to form this service. """ calling_points = list() ...
[ "def", "previous_calling_points", "(", "self", ")", ":", "calling_points", "=", "list", "(", ")", "for", "cpl", "in", "self", ".", "_previous_calling_point_lists", ":", "calling_points", "+=", "cpl", ".", "calling_points", "return", "calling_points" ]
A list of CallingPoint objects. This is the list of all previous calling points for the service, including all associated services if multiple services join together to form this service.
[ "A", "list", "of", "CallingPoint", "objects", "." ]
python
train
klen/graphite-beacon
graphite_beacon/handlers/cli.py
https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/handlers/cli.py#L41-L57
def substitute_variables(command, level, name, value, target=None, **kwargs): """Substitute variables in command fragments by values e.g. ${level} => 'warning'.""" rule = kwargs.get('rule', {}) rule_value = rule.get('value', '') if rule else '' substitutes = { '${level}': str(level), '${...
[ "def", "substitute_variables", "(", "command", ",", "level", ",", "name", ",", "value", ",", "target", "=", "None", ",", "*", "*", "kwargs", ")", ":", "rule", "=", "kwargs", ".", "get", "(", "'rule'", ",", "{", "}", ")", "rule_value", "=", "rule", ...
Substitute variables in command fragments by values e.g. ${level} => 'warning'.
[ "Substitute", "variables", "in", "command", "fragments", "by", "values", "e", ".", "g", ".", "$", "{", "level", "}", "=", ">", "warning", "." ]
python
train
jmcgeheeiv/pyfakefs
pyfakefs/fake_scandir.py
https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/fake_scandir.py#L176-L200
def _classify_directory_contents(filesystem, root): """Classify contents of a directory as files/directories. Args: filesystem: The fake filesystem used for implementation root: (str) Directory to examine. Returns: (tuple) A tuple consisting of three values: the directory examined,...
[ "def", "_classify_directory_contents", "(", "filesystem", ",", "root", ")", ":", "dirs", "=", "[", "]", "files", "=", "[", "]", "for", "entry", "in", "filesystem", ".", "listdir", "(", "root", ")", ":", "if", "filesystem", ".", "isdir", "(", "filesystem"...
Classify contents of a directory as files/directories. Args: filesystem: The fake filesystem used for implementation root: (str) Directory to examine. Returns: (tuple) A tuple consisting of three values: the directory examined, a list containing all of the directory entries, an...
[ "Classify", "contents", "of", "a", "directory", "as", "files", "/", "directories", "." ]
python
train
vertexproject/synapse
synapse/lib/provenance.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/provenance.py#L169-L181
def commit(self): ''' Writes the current provenance stack to storage if it wasn't already there and returns it Returns (Tuple[bool, str, List[]]): Whether the stack was not cached, the iden of the prov stack, and the provstack ''' providen, provstack = get() ...
[ "def", "commit", "(", "self", ")", ":", "providen", ",", "provstack", "=", "get", "(", ")", "wasnew", "=", "(", "providen", "is", "None", ")", "if", "wasnew", ":", "providen", "=", "self", ".", "getProvIden", "(", "provstack", ")", "setiden", "(", "p...
Writes the current provenance stack to storage if it wasn't already there and returns it Returns (Tuple[bool, str, List[]]): Whether the stack was not cached, the iden of the prov stack, and the provstack
[ "Writes", "the", "current", "provenance", "stack", "to", "storage", "if", "it", "wasn", "t", "already", "there", "and", "returns", "it" ]
python
train
aio-libs/aioredis
aioredis/commands/set.py
https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/set.py#L79-L90
def isscan(self, key, *, match=None, count=None): """Incrementally iterate set elements using async for. Usage example: >>> async for val in redis.isscan(key, match='something*'): ... print('Matched:', val) """ return _ScanIter(lambda cur: self.sscan(key, cur, ...
[ "def", "isscan", "(", "self", ",", "key", ",", "*", ",", "match", "=", "None", ",", "count", "=", "None", ")", ":", "return", "_ScanIter", "(", "lambda", "cur", ":", "self", ".", "sscan", "(", "key", ",", "cur", ",", "match", "=", "match", ",", ...
Incrementally iterate set elements using async for. Usage example: >>> async for val in redis.isscan(key, match='something*'): ... print('Matched:', val)
[ "Incrementally", "iterate", "set", "elements", "using", "async", "for", "." ]
python
train
portfors-lab/sparkle
sparkle/gui/stim/stimulusview.py
https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/stimulusview.py#L139-L156
def splitAt(self, point): """Gets the nearest index to *point*, *point* does not have to be over an item. index can be +1 more in row and/or column than existing items :param point: any point within the view, in view coordinates :type point: :qtdoc:`QPoint` :returns: (int, int)...
[ "def", "splitAt", "(", "self", ",", "point", ")", ":", "wx", "=", "point", ".", "x", "(", ")", "+", "self", ".", "horizontalScrollBar", "(", ")", ".", "value", "(", ")", "wy", "=", "point", ".", "y", "(", ")", "+", "self", ".", "verticalScrollBar...
Gets the nearest index to *point*, *point* does not have to be over an item. index can be +1 more in row and/or column than existing items :param point: any point within the view, in view coordinates :type point: :qtdoc:`QPoint` :returns: (int, int) -- (row, column) of the nearest inde...
[ "Gets", "the", "nearest", "index", "to", "*", "point", "*", "*", "point", "*", "does", "not", "have", "to", "be", "over", "an", "item", ".", "index", "can", "be", "+", "1", "more", "in", "row", "and", "/", "or", "column", "than", "existing", "items...
python
train
alefnula/tea
tea/shell/__init__.py
https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/shell/__init__.py#L25-L37
def split(s, posix=True): """Split the string s using shell-like syntax. Args: s (str): String to split posix (bool): Use posix split Returns: list of str: List of string parts """ if isinstance(s, six.binary_type): s = s.decode("utf-8") return shlex.split(s, po...
[ "def", "split", "(", "s", ",", "posix", "=", "True", ")", ":", "if", "isinstance", "(", "s", ",", "six", ".", "binary_type", ")", ":", "s", "=", "s", ".", "decode", "(", "\"utf-8\"", ")", "return", "shlex", ".", "split", "(", "s", ",", "posix", ...
Split the string s using shell-like syntax. Args: s (str): String to split posix (bool): Use posix split Returns: list of str: List of string parts
[ "Split", "the", "string", "s", "using", "shell", "-", "like", "syntax", "." ]
python
train
tanghaibao/jcvi
jcvi/assembly/coverage.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/coverage.py#L96-L160
def bed_to_bedpe(bedfile, bedpefile, pairsbedfile=None, matesfile=None, ca=False, strand=False): """ This converts the bedfile to bedpefile, assuming the reads are from CA. """ fp = must_open(bedfile) fw = must_open(bedpefile, "w") if pairsbedfile: fwpairs = must_open(pairsbedfile, "w") ...
[ "def", "bed_to_bedpe", "(", "bedfile", ",", "bedpefile", ",", "pairsbedfile", "=", "None", ",", "matesfile", "=", "None", ",", "ca", "=", "False", ",", "strand", "=", "False", ")", ":", "fp", "=", "must_open", "(", "bedfile", ")", "fw", "=", "must_open...
This converts the bedfile to bedpefile, assuming the reads are from CA.
[ "This", "converts", "the", "bedfile", "to", "bedpefile", "assuming", "the", "reads", "are", "from", "CA", "." ]
python
train
ray-project/ray
python/ray/experimental/state.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/state.py#L528-L596
def chrome_tracing_dump(self, filename=None): """Return a list of profiling events that can viewed as a timeline. To view this information as a timeline, simply dump it as a json file by passing in "filename" or using using json.dump, and then load go to chrome://tracing in the Chrome w...
[ "def", "chrome_tracing_dump", "(", "self", ",", "filename", "=", "None", ")", ":", "# TODO(rkn): Support including the task specification data in the", "# timeline.", "# TODO(rkn): This should support viewing just a window of time or a", "# limited number of events.", "profile_table", ...
Return a list of profiling events that can viewed as a timeline. To view this information as a timeline, simply dump it as a json file by passing in "filename" or using using json.dump, and then load go to chrome://tracing in the Chrome web browser and load the dumped file. Make sure to...
[ "Return", "a", "list", "of", "profiling", "events", "that", "can", "viewed", "as", "a", "timeline", "." ]
python
train
saltstack/salt
salt/utils/schedule.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/schedule.py#L201-L246
def _check_max_running(self, func, data, opts, now): ''' Return the schedule data structure ''' # Check to see if there are other jobs with this # signature running. If there are more than maxrunning # jobs present then don't start another. # If jid_include is Fa...
[ "def", "_check_max_running", "(", "self", ",", "func", ",", "data", ",", "opts", ",", "now", ")", ":", "# Check to see if there are other jobs with this", "# signature running. If there are more than maxrunning", "# jobs present then don't start another.", "# If jid_include is Fal...
Return the schedule data structure
[ "Return", "the", "schedule", "data", "structure" ]
python
train
roclark/sportsreference
sportsreference/ncaab/roster.py
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/roster.py#L120-L138
def _retrieve_html_page(self): """ Download the requested player's stats page. Download the requested page and strip all of the comment tags before returning a pyquery object which will be used to parse the data. Returns ------- PyQuery object The re...
[ "def", "_retrieve_html_page", "(", "self", ")", ":", "url", "=", "PLAYER_URL", "%", "self", ".", "_player_id", "try", ":", "url_data", "=", "pq", "(", "url", ")", "except", "HTTPError", ":", "return", "None", "return", "pq", "(", "utils", ".", "_remove_h...
Download the requested player's stats page. Download the requested page and strip all of the comment tags before returning a pyquery object which will be used to parse the data. Returns ------- PyQuery object The requested page is returned as a queriable PyQuery obj...
[ "Download", "the", "requested", "player", "s", "stats", "page", "." ]
python
train
materialsproject/pymatgen
pymatgen/io/abinit/flows.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/flows.py#L1190-L1218
def show_tricky_tasks(self, verbose=0): """ Print list of tricky tasks i.e. tasks that have been restarted or launched more than once or tasks with corrections. Args: verbose: Verbosity level. If > 0, task history and corrections (if any) are printed. """ nid...
[ "def", "show_tricky_tasks", "(", "self", ",", "verbose", "=", "0", ")", ":", "nids", ",", "tasks", "=", "[", "]", ",", "[", "]", "for", "task", "in", "self", ".", "iflat_tasks", "(", ")", ":", "if", "task", ".", "num_launches", ">", "1", "or", "a...
Print list of tricky tasks i.e. tasks that have been restarted or launched more than once or tasks with corrections. Args: verbose: Verbosity level. If > 0, task history and corrections (if any) are printed.
[ "Print", "list", "of", "tricky", "tasks", "i", ".", "e", ".", "tasks", "that", "have", "been", "restarted", "or", "launched", "more", "than", "once", "or", "tasks", "with", "corrections", "." ]
python
train
pypyr/pypyr-cli
pypyr/steps/py.py
https://github.com/pypyr/pypyr-cli/blob/4003f999cd5eb030b4c7407317de728f5115a80f/pypyr/steps/py.py#L11-L35
def run_step(context): """Executes dynamic python code. Context is a dictionary or dictionary-like. Context must contain key 'pycode' Will exec context['pycode'] as dynamically interpreted python statements. context is mandatory. When you execute the pipeline, it should look something like thi...
[ "def", "run_step", "(", "context", ")", ":", "logger", ".", "debug", "(", "\"started\"", ")", "context", ".", "assert_key_has_value", "(", "key", "=", "'pycode'", ",", "caller", "=", "__name__", ")", "logger", ".", "debug", "(", "f\"Executing python string: {c...
Executes dynamic python code. Context is a dictionary or dictionary-like. Context must contain key 'pycode' Will exec context['pycode'] as dynamically interpreted python statements. context is mandatory. When you execute the pipeline, it should look something like this: pipeline-runner [na...
[ "Executes", "dynamic", "python", "code", "." ]
python
train
salimm/pylods
pylods/backend/pylodsc/mapper.py
https://github.com/salimm/pylods/blob/d089e2a9afb1fa8cb6c754933fc574b512757c40/pylods/backend/pylodsc/mapper.py#L95-L107
def copy(self): ''' makes a clone copy of the mapper. It won't clone the serializers or deserializers and it won't copy the events ''' try: tmp = self.__class__() except Exception: tmp = self.__class__(self._pdict) tmp._serializers = ...
[ "def", "copy", "(", "self", ")", ":", "try", ":", "tmp", "=", "self", ".", "__class__", "(", ")", "except", "Exception", ":", "tmp", "=", "self", ".", "__class__", "(", "self", ".", "_pdict", ")", "tmp", ".", "_serializers", "=", "self", ".", "_ser...
makes a clone copy of the mapper. It won't clone the serializers or deserializers and it won't copy the events
[ "makes", "a", "clone", "copy", "of", "the", "mapper", ".", "It", "won", "t", "clone", "the", "serializers", "or", "deserializers", "and", "it", "won", "t", "copy", "the", "events" ]
python
train
SoCo/SoCo
soco/core.py
https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L1531-L1581
def __get_favorites(self, favorite_type, start=0, max_items=100): """ Helper method for `get_favorite_radio_*` methods. Args: favorite_type (str): Specify either `RADIO_STATIONS` or `RADIO_SHOWS`. start (int): Which number to start the retrieval from. Used for ...
[ "def", "__get_favorites", "(", "self", ",", "favorite_type", ",", "start", "=", "0", ",", "max_items", "=", "100", ")", ":", "if", "favorite_type", "not", "in", "(", "RADIO_SHOWS", ",", "RADIO_STATIONS", ")", ":", "favorite_type", "=", "SONOS_FAVORITES", "re...
Helper method for `get_favorite_radio_*` methods. Args: favorite_type (str): Specify either `RADIO_STATIONS` or `RADIO_SHOWS`. start (int): Which number to start the retrieval from. Used for paging. max_items (int): The total number of results...
[ "Helper", "method", "for", "get_favorite_radio_", "*", "methods", "." ]
python
train
bloomreach/s4cmd
s4cmd.py
https://github.com/bloomreach/s4cmd/blob/bb51075bf43703e7cd95aa39288cf7732ec13a6d/s4cmd.py#L854-L864
def get_single_file(self, pool, source, target): '''Download a single file or a directory by adding a task into queue''' if source[-1] == PATH_SEP: if self.opt.recursive: basepath = S3URL(source).path for f in (f for f in self.s3walk(source) if not f['is_dir']): pool.download(f['...
[ "def", "get_single_file", "(", "self", ",", "pool", ",", "source", ",", "target", ")", ":", "if", "source", "[", "-", "1", "]", "==", "PATH_SEP", ":", "if", "self", ".", "opt", ".", "recursive", ":", "basepath", "=", "S3URL", "(", "source", ")", "....
Download a single file or a directory by adding a task into queue
[ "Download", "a", "single", "file", "or", "a", "directory", "by", "adding", "a", "task", "into", "queue" ]
python
test
eandersson/amqpstorm
amqpstorm/management/virtual_host.py
https://github.com/eandersson/amqpstorm/blob/38330906c0af19eea482f43c5ce79bab98a1e064/amqpstorm/management/virtual_host.py#L10-L21
def get(self, virtual_host): """Get Virtual Host details. :param str virtual_host: Virtual host name :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. :rtype: dict """ virtu...
[ "def", "get", "(", "self", ",", "virtual_host", ")", ":", "virtual_host", "=", "quote", "(", "virtual_host", ",", "''", ")", "return", "self", ".", "http_client", ".", "get", "(", "API_VIRTUAL_HOST", "%", "virtual_host", ")" ]
Get Virtual Host details. :param str virtual_host: Virtual host name :raises ApiError: Raises if the remote server encountered an error. :raises ApiConnectionError: Raises if there was a connectivity issue. :rtype: dict
[ "Get", "Virtual", "Host", "details", "." ]
python
train
maximtrp/scikit-posthocs
scikit_posthocs/_outliers.py
https://github.com/maximtrp/scikit-posthocs/blob/5476b09e2a325cd4e31c0b0bc6906ab5cd77fc5d/scikit_posthocs/_outliers.py#L115-L191
def outliers_tietjen(x, k, hypo = False, alpha = 0.05): """ Tietjen-Moore test [1]_ to detect multiple outliers in a univariate data set that follows an approximately normal distribution. The Tietjen-Moore test [2]_ is a generalization of the Grubbs' test to the case of multiple outliers. If testin...
[ "def", "outliers_tietjen", "(", "x", ",", "k", ",", "hypo", "=", "False", ",", "alpha", "=", "0.05", ")", ":", "n", "=", "x", ".", "size", "def", "tietjen", "(", "x_", ",", "k_", ")", ":", "x_mean", "=", "x_", ".", "mean", "(", ")", "r", "=",...
Tietjen-Moore test [1]_ to detect multiple outliers in a univariate data set that follows an approximately normal distribution. The Tietjen-Moore test [2]_ is a generalization of the Grubbs' test to the case of multiple outliers. If testing for a single outlier, the Tietjen-Moore test is equivalent to t...
[ "Tietjen", "-", "Moore", "test", "[", "1", "]", "_", "to", "detect", "multiple", "outliers", "in", "a", "univariate", "data", "set", "that", "follows", "an", "approximately", "normal", "distribution", ".", "The", "Tietjen", "-", "Moore", "test", "[", "2", ...
python
train
inveniosoftware-contrib/invenio-workflows
invenio_workflows/engine.py
https://github.com/inveniosoftware-contrib/invenio-workflows/blob/9c09fd29509a3db975ac2aba337e6760d8cfd3c2/invenio_workflows/engine.py#L368-L391
def WaitProcessing(obj, eng, callbacks, exc_info): """Take actions when WaitProcessing is raised. ..note:: We're essentially doing HaltProcessing, plus `obj.set_action` and object status `WAITING` instead of `HALTED`. This is not present in TransitionActions so that...
[ "def", "WaitProcessing", "(", "obj", ",", "eng", ",", "callbacks", ",", "exc_info", ")", ":", "e", "=", "exc_info", "[", "1", "]", "obj", ".", "set_action", "(", "e", ".", "action", ",", "e", ".", "message", ")", "obj", ".", "save", "(", "status", ...
Take actions when WaitProcessing is raised. ..note:: We're essentially doing HaltProcessing, plus `obj.set_action` and object status `WAITING` instead of `HALTED`. This is not present in TransitionActions so that's why it is not calling super in this case.
[ "Take", "actions", "when", "WaitProcessing", "is", "raised", "." ]
python
train
StellarCN/py-stellar-base
stellar_base/operation.py
https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/operation.py#L51-L60
def to_xdr_object(self): """Creates an XDR Operation object that represents this :class:`Operation`. """ try: source_account = [account_xdr_object(self.source)] except StellarAddressInvalidError: source_account = [] return Xdr.types.Operation(sour...
[ "def", "to_xdr_object", "(", "self", ")", ":", "try", ":", "source_account", "=", "[", "account_xdr_object", "(", "self", ".", "source", ")", "]", "except", "StellarAddressInvalidError", ":", "source_account", "=", "[", "]", "return", "Xdr", ".", "types", "....
Creates an XDR Operation object that represents this :class:`Operation`.
[ "Creates", "an", "XDR", "Operation", "object", "that", "represents", "this", ":", "class", ":", "Operation", "." ]
python
train
angr/angr
angr/factory.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/factory.py#L41-L54
def successors(self, *args, **kwargs): """ Perform execution using any applicable engine. Enumerate the current engines and use the first one that works. Return a SimSuccessors object classifying the results of the run. :param state: The state to analyze :param addr: ...
[ "def", "successors", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "project", ".", "engines", ".", "successors", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
Perform execution using any applicable engine. Enumerate the current engines and use the first one that works. Return a SimSuccessors object classifying the results of the run. :param state: The state to analyze :param addr: optional, an address to execute at instead of the...
[ "Perform", "execution", "using", "any", "applicable", "engine", ".", "Enumerate", "the", "current", "engines", "and", "use", "the", "first", "one", "that", "works", ".", "Return", "a", "SimSuccessors", "object", "classifying", "the", "results", "of", "the", "r...
python
train
andymccurdy/redis-py
redis/client.py
https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/client.py#L1641-L1643
def lset(self, name, index, value): "Set ``position`` of list ``name`` to ``value``" return self.execute_command('LSET', name, index, value)
[ "def", "lset", "(", "self", ",", "name", ",", "index", ",", "value", ")", ":", "return", "self", ".", "execute_command", "(", "'LSET'", ",", "name", ",", "index", ",", "value", ")" ]
Set ``position`` of list ``name`` to ``value``
[ "Set", "position", "of", "list", "name", "to", "value" ]
python
train
insilichem/ommprotocol
ommprotocol/io.py
https://github.com/insilichem/ommprotocol/blob/7283fddba7203e5ac3542fdab41fc1279d3b444e/ommprotocol/io.py#L434-L441
def write_pdb(self, path): """ Outputs a PDB file with the current contents of the system """ if self.master is None and self.positions is None: raise ValueError('Topology and positions are needed to write output files.') with open(path, 'w') as f: PDBFile...
[ "def", "write_pdb", "(", "self", ",", "path", ")", ":", "if", "self", ".", "master", "is", "None", "and", "self", ".", "positions", "is", "None", ":", "raise", "ValueError", "(", "'Topology and positions are needed to write output files.'", ")", "with", "open", ...
Outputs a PDB file with the current contents of the system
[ "Outputs", "a", "PDB", "file", "with", "the", "current", "contents", "of", "the", "system" ]
python
train
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/util.py
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/util.py#L39-L56
def inflate_long(s, always_positive=False): """turns a normalized byte string into a long-int (adapted from Crypto.Util.number)""" out = long(0) negative = 0 if not always_positive and (len(s) > 0) and (byte_ord(s[0]) >= 0x80): negative = 1 if len(s) % 4: filler = zero_byte i...
[ "def", "inflate_long", "(", "s", ",", "always_positive", "=", "False", ")", ":", "out", "=", "long", "(", "0", ")", "negative", "=", "0", "if", "not", "always_positive", "and", "(", "len", "(", "s", ")", ">", "0", ")", "and", "(", "byte_ord", "(", ...
turns a normalized byte string into a long-int (adapted from Crypto.Util.number)
[ "turns", "a", "normalized", "byte", "string", "into", "a", "long", "-", "int", "(", "adapted", "from", "Crypto", ".", "Util", ".", "number", ")" ]
python
train
kakwa/ldapcherry
ldapcherry/__init__.py
https://github.com/kakwa/ldapcherry/blob/b5e7cb6a44065abc30d164e72981b3713a172dda/ldapcherry/__init__.py#L1010-L1025
def searchadmin(self, searchstring=None): """ search user page """ self._check_auth(must_admin=True) is_admin = self._check_admin() if searchstring is not None: res = self._search(searchstring) else: res = None attrs_list = self.attributes.get_sear...
[ "def", "searchadmin", "(", "self", ",", "searchstring", "=", "None", ")", ":", "self", ".", "_check_auth", "(", "must_admin", "=", "True", ")", "is_admin", "=", "self", ".", "_check_admin", "(", ")", "if", "searchstring", "is", "not", "None", ":", "res",...
search user page
[ "search", "user", "page" ]
python
train
smarie/python-valid8
valid8/entry_points_annotations.py
https://github.com/smarie/python-valid8/blob/5e15d1de11602933c5114eb9f73277ad91d97800/valid8/entry_points_annotations.py#L352-L369
def validate_field(cls, field_name, *validation_func, # type: ValidationFuncs **kwargs): # type: (...) -> Callable """ A class decorator. It goes through all class variables and for all of those that are descriptors with a __set__, it wraps the d...
[ "def", "validate_field", "(", "cls", ",", "field_name", ",", "*", "validation_func", ",", "# type: ValidationFuncs", "*", "*", "kwargs", ")", ":", "# type: (...) -> Callable", "return", "decorate_cls_with_validation", "(", "cls", ",", "field_name", ",", "*", "valida...
A class decorator. It goes through all class variables and for all of those that are descriptors with a __set__, it wraps the descriptors' setter function with a `validate_arg` annotation :param field_name: :param validation_func: :param help_msg: :param error_type: :param none_policy: :par...
[ "A", "class", "decorator", ".", "It", "goes", "through", "all", "class", "variables", "and", "for", "all", "of", "those", "that", "are", "descriptors", "with", "a", "__set__", "it", "wraps", "the", "descriptors", "setter", "function", "with", "a", "validate_...
python
train
vmware/pyvmomi
pyVim/connect.py
https://github.com/vmware/pyvmomi/blob/3ffcb23bf77d757175c0d5216ba9a25345d824cd/pyVim/connect.py#L453-L463
def __Logout(si): """ Disconnect (logout) service instance @param si: Service instance (returned from Connect) """ try: if si: content = si.RetrieveContent() content.sessionManager.Logout() except Exception as e: pass
[ "def", "__Logout", "(", "si", ")", ":", "try", ":", "if", "si", ":", "content", "=", "si", ".", "RetrieveContent", "(", ")", "content", ".", "sessionManager", ".", "Logout", "(", ")", "except", "Exception", "as", "e", ":", "pass" ]
Disconnect (logout) service instance @param si: Service instance (returned from Connect)
[ "Disconnect", "(", "logout", ")", "service", "instance" ]
python
train
project-rig/rig
setup.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/setup.py#L13-L55
def replace_local_hyperlinks( text, base_url="https://github.com/project-rig/rig/blob/master/"): """Replace local hyperlinks in RST with absolute addresses using the given base URL. This is used to make links in the long description function correctly outside of the repository (e.g. when publis...
[ "def", "replace_local_hyperlinks", "(", "text", ",", "base_url", "=", "\"https://github.com/project-rig/rig/blob/master/\"", ")", ":", "def", "get_new_url", "(", "url", ")", ":", "return", "base_url", "+", "url", "[", "2", ":", "]", "# Deal with anonymous URLS", "fo...
Replace local hyperlinks in RST with absolute addresses using the given base URL. This is used to make links in the long description function correctly outside of the repository (e.g. when published on PyPi). NOTE: This may need adjusting if further syntax is used.
[ "Replace", "local", "hyperlinks", "in", "RST", "with", "absolute", "addresses", "using", "the", "given", "base", "URL", "." ]
python
train
celiao/rtsimple
rtsimple/lists.py
https://github.com/celiao/rtsimple/blob/91f82cbd61a745bbe3a2cca54dfbb6b0ac123b86/rtsimple/lists.py#L92-L106
def movies_opening(self, **kwargs): """Gets the current opening movies from the API. Args: limit (optional): limits the number of movies returned, default=10 country (optional): localized data for selected country, default="us" Returns: A dict respresentation of t...
[ "def", "movies_opening", "(", "self", ",", "*", "*", "kwargs", ")", ":", "path", "=", "self", ".", "_get_path", "(", "'movies_opening'", ")", "response", "=", "self", ".", "_GET", "(", "path", ",", "kwargs", ")", "self", ".", "_set_attrs_to_values", "(",...
Gets the current opening movies from the API. Args: limit (optional): limits the number of movies returned, default=10 country (optional): localized data for selected country, default="us" Returns: A dict respresentation of the JSON returned from the API.
[ "Gets", "the", "current", "opening", "movies", "from", "the", "API", "." ]
python
train
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_vswitch.py#L781-L792
def get_vnetwork_vswitches_output_instance_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches output = ET.SubElement(get_vnetwork_vswitches, "output") ...
[ "def", "get_vnetwork_vswitches_output_instance_id", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_vnetwork_vswitches", "=", "ET", ".", "Element", "(", "\"get_vnetwork_vswitches\"", ")", "config", ...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
dmlc/gluon-nlp
scripts/word_embeddings/extract_vocab.py
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/scripts/word_embeddings/extract_vocab.py#L32-L44
def parse_args(): """Parse command line arguments.""" parser = argparse.ArgumentParser( description='Vocabulary extractor.', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--max-size', type=int, default=None) parser.add_argument('--min-freq', type=int, defau...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Vocabulary extractor.'", ",", "formatter_class", "=", "argparse", ".", "ArgumentDefaultsHelpFormatter", ")", "parser", ".", "add_argument", "(", "'--max-...
Parse command line arguments.
[ "Parse", "command", "line", "arguments", "." ]
python
train
Kozea/pygal
pygal/graph/graph.py
https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/graph/graph.py#L555-L596
def _static_value( self, serie_node, value, x, y, metadata, align_text='left', classes=None ): """Write the print value""" label = metadata and metadata.get('label') classes = classes and [classes...
[ "def", "_static_value", "(", "self", ",", "serie_node", ",", "value", ",", "x", ",", "y", ",", "metadata", ",", "align_text", "=", "'left'", ",", "classes", "=", "None", ")", ":", "label", "=", "metadata", "and", "metadata", ".", "get", "(", "'label'",...
Write the print value
[ "Write", "the", "print", "value" ]
python
train
deepmipt/DeepPavlov
deeppavlov/core/layers/tf_layers.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/core/layers/tf_layers.py#L371-L430
def character_embedding_network(char_placeholder: tf.Tensor, n_characters: int = None, emb_mat: np.array = None, char_embedding_dim: int = None, filter_widths=(3, 4, 5, 7), ...
[ "def", "character_embedding_network", "(", "char_placeholder", ":", "tf", ".", "Tensor", ",", "n_characters", ":", "int", "=", "None", ",", "emb_mat", ":", "np", ".", "array", "=", "None", ",", "char_embedding_dim", ":", "int", "=", "None", ",", "filter_widt...
Characters to vector. Every sequence of characters (token) is embedded to vector space with dimensionality char_embedding_dim Convolution plus max_pooling is used to obtain vector representations of words. Args: char_placeholder: placeholder of int32 type with dimensionality [B, T, ...
[ "Characters", "to", "vector", ".", "Every", "sequence", "of", "characters", "(", "token", ")", "is", "embedded", "to", "vector", "space", "with", "dimensionality", "char_embedding_dim", "Convolution", "plus", "max_pooling", "is", "used", "to", "obtain", "vector", ...
python
test
osrg/ryu
ryu/lib/packet/bfd.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/packet/bfd.py#L262-L274
def pack(self): """ Encode a BFD Control packet without authentication section. """ diag = (self.ver << 5) + self.diag flags = (self.state << 6) + self.flags length = len(self) return struct.pack(self._PACK_STR, diag, flags, self.detect_mult, ...
[ "def", "pack", "(", "self", ")", ":", "diag", "=", "(", "self", ".", "ver", "<<", "5", ")", "+", "self", ".", "diag", "flags", "=", "(", "self", ".", "state", "<<", "6", ")", "+", "self", ".", "flags", "length", "=", "len", "(", "self", ")", ...
Encode a BFD Control packet without authentication section.
[ "Encode", "a", "BFD", "Control", "packet", "without", "authentication", "section", "." ]
python
train
deepmipt/DeepPavlov
deeppavlov/models/elmo/elmo2tfhub.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/models/elmo/elmo2tfhub.py#L190-L206
def export2hub(weight_file, hub_dir, options): """Exports a TF-Hub module """ spec = make_module_spec(options, str(weight_file)) try: with tf.Graph().as_default(): module = hub.Module(spec) with tf.Session() as sess: sess.run(tf.global_variables_initial...
[ "def", "export2hub", "(", "weight_file", ",", "hub_dir", ",", "options", ")", ":", "spec", "=", "make_module_spec", "(", "options", ",", "str", "(", "weight_file", ")", ")", "try", ":", "with", "tf", ".", "Graph", "(", ")", ".", "as_default", "(", ")",...
Exports a TF-Hub module
[ "Exports", "a", "TF", "-", "Hub", "module" ]
python
test
jart/fabulous
fabulous/term.py
https://github.com/jart/fabulous/blob/19903cf0a980b82f5928c3bec1f28b6bdd3785bd/fabulous/term.py#L517-L530
def _split_attributes(self, attrs): """Spilt attribute code Takes an attribute code and returns a tuple containing foreground (fg), foreground intensity (fgi), background (bg), and background intensity (bgi) Attributes can be joined using ``fg | fgi | bg | bgi``...
[ "def", "_split_attributes", "(", "self", ",", "attrs", ")", ":", "fg", "=", "attrs", "&", "self", ".", "FG_ALL", "fgi", "=", "attrs", "&", "self", ".", "FG_INTENSITY", "bg", "=", "attrs", "&", "self", ".", "BG_ALL", "bgi", "=", "attrs", "&", "self", ...
Spilt attribute code Takes an attribute code and returns a tuple containing foreground (fg), foreground intensity (fgi), background (bg), and background intensity (bgi) Attributes can be joined using ``fg | fgi | bg | bgi``
[ "Spilt", "attribute", "code", "Takes", "an", "attribute", "code", "and", "returns", "a", "tuple", "containing", "foreground", "(", "fg", ")", "foreground", "intensity", "(", "fgi", ")", "background", "(", "bg", ")", "and", "background", "intensity", "(", "bg...
python
train
almarklein/pyelastix
pyelastix.py
https://github.com/almarklein/pyelastix/blob/971a677ce9a3ef8eb0b95ae393db8e2506d2f8a4/pyelastix.py#L272-L337
def _system3(cmd, verbose=False): """ Execute the given command in a subprocess and wait for it to finish. A thread is run that prints output of the process if verbose is True. """ # Init flag interrupted = False # Create progress if verbose > 0: progress = Progress() ...
[ "def", "_system3", "(", "cmd", ",", "verbose", "=", "False", ")", ":", "# Init flag", "interrupted", "=", "False", "# Create progress", "if", "verbose", ">", "0", ":", "progress", "=", "Progress", "(", ")", "stdout", "=", "[", "]", "def", "poll_process", ...
Execute the given command in a subprocess and wait for it to finish. A thread is run that prints output of the process if verbose is True.
[ "Execute", "the", "given", "command", "in", "a", "subprocess", "and", "wait", "for", "it", "to", "finish", ".", "A", "thread", "is", "run", "that", "prints", "output", "of", "the", "process", "if", "verbose", "is", "True", "." ]
python
train
apache/incubator-mxnet
example/rnn/word_lm/module.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/word_lm/module.py#L78-L90
def forward(self, data_batch, is_train=None, carry_state=True): """Forward computation. States from previous forward computation are carried to the current iteration if `carry_state` is set to `True`. """ # propagate states from the previous iteration if carry_state: ...
[ "def", "forward", "(", "self", ",", "data_batch", ",", "is_train", "=", "None", ",", "carry_state", "=", "True", ")", ":", "# propagate states from the previous iteration", "if", "carry_state", ":", "if", "isinstance", "(", "self", ".", "_next_states", ",", "(",...
Forward computation. States from previous forward computation are carried to the current iteration if `carry_state` is set to `True`.
[ "Forward", "computation", ".", "States", "from", "previous", "forward", "computation", "are", "carried", "to", "the", "current", "iteration", "if", "carry_state", "is", "set", "to", "True", "." ]
python
train
MDAnalysis/GridDataFormats
gridData/core.py
https://github.com/MDAnalysis/GridDataFormats/blob/3eeb0432f8cf856912436e4f3e7aba99d3c916be/gridData/core.py#L389-L394
def _load_cpp4(self, filename): """Initializes Grid from a CCP4 file.""" ccp4 = CCP4.CCP4() ccp4.read(filename) grid, edges = ccp4.histogramdd() self.__init__(grid=grid, edges=edges, metadata=self.metadata)
[ "def", "_load_cpp4", "(", "self", ",", "filename", ")", ":", "ccp4", "=", "CCP4", ".", "CCP4", "(", ")", "ccp4", ".", "read", "(", "filename", ")", "grid", ",", "edges", "=", "ccp4", ".", "histogramdd", "(", ")", "self", ".", "__init__", "(", "grid...
Initializes Grid from a CCP4 file.
[ "Initializes", "Grid", "from", "a", "CCP4", "file", "." ]
python
valid
quantmind/pulsar
pulsar/utils/pylib/events.py
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/events.py#L56-L66
def unbind(self, callback): """Remove a callback from the list """ handlers = self._handlers if handlers: filtered_callbacks = [f for f in handlers if f != callback] removed_count = len(handlers) - len(filtered_callbacks) if removed_count: ...
[ "def", "unbind", "(", "self", ",", "callback", ")", ":", "handlers", "=", "self", ".", "_handlers", "if", "handlers", ":", "filtered_callbacks", "=", "[", "f", "for", "f", "in", "handlers", "if", "f", "!=", "callback", "]", "removed_count", "=", "len", ...
Remove a callback from the list
[ "Remove", "a", "callback", "from", "the", "list" ]
python
train
tensorflow/mesh
mesh_tensorflow/ops.py
https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/ops.py#L1254-L1268
def convert_args_to_laid_out_tensors(xs): """Convert list elements to laid-out-tensors when possible. Args: xs: a list Returns: a list """ ret = [] for x in xs: if hasattr(x, "to_laid_out_tensor"): ret.append(x.to_laid_out_tensor()) else: ret.append(x) return ret
[ "def", "convert_args_to_laid_out_tensors", "(", "xs", ")", ":", "ret", "=", "[", "]", "for", "x", "in", "xs", ":", "if", "hasattr", "(", "x", ",", "\"to_laid_out_tensor\"", ")", ":", "ret", ".", "append", "(", "x", ".", "to_laid_out_tensor", "(", ")", ...
Convert list elements to laid-out-tensors when possible. Args: xs: a list Returns: a list
[ "Convert", "list", "elements", "to", "laid", "-", "out", "-", "tensors", "when", "possible", "." ]
python
train
Carreau/warn
warn/warn.py
https://github.com/Carreau/warn/blob/251ed08bc13b536c47392ba577f86e1f96bdad6b/warn/warn.py#L28-L115
def warn_explicit(message, category, filename, lineno, module=None, registry=None, module_globals=None, emit_module=None): """ Low level implementation of the warning functionality. Duplicate of the standard library `warnings.warn_explicit`, except it accepts ...
[ "def", "warn_explicit", "(", "message", ",", "category", ",", "filename", ",", "lineno", ",", "module", "=", "None", ",", "registry", "=", "None", ",", "module_globals", "=", "None", ",", "emit_module", "=", "None", ")", ":", "lineno", "=", "int", "(", ...
Low level implementation of the warning functionality. Duplicate of the standard library `warnings.warn_explicit`, except it accepts the following arguments: `emit_module`: regular expression that should match the module the warnings are emitted from.
[ "Low", "level", "implementation", "of", "the", "warning", "functionality", ".", "Duplicate", "of", "the", "standard", "library", "warnings", ".", "warn_explicit", "except", "it", "accepts", "the", "following", "arguments", ":" ]
python
train
mikekatz04/BOWIE
snr_calculator_folder/gwsnrcalc/utils/waveforms.py
https://github.com/mikekatz04/BOWIE/blob/a941342a3536cb57c817a1643896d99a3f354a86/snr_calculator_folder/gwsnrcalc/utils/waveforms.py#L534-L539
def _hcn_func(self): """Eq. 56 from Barack and Cutler 2004 """ self.hc = 1./(np.pi*self.dist)*np.sqrt(2.*self._dEndfr()) return
[ "def", "_hcn_func", "(", "self", ")", ":", "self", ".", "hc", "=", "1.", "/", "(", "np", ".", "pi", "*", "self", ".", "dist", ")", "*", "np", ".", "sqrt", "(", "2.", "*", "self", ".", "_dEndfr", "(", ")", ")", "return" ]
Eq. 56 from Barack and Cutler 2004
[ "Eq", ".", "56", "from", "Barack", "and", "Cutler", "2004" ]
python
train
CalebBell/fpi
fpi/drag.py
https://github.com/CalebBell/fpi/blob/6e6da3b9d0c17e10cc0886c97bc1bb8aeba2cca5/fpi/drag.py#L834-L885
def Almedeij(Re): r'''Calculates drag coefficient of a smooth sphere using the method in [1]_ as described in [2]_. .. math:: C_D = \left[\frac{1}{(\phi_1 + \phi_2)^{-1} + (\phi_3)^{-1}} + \phi_4\right]^{0.1} \phi_1 = (24Re^{-1})^{10} + (21Re^{-0.67})^{10} + (4Re^{-0.33})^{10} + 0.4^{10} ...
[ "def", "Almedeij", "(", "Re", ")", ":", "phi4", "=", "(", "(", "6E-17", "*", "Re", "**", "2.63", ")", "**", "-", "10", "+", "0.2", "**", "-", "10", ")", "**", "-", "1", "phi3", "=", "(", "1.57E8", "*", "Re", "**", "-", "1.625", ")", "**", ...
r'''Calculates drag coefficient of a smooth sphere using the method in [1]_ as described in [2]_. .. math:: C_D = \left[\frac{1}{(\phi_1 + \phi_2)^{-1} + (\phi_3)^{-1}} + \phi_4\right]^{0.1} \phi_1 = (24Re^{-1})^{10} + (21Re^{-0.67})^{10} + (4Re^{-0.33})^{10} + 0.4^{10} \phi_2 = \left...
[ "r", "Calculates", "drag", "coefficient", "of", "a", "smooth", "sphere", "using", "the", "method", "in", "[", "1", "]", "_", "as", "described", "in", "[", "2", "]", "_", "." ]
python
train
spdx/tools-python
spdx/parsers/lexers/tagvalue.py
https://github.com/spdx/tools-python/blob/301d72f6ae57c832c1da7f6402fa49b192de6810/spdx/parsers/lexers/tagvalue.py#L104-L112
def t_text_end(self, t): r'</text>\s*' t.type = 'TEXT' t.value = t.lexer.lexdata[ t.lexer.text_start:t.lexer.lexpos] t.lexer.lineno += t.value.count('\n') t.value = t.value.strip() t.lexer.begin('INITIAL') return t
[ "def", "t_text_end", "(", "self", ",", "t", ")", ":", "t", ".", "type", "=", "'TEXT'", "t", ".", "value", "=", "t", ".", "lexer", ".", "lexdata", "[", "t", ".", "lexer", ".", "text_start", ":", "t", ".", "lexer", ".", "lexpos", "]", "t", ".", ...
r'</text>\s*
[ "r", "<", "/", "text", ">", "\\", "s", "*" ]
python
valid
UCL-INGI/INGInious
inginious/frontend/arch_helper.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/arch_helper.py#L33-L47
def _run_asyncio(loop, zmq_context): """ Run asyncio (should be called in a thread) and close the loop and the zmq context when the thread ends :param loop: :param zmq_context: :return: """ try: asyncio.set_event_loop(loop) loop.run_forever() except: pass fina...
[ "def", "_run_asyncio", "(", "loop", ",", "zmq_context", ")", ":", "try", ":", "asyncio", ".", "set_event_loop", "(", "loop", ")", "loop", ".", "run_forever", "(", ")", "except", ":", "pass", "finally", ":", "loop", ".", "close", "(", ")", "zmq_context", ...
Run asyncio (should be called in a thread) and close the loop and the zmq context when the thread ends :param loop: :param zmq_context: :return:
[ "Run", "asyncio", "(", "should", "be", "called", "in", "a", "thread", ")", "and", "close", "the", "loop", "and", "the", "zmq", "context", "when", "the", "thread", "ends", ":", "param", "loop", ":", ":", "param", "zmq_context", ":", ":", "return", ":" ]
python
train
ajyoon/blur
examples/waves/waves.py
https://github.com/ajyoon/blur/blob/25fcf083af112bb003956a7a7e1c6ff7d8fef279/examples/waves/waves.py#L182-L221
def build_chunk(oscillators): """ Build an audio chunk and progress the oscillator states. Args: oscillators (list): A list of oscillator.Oscillator objects to build chunks from Returns: str: a string of audio sample bytes ready to be written to a wave file """ step...
[ "def", "build_chunk", "(", "oscillators", ")", ":", "step_random_processes", "(", "oscillators", ")", "subchunks", "=", "[", "]", "for", "osc", "in", "oscillators", ":", "osc", ".", "amplitude", ".", "step_amp", "(", ")", "osc_chunk", "=", "osc", ".", "get...
Build an audio chunk and progress the oscillator states. Args: oscillators (list): A list of oscillator.Oscillator objects to build chunks from Returns: str: a string of audio sample bytes ready to be written to a wave file
[ "Build", "an", "audio", "chunk", "and", "progress", "the", "oscillator", "states", "." ]
python
train
Telefonica/toolium
toolium/behave/env_utils.py
https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/behave/env_utils.py#L237-L247
def execute_before_scenario_steps(self, context): """ actions before each scenario :param context: It’s a clever place where you and behave can store information to share around, automatically managed by behave. """ if not self.feature_error: self.__execute_steps_by_a...
[ "def", "execute_before_scenario_steps", "(", "self", ",", "context", ")", ":", "if", "not", "self", ".", "feature_error", ":", "self", ".", "__execute_steps_by_action", "(", "context", ",", "ACTIONS_BEFORE_SCENARIO", ")", "if", "context", ".", "dyn_env", ".", "s...
actions before each scenario :param context: It’s a clever place where you and behave can store information to share around, automatically managed by behave.
[ "actions", "before", "each", "scenario", ":", "param", "context", ":", "It’s", "a", "clever", "place", "where", "you", "and", "behave", "can", "store", "information", "to", "share", "around", "automatically", "managed", "by", "behave", "." ]
python
train
barryp/py-amqplib
amqplib/client_0_8/method_framing.py
https://github.com/barryp/py-amqplib/blob/2b3a47de34b4712c111d0a55d7ff109dffc2a7b2/amqplib/client_0_8/method_framing.py#L174-L193
def _process_content_header(self, channel, payload): """ Process Content Header frames """ partial = self.partial_messages[channel] partial.add_header(payload) if partial.complete: # # a bodyless message, we're done # self...
[ "def", "_process_content_header", "(", "self", ",", "channel", ",", "payload", ")", ":", "partial", "=", "self", ".", "partial_messages", "[", "channel", "]", "partial", ".", "add_header", "(", "payload", ")", "if", "partial", ".", "complete", ":", "#", "#...
Process Content Header frames
[ "Process", "Content", "Header", "frames" ]
python
train
blackecho/Deep-Learning-TensorFlow
yadlt/models/convolutional/conv_net.py
https://github.com/blackecho/Deep-Learning-TensorFlow/blob/ddeb1f2848da7b7bee166ad2152b4afc46bb2086/yadlt/models/convolutional/conv_net.py#L279-L283
def max_pool(x, dim): """Max pooling operation.""" return tf.nn.max_pool( x, ksize=[1, dim, dim, 1], strides=[1, dim, dim, 1], padding='SAME')
[ "def", "max_pool", "(", "x", ",", "dim", ")", ":", "return", "tf", ".", "nn", ".", "max_pool", "(", "x", ",", "ksize", "=", "[", "1", ",", "dim", ",", "dim", ",", "1", "]", ",", "strides", "=", "[", "1", ",", "dim", ",", "dim", ",", "1", ...
Max pooling operation.
[ "Max", "pooling", "operation", "." ]
python
train
elehcimd/pynb
fabfile.py
https://github.com/elehcimd/pynb/blob/a32af1f0e574f880eccda4a46aede6d65151f8c9/fabfile.py#L68-L87
def git_push(): """ Push new version and corresponding tag to origin :return: """ # get current version new_version = version.__version__ values = list(map(lambda x: int(x), new_version.split('.'))) # Push to origin new version and corresponding tag: # * commit new version # * ...
[ "def", "git_push", "(", ")", ":", "# get current version", "new_version", "=", "version", ".", "__version__", "values", "=", "list", "(", "map", "(", "lambda", "x", ":", "int", "(", "x", ")", ",", "new_version", ".", "split", "(", "'.'", ")", ")", ")",...
Push new version and corresponding tag to origin :return:
[ "Push", "new", "version", "and", "corresponding", "tag", "to", "origin", ":", "return", ":" ]
python
train
dagster-io/dagster
python_modules/dagster/dagster/core/definitions/decorators.py
https://github.com/dagster-io/dagster/blob/4119f8c773089de64831b1dfb9e168e353d401dc/python_modules/dagster/dagster/core/definitions/decorators.py#L173-L271
def solid(name=None, inputs=None, outputs=None, config_field=None, description=None): '''(decorator) Create a solid with specified parameters. This shortcut simplifies the core solid API by exploding arguments into kwargs of the transform function and omitting additional parameters when they are not needed...
[ "def", "solid", "(", "name", "=", "None", ",", "inputs", "=", "None", ",", "outputs", "=", "None", ",", "config_field", "=", "None", ",", "description", "=", "None", ")", ":", "# This case is for when decorator is used bare, without arguments. e.g. @solid versus @soli...
(decorator) Create a solid with specified parameters. This shortcut simplifies the core solid API by exploding arguments into kwargs of the transform function and omitting additional parameters when they are not needed. Parameters are otherwise as in the core API, :py:class:`SolidDefinition`. The deco...
[ "(", "decorator", ")", "Create", "a", "solid", "with", "specified", "parameters", "." ]
python
test
ashmastaflash/kal-wrapper
kalibrate/fn.py
https://github.com/ashmastaflash/kal-wrapper/blob/80ee03ab7bd3172ac26b769d6b442960f3424b0e/kalibrate/fn.py#L65-L69
def to_eng(num_in): """Return number in engineering notation.""" x = decimal.Decimal(str(num_in)) eng_not = x.normalize().to_eng_string() return(eng_not)
[ "def", "to_eng", "(", "num_in", ")", ":", "x", "=", "decimal", ".", "Decimal", "(", "str", "(", "num_in", ")", ")", "eng_not", "=", "x", ".", "normalize", "(", ")", ".", "to_eng_string", "(", ")", "return", "(", "eng_not", ")" ]
Return number in engineering notation.
[ "Return", "number", "in", "engineering", "notation", "." ]
python
train
victorlei/smop
smop/parse.py
https://github.com/victorlei/smop/blob/bdad96b715d1dd75ce8ab4724f76b9b1bb1f61cd/smop/parse.py#L455-L460
def p_expr_stmt(p): """ expr_stmt : expr_list SEMI """ assert isinstance(p[1], node.expr_list) p[0] = node.expr_stmt(expr=p[1])
[ "def", "p_expr_stmt", "(", "p", ")", ":", "assert", "isinstance", "(", "p", "[", "1", "]", ",", "node", ".", "expr_list", ")", "p", "[", "0", "]", "=", "node", ".", "expr_stmt", "(", "expr", "=", "p", "[", "1", "]", ")" ]
expr_stmt : expr_list SEMI
[ "expr_stmt", ":", "expr_list", "SEMI" ]
python
train
inasafe/inasafe
safe/gui/tools/options_dialog.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/options_dialog.py#L914-L919
def set_welcome_message(self): """Create and insert welcome message.""" string = html_header() string += welcome_message().to_html() string += html_footer() self.welcome_message.setHtml(string)
[ "def", "set_welcome_message", "(", "self", ")", ":", "string", "=", "html_header", "(", ")", "string", "+=", "welcome_message", "(", ")", ".", "to_html", "(", ")", "string", "+=", "html_footer", "(", ")", "self", ".", "welcome_message", ".", "setHtml", "("...
Create and insert welcome message.
[ "Create", "and", "insert", "welcome", "message", "." ]
python
train
acutesoftware/AIKIF
aikif/toolbox/Toolbox.py
https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/toolbox/Toolbox.py#L98-L107
def verify(self, tool): """ check that the tool exists """ if os.path.isfile(tool['file']): print('Toolbox: program exists = TOK :: ' + tool['file']) return True else: print('Toolbox: program exists = FAIL :: ' + tool['file']) retu...
[ "def", "verify", "(", "self", ",", "tool", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "tool", "[", "'file'", "]", ")", ":", "print", "(", "'Toolbox: program exists = TOK :: '", "+", "tool", "[", "'file'", "]", ")", "return", "True", "else"...
check that the tool exists
[ "check", "that", "the", "tool", "exists" ]
python
train
streamlink/streamlink
src/streamlink/plugin/api/validate.py
https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugin/api/validate.py#L154-L177
def get(item, default=None): """Get item from value (value[item]). If the item is not found, return the default. Handles XML elements, regex matches and anything that has __getitem__. """ def getter(value): if ET.iselement(value): value = value.attrib try: ...
[ "def", "get", "(", "item", ",", "default", "=", "None", ")", ":", "def", "getter", "(", "value", ")", ":", "if", "ET", ".", "iselement", "(", "value", ")", ":", "value", "=", "value", ".", "attrib", "try", ":", "# Use .group() if this is a regex match ob...
Get item from value (value[item]). If the item is not found, return the default. Handles XML elements, regex matches and anything that has __getitem__.
[ "Get", "item", "from", "value", "(", "value", "[", "item", "]", ")", "." ]
python
test