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
abseil/abseil-py
absl/flags/argparse_flags.py
https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/argparse_flags.py#L212-L235
def _define_absl_flag(self, flag_instance, suppress): """Defines a flag from the flag_instance.""" flag_name = flag_instance.name short_name = flag_instance.short_name argument_names = ['--' + flag_name] if short_name: argument_names.insert(0, '-' + short_name) if suppress: helptext ...
[ "def", "_define_absl_flag", "(", "self", ",", "flag_instance", ",", "suppress", ")", ":", "flag_name", "=", "flag_instance", ".", "name", "short_name", "=", "flag_instance", ".", "short_name", "argument_names", "=", "[", "'--'", "+", "flag_name", "]", "if", "s...
Defines a flag from the flag_instance.
[ "Defines", "a", "flag", "from", "the", "flag_instance", "." ]
python
train
iotile/coretools
transport_plugins/native_ble/iotile_transport_native_ble/device_adapter.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/native_ble/iotile_transport_native_ble/device_adapter.py#L318-L352
def _on_services_probed(self, success, result, failure_reason, context): """Callback called when the services has been probed. It is executed in the baBLE working thread: should not be blocking. Args: success (bool): A bool indicating that the operation is successful or not ...
[ "def", "_on_services_probed", "(", "self", ",", "success", ",", "result", ",", "failure_reason", ",", "context", ")", ":", "connection_id", "=", "context", "[", "'connection_id'", "]", "if", "not", "success", ":", "self", ".", "_logger", ".", "error", "(", ...
Callback called when the services has been probed. It is executed in the baBLE working thread: should not be blocking. Args: success (bool): A bool indicating that the operation is successful or not result (dict): Information probed (if successful) - services (list...
[ "Callback", "called", "when", "the", "services", "has", "been", "probed", ".", "It", "is", "executed", "in", "the", "baBLE", "working", "thread", ":", "should", "not", "be", "blocking", "." ]
python
train
davidfokkema/artist
demo/demo_fourier_with_legend.py
https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/demo/demo_fourier_with_legend.py#L26-L32
def fourier(x, N): """Fourier approximation with N terms""" term = 0. for n in range(1, N, 2): term += (1. / n) * math.sin(n * math.pi * x / L) return (4. / (math.pi)) * term
[ "def", "fourier", "(", "x", ",", "N", ")", ":", "term", "=", "0.", "for", "n", "in", "range", "(", "1", ",", "N", ",", "2", ")", ":", "term", "+=", "(", "1.", "/", "n", ")", "*", "math", ".", "sin", "(", "n", "*", "math", ".", "pi", "*"...
Fourier approximation with N terms
[ "Fourier", "approximation", "with", "N", "terms" ]
python
train
cltrudeau/django-awl
awl/admintools.py
https://github.com/cltrudeau/django-awl/blob/70d469ef9a161c1170b53aa017cf02d7c15eb90c/awl/admintools.py#L12-L32
def admin_obj_link(obj, display=''): """Returns a link to the django admin change list with a filter set to only the object given. :param obj: Object to create the admin change list display link for :param display: Text to display in the link. Defaults to string call of the object ...
[ "def", "admin_obj_link", "(", "obj", ",", "display", "=", "''", ")", ":", "# get the url for the change list for this object", "url", "=", "reverse", "(", "'admin:%s_%s_changelist'", "%", "(", "obj", ".", "_meta", ".", "app_label", ",", "obj", ".", "_meta", ".",...
Returns a link to the django admin change list with a filter set to only the object given. :param obj: Object to create the admin change list display link for :param display: Text to display in the link. Defaults to string call of the object :returns: Text containing HTML for a...
[ "Returns", "a", "link", "to", "the", "django", "admin", "change", "list", "with", "a", "filter", "set", "to", "only", "the", "object", "given", "." ]
python
valid
peterldowns/djoauth2
djoauth2/helpers.py
https://github.com/peterldowns/djoauth2/blob/151c7619d1d7a91d720397cfecf3a29fcc9747a9/djoauth2/helpers.py#L51-L90
def update_parameters(url, parameters, encoding='utf8'): """ Updates a URL's existing GET parameters. :param url: a base URL to which to add additional parameters. :param parameters: a dictionary of parameters, any mix of unicode and string objects as the parameters and the values. :parameter encoding: the...
[ "def", "update_parameters", "(", "url", ",", "parameters", ",", "encoding", "=", "'utf8'", ")", ":", "# Convert the base URL to the default encoding.", "if", "isinstance", "(", "url", ",", "unicode", ")", ":", "url", "=", "url", ".", "encode", "(", "encoding", ...
Updates a URL's existing GET parameters. :param url: a base URL to which to add additional parameters. :param parameters: a dictionary of parameters, any mix of unicode and string objects as the parameters and the values. :parameter encoding: the byte encoding to use when passed unicode for the base URL ...
[ "Updates", "a", "URL", "s", "existing", "GET", "parameters", "." ]
python
train
googledatalab/pydatalab
datalab/bigquery/_query_job.py
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/datalab/bigquery/_query_job.py#L63-L99
def wait(self, timeout=None): """ Wait for the job to complete, or a timeout to happen. This is more efficient than the version in the base Job class, in that we can use a call that blocks for the poll duration rather than a sleep. That means we shouldn't block unnecessarily long and can also pol...
[ "def", "wait", "(", "self", ",", "timeout", "=", "None", ")", ":", "poll", "=", "30", "while", "not", "self", ".", "_is_complete", ":", "try", ":", "query_result", "=", "self", ".", "_api", ".", "jobs_query_results", "(", "self", ".", "_job_id", ",", ...
Wait for the job to complete, or a timeout to happen. This is more efficient than the version in the base Job class, in that we can use a call that blocks for the poll duration rather than a sleep. That means we shouldn't block unnecessarily long and can also poll less. Args: timeout: how ...
[ "Wait", "for", "the", "job", "to", "complete", "or", "a", "timeout", "to", "happen", "." ]
python
train
seanpar203/event-bus
event_bus/bus.py
https://github.com/seanpar203/event-bus/blob/60319b9eb4e38c348e80f3ec625312eda75da765/event_bus/bus.py#L202-L212
def _event_funcs(self, event: str) -> Iterable[Callable]: """ Returns an Iterable of the functions subscribed to a event. :param event: Name of the event. :type event: str :return: A iterable to do things with. :rtype: Iterable """ for func in self._events[event...
[ "def", "_event_funcs", "(", "self", ",", "event", ":", "str", ")", "->", "Iterable", "[", "Callable", "]", ":", "for", "func", "in", "self", ".", "_events", "[", "event", "]", ":", "yield", "func" ]
Returns an Iterable of the functions subscribed to a event. :param event: Name of the event. :type event: str :return: A iterable to do things with. :rtype: Iterable
[ "Returns", "an", "Iterable", "of", "the", "functions", "subscribed", "to", "a", "event", "." ]
python
train
craffel/mir_eval
mir_eval/multipitch.py
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/multipitch.py#L456-L507
def evaluate(ref_time, ref_freqs, est_time, est_freqs, **kwargs): """Evaluate two multipitch (multi-f0) transcriptions, where the first is treated as the reference (ground truth) and the second as the estimate to be evaluated (prediction). Examples -------- >>> ref_time, ref_freq = mir_eval.io....
[ "def", "evaluate", "(", "ref_time", ",", "ref_freqs", ",", "est_time", ",", "est_freqs", ",", "*", "*", "kwargs", ")", ":", "scores", "=", "collections", ".", "OrderedDict", "(", ")", "(", "scores", "[", "'Precision'", "]", ",", "scores", "[", "'Recall'"...
Evaluate two multipitch (multi-f0) transcriptions, where the first is treated as the reference (ground truth) and the second as the estimate to be evaluated (prediction). Examples -------- >>> ref_time, ref_freq = mir_eval.io.load_ragged_time_series('ref.txt') >>> est_time, est_freq = mir_eval....
[ "Evaluate", "two", "multipitch", "(", "multi", "-", "f0", ")", "transcriptions", "where", "the", "first", "is", "treated", "as", "the", "reference", "(", "ground", "truth", ")", "and", "the", "second", "as", "the", "estimate", "to", "be", "evaluated", "(",...
python
train
notifiers/notifiers
notifiers_cli/utils/callbacks.py
https://github.com/notifiers/notifiers/blob/6dd8aafff86935dbb4763db9c56f9cdd7fc08b65/notifiers_cli/utils/callbacks.py#L49-L59
def _resource(resource, pretty: bool = None, **data): """The callback func that will be hooked to the generic resource commands""" data = clean_data(data) ctx = click.get_current_context() if ctx.obj.get("env_prefix"): data["env_prefix"] = ctx.obj["env_prefix"] rsp = resource(**data) d...
[ "def", "_resource", "(", "resource", ",", "pretty", ":", "bool", "=", "None", ",", "*", "*", "data", ")", ":", "data", "=", "clean_data", "(", "data", ")", "ctx", "=", "click", ".", "get_current_context", "(", ")", "if", "ctx", ".", "obj", ".", "ge...
The callback func that will be hooked to the generic resource commands
[ "The", "callback", "func", "that", "will", "be", "hooked", "to", "the", "generic", "resource", "commands" ]
python
train
ActivisionGameScience/assertpy
assertpy/assertpy.py
https://github.com/ActivisionGameScience/assertpy/blob/08d799cdb01f9a25d3e20672efac991c7bc26d79/assertpy/assertpy.py#L101-L131
def contents_of(f, encoding='utf-8'): """Helper to read the contents of the given file or path into a string with the given encoding. Encoding defaults to 'utf-8', other useful encodings are 'ascii' and 'latin-1'.""" try: contents = f.read() except AttributeError: try: with ...
[ "def", "contents_of", "(", "f", ",", "encoding", "=", "'utf-8'", ")", ":", "try", ":", "contents", "=", "f", ".", "read", "(", ")", "except", "AttributeError", ":", "try", ":", "with", "open", "(", "f", ",", "'r'", ")", "as", "fp", ":", "contents",...
Helper to read the contents of the given file or path into a string with the given encoding. Encoding defaults to 'utf-8', other useful encodings are 'ascii' and 'latin-1'.
[ "Helper", "to", "read", "the", "contents", "of", "the", "given", "file", "or", "path", "into", "a", "string", "with", "the", "given", "encoding", ".", "Encoding", "defaults", "to", "utf", "-", "8", "other", "useful", "encodings", "are", "ascii", "and", "...
python
valid
CalebBell/fluids
fluids/geometry.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1130-L1189
def SA_torispheroidal(D, fd, fk): r'''Calculates surface area of a torispherical head according to [1]_. Somewhat involved. Equations are adapted to be used for a full head. .. math:: SA = S_1 + S_2 .. math:: S_1 = 2\pi D^2 f_d \alpha .. math:: S_2 = 2\pi D^2 f_k\left(\alp...
[ "def", "SA_torispheroidal", "(", "D", ",", "fd", ",", "fk", ")", ":", "alpha_1", "=", "fd", "*", "(", "1", "-", "(", "1", "-", "(", "(", "0.5", "-", "fk", ")", "/", "(", "fd", "-", "fk", ")", ")", "**", "2", ")", "**", "0.5", ")", "alpha_...
r'''Calculates surface area of a torispherical head according to [1]_. Somewhat involved. Equations are adapted to be used for a full head. .. math:: SA = S_1 + S_2 .. math:: S_1 = 2\pi D^2 f_d \alpha .. math:: S_2 = 2\pi D^2 f_k\left(\alpha - \alpha_1 + (0.5 - f_k)\left(\sin^...
[ "r", "Calculates", "surface", "area", "of", "a", "torispherical", "head", "according", "to", "[", "1", "]", "_", ".", "Somewhat", "involved", ".", "Equations", "are", "adapted", "to", "be", "used", "for", "a", "full", "head", "." ]
python
train
spyder-ide/spyder
spyder/plugins/ipythonconsole/widgets/client.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L305-L312
def stop_button_click_handler(self): """Method to handle what to do when the stop button is pressed""" self.stop_button.setDisabled(True) # Interrupt computations or stop debugging if not self.shellwidget._reading: self.interrupt_kernel() else: self...
[ "def", "stop_button_click_handler", "(", "self", ")", ":", "self", ".", "stop_button", ".", "setDisabled", "(", "True", ")", "# Interrupt computations or stop debugging\r", "if", "not", "self", ".", "shellwidget", ".", "_reading", ":", "self", ".", "interrupt_kernel...
Method to handle what to do when the stop button is pressed
[ "Method", "to", "handle", "what", "to", "do", "when", "the", "stop", "button", "is", "pressed" ]
python
train
RI-imaging/qpsphere
qpsphere/models/_bhfield/wrap.py
https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/_bhfield/wrap.py#L224-L303
def run_simulation(wdir, arp=True, **kwargs): """ Example ------- 100-nm silica sphere with 10-nm thick Ag coating, embedded in water; arprec 20 digits; illuminated with YAG (1064nm); scan xz plane (21x21, +-200nm) bhfield-arp-db.exe mpdigit wl r_core r_coat n_grid_x ...
[ "def", "run_simulation", "(", "wdir", ",", "arp", "=", "True", ",", "*", "*", "kwargs", ")", ":", "wdir", "=", "pathlib", ".", "Path", "(", "wdir", ")", "cmd", "=", "\"{pathbhfield} {mpdigit} {wl:f} {r_core:f} {r_coat:f} \"", "+", "\"{n_grid_x:d} {xspan_min:f} {xs...
Example ------- 100-nm silica sphere with 10-nm thick Ag coating, embedded in water; arprec 20 digits; illuminated with YAG (1064nm); scan xz plane (21x21, +-200nm) bhfield-arp-db.exe mpdigit wl r_core r_coat n_grid_x xspan_min xspan_max n_grid_y yspan_...
[ "Example", "-------", "100", "-", "nm", "silica", "sphere", "with", "10", "-", "nm", "thick", "Ag", "coating", "embedded", "in", "water", ";", "arprec", "20", "digits", ";", "illuminated", "with", "YAG", "(", "1064nm", ")", ";", "scan", "xz", "plane", ...
python
train
Basic-Components/msgpack-rpc-protocol
python/pymprpc/mixins/encoder_decoder_mixin.py
https://github.com/Basic-Components/msgpack-rpc-protocol/blob/7983ace5d5cfd7214df6803f9b1de458df5fe3b1/python/pymprpc/mixins/encoder_decoder_mixin.py#L66-L91
def decoder(self, response: bytes): """编码请求为bytes. 检查是否使用debug模式和是否对数据进行压缩.之后根据状态将python字典形式的请求编码为字节串. Parameters: response (bytes): - 响应的字节串编码 Return: (Dict[str, Any]): - python字典形式的响应 """ response = response[:-(len(self.SEPARATOR))] ...
[ "def", "decoder", "(", "self", ",", "response", ":", "bytes", ")", ":", "response", "=", "response", "[", ":", "-", "(", "len", "(", "self", ".", "SEPARATOR", ")", ")", "]", "if", "self", ".", "compreser", "is", "not", "None", ":", "response", "=",...
编码请求为bytes. 检查是否使用debug模式和是否对数据进行压缩.之后根据状态将python字典形式的请求编码为字节串. Parameters: response (bytes): - 响应的字节串编码 Return: (Dict[str, Any]): - python字典形式的响应
[ "编码请求为bytes", "." ]
python
train
robertpeteuil/multi-cloud-control
mcc/cldcnct.py
https://github.com/robertpeteuil/multi-cloud-control/blob/f1565af1c0b6ed465ff312d3ccc592ba0609f4a2/mcc/cldcnct.py#L108-L112
def busy_disp_off(dobj): """Turn OFF busy_display to indicate completion.""" dobj.kill(block=False) sys.stdout.write("\033[D \033[D") sys.stdout.flush()
[ "def", "busy_disp_off", "(", "dobj", ")", ":", "dobj", ".", "kill", "(", "block", "=", "False", ")", "sys", ".", "stdout", ".", "write", "(", "\"\\033[D \\033[D\"", ")", "sys", ".", "stdout", ".", "flush", "(", ")" ]
Turn OFF busy_display to indicate completion.
[ "Turn", "OFF", "busy_display", "to", "indicate", "completion", "." ]
python
train
senaite/senaite.core
bika/lims/browser/batchfolder.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/batchfolder.py#L143-L183
def folderitem(self, obj, item, index): """Applies new properties to the item (Batch) that is currently being rendered as a row in the list :param obj: client to be rendered as a row in the list :param item: dict representation of the batch, suitable for the list :param index: c...
[ "def", "folderitem", "(", "self", ",", "obj", ",", "item", ",", "index", ")", ":", "obj", "=", "api", ".", "get_object", "(", "obj", ")", "url", "=", "\"{}/analysisrequests\"", ".", "format", "(", "api", ".", "get_url", "(", "obj", ")", ")", "bid", ...
Applies new properties to the item (Batch) that is currently being rendered as a row in the list :param obj: client to be rendered as a row in the list :param item: dict representation of the batch, suitable for the list :param index: current position of the item within the list ...
[ "Applies", "new", "properties", "to", "the", "item", "(", "Batch", ")", "that", "is", "currently", "being", "rendered", "as", "a", "row", "in", "the", "list" ]
python
train
JukeboxPipeline/jukebox-core
src/jukeboxcore/addons/guerilla/guerillamgmt.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/guerilla/guerillamgmt.py#L468-L486
def create_shot(self, ): """Create a shot and store it in the self.shot :returns: None :rtype: None :raises: None """ name = self.name_le.text() if not name: self.name_le.setPlaceholderText("Please enter a name!") return desc = sel...
[ "def", "create_shot", "(", "self", ",", ")", ":", "name", "=", "self", ".", "name_le", ".", "text", "(", ")", "if", "not", "name", ":", "self", ".", "name_le", ".", "setPlaceholderText", "(", "\"Please enter a name!\"", ")", "return", "desc", "=", "self"...
Create a shot and store it in the self.shot :returns: None :rtype: None :raises: None
[ "Create", "a", "shot", "and", "store", "it", "in", "the", "self", ".", "shot" ]
python
train
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/pympler/refgraph.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/refgraph.py#L267-L284
def _annotate_objects(self): """ Extract meta-data describing the stored objects. """ self.metadata = [] sizer = Asizer() sizes = sizer.asizesof(*self.objects) self.total_size = sizer.total for obj, sz in zip(self.objects, sizes): md = _MetaObj...
[ "def", "_annotate_objects", "(", "self", ")", ":", "self", ".", "metadata", "=", "[", "]", "sizer", "=", "Asizer", "(", ")", "sizes", "=", "sizer", ".", "asizesof", "(", "*", "self", ".", "objects", ")", "self", ".", "total_size", "=", "sizer", ".", ...
Extract meta-data describing the stored objects.
[ "Extract", "meta", "-", "data", "describing", "the", "stored", "objects", "." ]
python
train
vijaykatam/django-cache-manager
django_cache_manager/models.py
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/models.py#L21-L26
def update_model_cache(table_name): """ Updates model cache by generating a new key for the model """ model_cache_info = ModelCacheInfo(table_name, uuid.uuid4().hex) model_cache_backend.share_model_cache_info(model_cache_info)
[ "def", "update_model_cache", "(", "table_name", ")", ":", "model_cache_info", "=", "ModelCacheInfo", "(", "table_name", ",", "uuid", ".", "uuid4", "(", ")", ".", "hex", ")", "model_cache_backend", ".", "share_model_cache_info", "(", "model_cache_info", ")" ]
Updates model cache by generating a new key for the model
[ "Updates", "model", "cache", "by", "generating", "a", "new", "key", "for", "the", "model" ]
python
train
bpsmith/tia
tia/bbg/v3api.py
https://github.com/bpsmith/tia/blob/a7043b6383e557aeea8fc7112bbffd6e36a230e9/tia/bbg/v3api.py#L23-L30
def security_iter(nodearr): """ provide a security data iterator by returning a tuple of (Element, SecurityError) which are mutually exclusive """ assert nodearr.name() == 'securityData' and nodearr.isArray() for i in range(nodearr.numValues()): node = nodearr.getValue(i) ...
[ "def", "security_iter", "(", "nodearr", ")", ":", "assert", "nodearr", ".", "name", "(", ")", "==", "'securityData'", "and", "nodearr", ".", "isArray", "(", ")", "for", "i", "in", "range", "(", "nodearr", ".", "numValues", "(", ")", ")", ":", "node", ...
provide a security data iterator by returning a tuple of (Element, SecurityError) which are mutually exclusive
[ "provide", "a", "security", "data", "iterator", "by", "returning", "a", "tuple", "of", "(", "Element", "SecurityError", ")", "which", "are", "mutually", "exclusive" ]
python
train
tensorflow/tensorboard
tensorboard/backend/event_processing/sqlite_writer.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/backend/event_processing/sqlite_writer.py#L416-L430
def initialize_schema(connection): """Initializes the TensorBoard sqlite schema using the given connection. Args: connection: A sqlite DB connection. """ cursor = connection.cursor() cursor.execute("PRAGMA application_id={}".format(_TENSORBOARD_APPLICATION_ID)) cursor.execute("PRAGMA user_version={}".f...
[ "def", "initialize_schema", "(", "connection", ")", ":", "cursor", "=", "connection", ".", "cursor", "(", ")", "cursor", ".", "execute", "(", "\"PRAGMA application_id={}\"", ".", "format", "(", "_TENSORBOARD_APPLICATION_ID", ")", ")", "cursor", ".", "execute", "...
Initializes the TensorBoard sqlite schema using the given connection. Args: connection: A sqlite DB connection.
[ "Initializes", "the", "TensorBoard", "sqlite", "schema", "using", "the", "given", "connection", "." ]
python
train
dhermes/bezier
src/bezier/_curve_helpers.py
https://github.com/dhermes/bezier/blob/4f941f82637a8e70a5b159a9203132192e23406b/src/bezier/_curve_helpers.py#L299-L343
def _compute_length(nodes): r"""Approximately compute the length of a curve. .. _QUADPACK: https://en.wikipedia.org/wiki/QUADPACK If ``degree`` is :math:`n`, then the Hodograph curve :math:`B'(s)` is degree :math:`d = n - 1`. Using this curve, we approximate the integral: .. math:: \i...
[ "def", "_compute_length", "(", "nodes", ")", ":", "_", ",", "num_nodes", "=", "np", ".", "shape", "(", "nodes", ")", "# NOTE: We somewhat replicate code in ``evaluate_hodograph()``", "# here. This is so we don't re-compute the nodes for the first", "# derivative every...
r"""Approximately compute the length of a curve. .. _QUADPACK: https://en.wikipedia.org/wiki/QUADPACK If ``degree`` is :math:`n`, then the Hodograph curve :math:`B'(s)` is degree :math:`d = n - 1`. Using this curve, we approximate the integral: .. math:: \int_{B\left(\left[0, 1\right]\rig...
[ "r", "Approximately", "compute", "the", "length", "of", "a", "curve", "." ]
python
train
odrling/peony-twitter
peony/client.py
https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L542-L640
async def _chunked_upload(self, media, media_size, path=None, media_type=None, media_category=None, chunk_size=2**20, **params): """ upload media in c...
[ "async", "def", "_chunked_upload", "(", "self", ",", "media", ",", "media_size", ",", "path", "=", "None", ",", "media_type", "=", "None", ",", "media_category", "=", "None", ",", "chunk_size", "=", "2", "**", "20", ",", "*", "*", "params", ")", ":", ...
upload media in chunks Parameters ---------- media : file object a file object of the media media_size : int size of the media path : str, optional filename of the media media_type : str, optional mime type of the media ...
[ "upload", "media", "in", "chunks" ]
python
valid
numenta/nupic
src/nupic/algorithms/spatial_pooler.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1694-L1715
def _getInputNeighborhood(self, centerInput): """ Gets a neighborhood of inputs. Simply calls topology.wrappingNeighborhood or topology.neighborhood. A subclass can insert different topology behavior by overriding this method. :param centerInput (int) The center of the neighborhood. @ret...
[ "def", "_getInputNeighborhood", "(", "self", ",", "centerInput", ")", ":", "if", "self", ".", "_wrapAround", ":", "return", "topology", ".", "wrappingNeighborhood", "(", "centerInput", ",", "self", ".", "_potentialRadius", ",", "self", ".", "_inputDimensions", "...
Gets a neighborhood of inputs. Simply calls topology.wrappingNeighborhood or topology.neighborhood. A subclass can insert different topology behavior by overriding this method. :param centerInput (int) The center of the neighborhood. @returns (1D numpy array of integers) The inputs in the ne...
[ "Gets", "a", "neighborhood", "of", "inputs", "." ]
python
valid
cltrudeau/django-flowr
flowr/models.py
https://github.com/cltrudeau/django-flowr/blob/d077b90376ede33721db55ff29e08b8a16ed17ae/flowr/models.py#L321-L345
def prune(self): """Removes the node and all descendents without looping back past the root. Note this does not remove the associated data objects. :returns: list of :class:`BaseDataNode` subclassers associated with the removed ``Node`` objects. """ targ...
[ "def", "prune", "(", "self", ")", ":", "targets", "=", "self", ".", "descendents_root", "(", ")", "try", ":", "targets", ".", "remove", "(", "self", ".", "graph", ".", "root", ")", "except", "ValueError", ":", "# root wasn't in the target list, no problem", ...
Removes the node and all descendents without looping back past the root. Note this does not remove the associated data objects. :returns: list of :class:`BaseDataNode` subclassers associated with the removed ``Node`` objects.
[ "Removes", "the", "node", "and", "all", "descendents", "without", "looping", "back", "past", "the", "root", ".", "Note", "this", "does", "not", "remove", "the", "associated", "data", "objects", "." ]
python
valid
OCR-D/core
ocrd_models/ocrd_models/ocrd_mets.py
https://github.com/OCR-D/core/blob/57e68c578526cb955fd2e368207f5386c459d91d/ocrd_models/ocrd_models/ocrd_mets.py#L180-L213
def add_file(self, fileGrp, mimetype=None, url=None, ID=None, pageId=None, force=False, local_filename=None, **kwargs): """ Add a `OcrdFile </../../ocrd_models/ocrd_models.ocrd_file.html>`_. Arguments: fileGrp (string): Add file to ``mets:fileGrp`` with this ``USE`` attribute ...
[ "def", "add_file", "(", "self", ",", "fileGrp", ",", "mimetype", "=", "None", ",", "url", "=", "None", ",", "ID", "=", "None", ",", "pageId", "=", "None", ",", "force", "=", "False", ",", "local_filename", "=", "None", ",", "*", "*", "kwargs", ")",...
Add a `OcrdFile </../../ocrd_models/ocrd_models.ocrd_file.html>`_. Arguments: fileGrp (string): Add file to ``mets:fileGrp`` with this ``USE`` attribute mimetype (string): url (string): ID (string): pageId (string): force (boolean): Whethe...
[ "Add", "a", "OcrdFile", "<", "/", "..", "/", "..", "/", "ocrd_models", "/", "ocrd_models", ".", "ocrd_file", ".", "html", ">", "_", "." ]
python
train
openeventdata/mordecai
mordecai/geoparse.py
https://github.com/openeventdata/mordecai/blob/bd82b8bcc27621345c57cbe9ec7f8c8552620ffc/mordecai/geoparse.py#L115-L149
def clean_entity(self, ent): """ Strip out extra words that often get picked up by spaCy's NER. To do: preserve info about what got stripped out to help with ES/Geonames resolution later. Parameters --------- ent: a spaCy named entity Span Returns ...
[ "def", "clean_entity", "(", "self", ",", "ent", ")", ":", "dump_list", "=", "[", "'province'", ",", "'the'", ",", "'area'", ",", "'airport'", ",", "'district'", ",", "'square'", ",", "'town'", ",", "'village'", ",", "'prison'", ",", "\"river\"", ",", "\"...
Strip out extra words that often get picked up by spaCy's NER. To do: preserve info about what got stripped out to help with ES/Geonames resolution later. Parameters --------- ent: a spaCy named entity Span Returns ------- new_ent: a spaCy Span, wit...
[ "Strip", "out", "extra", "words", "that", "often", "get", "picked", "up", "by", "spaCy", "s", "NER", "." ]
python
train
eirannejad/Revit-Journal-Maker
rjm/__init__.py
https://github.com/eirannejad/Revit-Journal-Maker/blob/09a4f27da6d183f63a2c93ed99dca8a8590d5241/rjm/__init__.py#L228-L242
def open_model(self, model_path, audit=False): """Append a open non-workshared model entry to the journal. This instructs Revit to open a non-workshared model. Args: model_path (str): full path to non-workshared model audit (bool): if True audits the model when opening ...
[ "def", "open_model", "(", "self", ",", "model_path", ",", "audit", "=", "False", ")", ":", "if", "audit", ":", "self", ".", "_add_entry", "(", "templates", ".", "FILE_OPEN_AUDIT", ".", "format", "(", "model_path", "=", "model_path", ")", ")", "else", ":"...
Append a open non-workshared model entry to the journal. This instructs Revit to open a non-workshared model. Args: model_path (str): full path to non-workshared model audit (bool): if True audits the model when opening
[ "Append", "a", "open", "non", "-", "workshared", "model", "entry", "to", "the", "journal", "." ]
python
train
DiscordBotList/DBL-Python-Library
dbl/client.py
https://github.com/DiscordBotList/DBL-Python-Library/blob/c1461ae0acc644cdeedef8fd6b5e36f76d81c1aa/dbl/client.py#L330-L349
async def get_widget_small(self, bot_id: int = None): """This function is a coroutine. Generates the default small widget. Parameters ========== bot_id: int The bot_id of the bot you wish to make a widget for. Returns ======= URL of the wi...
[ "async", "def", "get_widget_small", "(", "self", ",", "bot_id", ":", "int", "=", "None", ")", ":", "if", "bot_id", "is", "None", ":", "bot_id", "=", "self", ".", "bot_id", "url", "=", "'https://discordbots.org/api/widget/lib/{0}.png'", ".", "format", "(", "b...
This function is a coroutine. Generates the default small widget. Parameters ========== bot_id: int The bot_id of the bot you wish to make a widget for. Returns ======= URL of the widget: str
[ "This", "function", "is", "a", "coroutine", "." ]
python
test
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/work/work_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/work/work_client.py#L28-L55
def get_backlog_configurations(self, team_context): """GetBacklogConfigurations. Gets backlog configuration for a team :param :class:`<TeamContext> <azure.devops.v5_0.work.models.TeamContext>` team_context: The team context for the operation :rtype: :class:`<BacklogConfiguration> <azure....
[ "def", "get_backlog_configurations", "(", "self", ",", "team_context", ")", ":", "project", "=", "None", "team", "=", "None", "if", "team_context", "is", "not", "None", ":", "if", "team_context", ".", "project_id", ":", "project", "=", "team_context", ".", "...
GetBacklogConfigurations. Gets backlog configuration for a team :param :class:`<TeamContext> <azure.devops.v5_0.work.models.TeamContext>` team_context: The team context for the operation :rtype: :class:`<BacklogConfiguration> <azure.devops.v5_0.work.models.BacklogConfiguration>`
[ "GetBacklogConfigurations", ".", "Gets", "backlog", "configuration", "for", "a", "team", ":", "param", ":", "class", ":", "<TeamContext", ">", "<azure", ".", "devops", ".", "v5_0", ".", "work", ".", "models", ".", "TeamContext", ">", "team_context", ":", "Th...
python
train
bitshares/python-bitshares
bitsharesbase/operationids.py
https://github.com/bitshares/python-bitshares/blob/8a3b5954a6abcaaff7c6a5c41d910e58eea3142f/bitsharesbase/operationids.py#L71-L83
def getOperationName(id: str): """ This method returns the name representation of an operation given its value as used in the API """ if isinstance(id, str): # Some graphene chains (e.g. steem) do not encode the # operation_type as id but in its string form assert id in opera...
[ "def", "getOperationName", "(", "id", ":", "str", ")", ":", "if", "isinstance", "(", "id", ",", "str", ")", ":", "# Some graphene chains (e.g. steem) do not encode the", "# operation_type as id but in its string form", "assert", "id", "in", "operations", ".", "keys", ...
This method returns the name representation of an operation given its value as used in the API
[ "This", "method", "returns", "the", "name", "representation", "of", "an", "operation", "given", "its", "value", "as", "used", "in", "the", "API" ]
python
train
ModisWorks/modis
modis/discord_modis/modules/help/api_help.py
https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/help/api_help.py#L32-L52
def get_help_commands(server_prefix): """ Get the help commands for all modules Args: server_prefix: The server command prefix Returns: datapacks (list): A list of datapacks for the help commands for all the modules """ datapacks = [] _dir = os.path.realpath( os.p...
[ "def", "get_help_commands", "(", "server_prefix", ")", ":", "datapacks", "=", "[", "]", "_dir", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "os", ".", "path", ".", "dirname"...
Get the help commands for all modules Args: server_prefix: The server command prefix Returns: datapacks (list): A list of datapacks for the help commands for all the modules
[ "Get", "the", "help", "commands", "for", "all", "modules" ]
python
train
odlgroup/odl
odl/trafos/fourier.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/trafos/fourier.py#L146-L171
def _call(self, x, out, **kwargs): """Implement ``self(x, out[, **kwargs])``. Parameters ---------- x : `domain` element Discretized function to be transformed out : `range` element Element to which the output is written Notes ----- ...
[ "def", "_call", "(", "self", ",", "x", ",", "out", ",", "*", "*", "kwargs", ")", ":", "# TODO: Implement zero padding", "if", "self", ".", "impl", "==", "'numpy'", ":", "out", "[", ":", "]", "=", "self", ".", "_call_numpy", "(", "x", ".", "asarray", ...
Implement ``self(x, out[, **kwargs])``. Parameters ---------- x : `domain` element Discretized function to be transformed out : `range` element Element to which the output is written Notes ----- See the ``pyfftw_call`` function for ``**kw...
[ "Implement", "self", "(", "x", "out", "[", "**", "kwargs", "]", ")", "." ]
python
train
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L3146-L3164
def GetPixelColorsOfRects(self, rects: list) -> list: """ rects: a list of rects, such as [(0,0,10,10), (10,10,20,20),(x,y,width,height)]. Return list, a list whose elements are ctypes.Array which is an iterable array of int values in argb. """ rects2 = [(x, y, x + width, y + hei...
[ "def", "GetPixelColorsOfRects", "(", "self", ",", "rects", ":", "list", ")", "->", "list", ":", "rects2", "=", "[", "(", "x", ",", "y", ",", "x", "+", "width", ",", "y", "+", "height", ")", "for", "x", ",", "y", ",", "width", ",", "height", "in...
rects: a list of rects, such as [(0,0,10,10), (10,10,20,20),(x,y,width,height)]. Return list, a list whose elements are ctypes.Array which is an iterable array of int values in argb.
[ "rects", ":", "a", "list", "of", "rects", "such", "as", "[", "(", "0", "0", "10", "10", ")", "(", "10", "10", "20", "20", ")", "(", "x", "y", "width", "height", ")", "]", ".", "Return", "list", "a", "list", "whose", "elements", "are", "ctypes",...
python
valid
albahnsen/CostSensitiveClassification
costcla/models/cost_tree.py
https://github.com/albahnsen/CostSensitiveClassification/blob/75778ae32c70671c0cdde6c4651277b6a8b58871/costcla/models/cost_tree.py#L654-L676
def pruning(self, X, y, cost_mat): """ Function that prune the decision tree. Parameters ---------- X : array-like of shape = [n_samples, n_features] The input samples. y_true : array indicator matrix Ground truth (correct) labels. cost_mat : a...
[ "def", "pruning", "(", "self", ",", "X", ",", "y", ",", "cost_mat", ")", ":", "self", ".", "tree_", ".", "tree_pruned", "=", "copy", ".", "deepcopy", "(", "self", ".", "tree_", ".", "tree", ")", "if", "self", ".", "tree_", ".", "n_nodes", ">", "0...
Function that prune the decision tree. Parameters ---------- X : array-like of shape = [n_samples, n_features] The input samples. y_true : array indicator matrix Ground truth (correct) labels. cost_mat : array-like of shape = [n_samples, 4] ...
[ "Function", "that", "prune", "the", "decision", "tree", "." ]
python
train
Valassis-Digital-Media/spylon
spylon/spark/launcher.py
https://github.com/Valassis-Digital-Media/spylon/blob/ac00e285fa1c790674606b793819c3e5baee0d48/spylon/spark/launcher.py#L584-L610
def with_sql_context(application_name, conf=None): """Context manager for a spark context Returns ------- sc : SparkContext sql_context: SQLContext Examples -------- Used within a context manager >>> with with_sql_context("MyApplication") as (sc, sql_context): ... import py...
[ "def", "with_sql_context", "(", "application_name", ",", "conf", "=", "None", ")", ":", "if", "conf", "is", "None", ":", "conf", "=", "default_configuration", "assert", "isinstance", "(", "conf", ",", "SparkConfiguration", ")", "sc", "=", "conf", ".", "spark...
Context manager for a spark context Returns ------- sc : SparkContext sql_context: SQLContext Examples -------- Used within a context manager >>> with with_sql_context("MyApplication") as (sc, sql_context): ... import pyspark ... # Do stuff ... pass
[ "Context", "manager", "for", "a", "spark", "context" ]
python
train
wharris/dougrain
dougrain/document.py
https://github.com/wharris/dougrain/blob/45062a1562fc34793e40c6253a93aa91eb4cf855/dougrain/document.py#L665-L731
def delete_embedded(self, rel=None, href=lambda _: True): """Removes an embedded resource from this document. Calling code should use this method to remove embedded resources instead of modifying ``embedded`` directly. The optional arguments, ``rel`` and ``href`` are used to select the...
[ "def", "delete_embedded", "(", "self", ",", "rel", "=", "None", ",", "href", "=", "lambda", "_", ":", "True", ")", ":", "if", "EMBEDDED_KEY", "not", "in", "self", ".", "o", ":", "return", "if", "rel", "is", "None", ":", "for", "rel", "in", "list", ...
Removes an embedded resource from this document. Calling code should use this method to remove embedded resources instead of modifying ``embedded`` directly. The optional arguments, ``rel`` and ``href`` are used to select the embedded resources that will be removed. If neither of the o...
[ "Removes", "an", "embedded", "resource", "from", "this", "document", "." ]
python
train
avalente/appmetrics
appmetrics/statistics.py
https://github.com/avalente/appmetrics/blob/366fc7e1ca897e49a2227cbfa43bfa02a47f1acc/appmetrics/statistics.py#L442-L455
def percentile(data, n): """Return the n-th percentile of the given data Assume that the data are already sorted """ size = len(data) idx = (n / 100.0) * size - 0.5 if idx < 0 or idx > size: raise StatisticsError("Too few data points ({}) for {}th percentile".format(size, n)) re...
[ "def", "percentile", "(", "data", ",", "n", ")", ":", "size", "=", "len", "(", "data", ")", "idx", "=", "(", "n", "/", "100.0", ")", "*", "size", "-", "0.5", "if", "idx", "<", "0", "or", "idx", ">", "size", ":", "raise", "StatisticsError", "(",...
Return the n-th percentile of the given data Assume that the data are already sorted
[ "Return", "the", "n", "-", "th", "percentile", "of", "the", "given", "data" ]
python
train
deepmind/pysc2
pysc2/lib/colors.py
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/colors.py#L78-L121
def smooth_hue_palette(scale): """Takes an array of ints and returns a corresponding colored rgb array.""" # http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL # Based on http://stackoverflow.com/a/17382854 , with simplifications and # optimizations. Assumes S=1, L=0.5, meaning C=1 and m=0. # 0 stays black, ev...
[ "def", "smooth_hue_palette", "(", "scale", ")", ":", "# http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSL", "# Based on http://stackoverflow.com/a/17382854 , with simplifications and", "# optimizations. Assumes S=1, L=0.5, meaning C=1 and m=0.", "# 0 stays black, everything else moves into a hue."...
Takes an array of ints and returns a corresponding colored rgb array.
[ "Takes", "an", "array", "of", "ints", "and", "returns", "a", "corresponding", "colored", "rgb", "array", "." ]
python
train
Peter-Slump/django-dynamic-fixtures
src/dynamic_fixtures/management/commands/load_dynamic_fixtures.py
https://github.com/Peter-Slump/django-dynamic-fixtures/blob/da99b4b12b11be28ea4b36b6cf2896ca449c73c1/src/dynamic_fixtures/management/commands/load_dynamic_fixtures.py#L61-L78
def progress_callback(self, action, node, elapsed_time=None): """ Callback to report progress :param str action: :param list node: app, module :param int | None elapsed_time: """ if action == 'load_start': self.stdout.write('Loading fixture {}.{}...'....
[ "def", "progress_callback", "(", "self", ",", "action", ",", "node", ",", "elapsed_time", "=", "None", ")", ":", "if", "action", "==", "'load_start'", ":", "self", ".", "stdout", ".", "write", "(", "'Loading fixture {}.{}...'", ".", "format", "(", "*", "no...
Callback to report progress :param str action: :param list node: app, module :param int | None elapsed_time:
[ "Callback", "to", "report", "progress" ]
python
train
PmagPy/PmagPy
programs/demag_gui.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/demag_gui.py#L1997-L2080
def calc_and_plot_sample_orient_check(self): """ If sample orientation is on plots the wrong arrow, wrong compass, and rotated sample error directions for the current specimen interpretation on the high level mean plot so that you can check sample orientation good/bad. ""...
[ "def", "calc_and_plot_sample_orient_check", "(", "self", ")", ":", "fit", "=", "self", ".", "current_fit", "if", "fit", "==", "None", ":", "return", "pars", "=", "fit", ".", "get", "(", "'specimen'", ")", "if", "'specimen_dec'", "not", "in", "list", "(", ...
If sample orientation is on plots the wrong arrow, wrong compass, and rotated sample error directions for the current specimen interpretation on the high level mean plot so that you can check sample orientation good/bad.
[ "If", "sample", "orientation", "is", "on", "plots", "the", "wrong", "arrow", "wrong", "compass", "and", "rotated", "sample", "error", "directions", "for", "the", "current", "specimen", "interpretation", "on", "the", "high", "level", "mean", "plot", "so", "that...
python
train
ynop/audiomate
audiomate/processing/pipeline/spectral.py
https://github.com/ynop/audiomate/blob/61727920b23a708293c3d526fa3000d4de9c6c21/audiomate/processing/pipeline/spectral.py#L10-L43
def stft_from_frames(frames, window='hann', dtype=np.complex64): """ Variation of the librosa.core.stft function, that computes the short-time-fourier-transfrom from frames instead from the signal. See http://librosa.github.io/librosa/_modules/librosa/core/spectrum.html#stft """ win_length = f...
[ "def", "stft_from_frames", "(", "frames", ",", "window", "=", "'hann'", ",", "dtype", "=", "np", ".", "complex64", ")", ":", "win_length", "=", "frames", ".", "shape", "[", "0", "]", "n_fft", "=", "win_length", "fft_window", "=", "filters", ".", "get_win...
Variation of the librosa.core.stft function, that computes the short-time-fourier-transfrom from frames instead from the signal. See http://librosa.github.io/librosa/_modules/librosa/core/spectrum.html#stft
[ "Variation", "of", "the", "librosa", ".", "core", ".", "stft", "function", "that", "computes", "the", "short", "-", "time", "-", "fourier", "-", "transfrom", "from", "frames", "instead", "from", "the", "signal", "." ]
python
train
HazyResearch/pdftotree
pdftotree/utils/pdf/node.py
https://github.com/HazyResearch/pdftotree/blob/5890d668b475d5d3058d1d886aafbfd83268c440/pdftotree/utils/pdf/node.py#L241-L245
def _one_contains_other(s1, s2): """ Whether one set contains the other """ return min(len(s1), len(s2)) == len(s1 & s2)
[ "def", "_one_contains_other", "(", "s1", ",", "s2", ")", ":", "return", "min", "(", "len", "(", "s1", ")", ",", "len", "(", "s2", ")", ")", "==", "len", "(", "s1", "&", "s2", ")" ]
Whether one set contains the other
[ "Whether", "one", "set", "contains", "the", "other" ]
python
train
opendatateam/udata
udata/core/dataset/preview.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/core/dataset/preview.py#L64-L77
def get_enabled_plugins(): ''' Returns enabled preview plugins. Plugins are sorted, defaults come last ''' plugins = entrypoints.get_enabled('udata.preview', current_app).values() valid = [p for p in plugins if issubclass(p, PreviewPlugin)] for plugin in plugins: if plugin not in va...
[ "def", "get_enabled_plugins", "(", ")", ":", "plugins", "=", "entrypoints", ".", "get_enabled", "(", "'udata.preview'", ",", "current_app", ")", ".", "values", "(", ")", "valid", "=", "[", "p", "for", "p", "in", "plugins", "if", "issubclass", "(", "p", "...
Returns enabled preview plugins. Plugins are sorted, defaults come last
[ "Returns", "enabled", "preview", "plugins", "." ]
python
train
MartinThoma/hwrt
hwrt/download.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/download.py#L18-L21
def is_file_consistent(local_path_file, md5_hash): """Check if file is there and if the md5_hash is correct.""" return os.path.isfile(local_path_file) and \ hashlib.md5(open(local_path_file, 'rb').read()).hexdigest() == md5_hash
[ "def", "is_file_consistent", "(", "local_path_file", ",", "md5_hash", ")", ":", "return", "os", ".", "path", ".", "isfile", "(", "local_path_file", ")", "and", "hashlib", ".", "md5", "(", "open", "(", "local_path_file", ",", "'rb'", ")", ".", "read", "(", ...
Check if file is there and if the md5_hash is correct.
[ "Check", "if", "file", "is", "there", "and", "if", "the", "md5_hash", "is", "correct", "." ]
python
train
rootpy/rootpy
rootpy/logger/magic.py
https://github.com/rootpy/rootpy/blob/3926935e1f2100d8ba68070c2ab44055d4800f73/rootpy/logger/magic.py#L219-L269
def re_execute_with_exception(frame, exception, traceback): """ Dark magic. Causes ``frame`` to raise an exception at the current location with ``traceback`` appended to it. Note that since the line tracer is raising an exception, the interpreter disables the global trace, so it's not possible to r...
[ "def", "re_execute_with_exception", "(", "frame", ",", "exception", ",", "traceback", ")", ":", "if", "sys", ".", "gettrace", "(", ")", "==", "globaltrace", ":", "# If our trace handler is already installed, that means that this", "# function has been called twice before the ...
Dark magic. Causes ``frame`` to raise an exception at the current location with ``traceback`` appended to it. Note that since the line tracer is raising an exception, the interpreter disables the global trace, so it's not possible to restore the previous tracing conditions.
[ "Dark", "magic", ".", "Causes", "frame", "to", "raise", "an", "exception", "at", "the", "current", "location", "with", "traceback", "appended", "to", "it", "." ]
python
train
aio-libs/aioredis
aioredis/commands/set.py
https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/set.py#L59-L61
def srem(self, key, member, *members): """Remove one or more members from a set.""" return self.execute(b'SREM', key, member, *members)
[ "def", "srem", "(", "self", ",", "key", ",", "member", ",", "*", "members", ")", ":", "return", "self", ".", "execute", "(", "b'SREM'", ",", "key", ",", "member", ",", "*", "members", ")" ]
Remove one or more members from a set.
[ "Remove", "one", "or", "more", "members", "from", "a", "set", "." ]
python
train
PmagPy/PmagPy
programs/pt_rot.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/pt_rot.py#L12-L146
def main(): """ NAME pt_rot.py DESCRIPTION rotates pt according to specified age and plate SYNTAX pt_rot.py [command line options] OPTIONS -h prints help and quits -f file with lon lat plate age Dplate as space delimited input Dplate is the de...
[ "def", "main", "(", ")", ":", "dir_path", "=", "'.'", "PTS", "=", "[", "]", "ResRecs", "=", "[", "]", "ofile", "=", "\"\"", "data_model", "=", "3", "Dplates", "=", "[", "'nwaf'", ",", "'neaf'", ",", "'saf'", ",", "'aus'", ",", "'eur'", ",", "'ind...
NAME pt_rot.py DESCRIPTION rotates pt according to specified age and plate SYNTAX pt_rot.py [command line options] OPTIONS -h prints help and quits -f file with lon lat plate age Dplate as space delimited input Dplate is the destination plate coordina...
[ "NAME", "pt_rot", ".", "py" ]
python
train
johnnoone/facts
facts/targeting.py
https://github.com/johnnoone/facts/blob/82d38a46c15d9c01200445526f4c0d1825fc1e51/facts/targeting.py#L50-L74
def read(self, obj): """ Returns object: fragment """ path, frag = [], obj for part in self.parts: path.append(part) if isinstance(frag, dict): try: frag = frag[part] except KeyError as error:...
[ "def", "read", "(", "self", ",", "obj", ")", ":", "path", ",", "frag", "=", "[", "]", ",", "obj", "for", "part", "in", "self", ".", "parts", ":", "path", ".", "append", "(", "part", ")", "if", "isinstance", "(", "frag", ",", "dict", ")", ":", ...
Returns object: fragment
[ "Returns", "object", ":", "fragment" ]
python
train
maceoutliner/django-fiction-outlines
fiction_outlines/views.py
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/views.py#L1261-L1268
def return_opml_response(self, context, **response_kwargs): ''' Returns export data as an opml file. ''' self.template_name = 'fiction_outlines/outline.opml' response = super().render_to_response(context, content_type='text/xml', **response_kwargs) response['Content-Dispo...
[ "def", "return_opml_response", "(", "self", ",", "context", ",", "*", "*", "response_kwargs", ")", ":", "self", ".", "template_name", "=", "'fiction_outlines/outline.opml'", "response", "=", "super", "(", ")", ".", "render_to_response", "(", "context", ",", "con...
Returns export data as an opml file.
[ "Returns", "export", "data", "as", "an", "opml", "file", "." ]
python
train
onelogin/python3-saml
src/onelogin/saml2/response.py
https://github.com/onelogin/python3-saml/blob/064b7275fba1e5f39a9116ba1cdcc5d01fc34daa/src/onelogin/saml2/response.py#L521-L535
def get_session_index(self): """ Gets the SessionIndex from the AuthnStatement Could be used to be stored in the local session in order to be used in a future Logout Request that the SP could send to the SP, to set what specific session must be deleted :returns: The Sess...
[ "def", "get_session_index", "(", "self", ")", ":", "session_index", "=", "None", "authn_statement_nodes", "=", "self", ".", "__query_assertion", "(", "'/saml:AuthnStatement[@SessionIndex]'", ")", "if", "authn_statement_nodes", ":", "session_index", "=", "authn_statement_n...
Gets the SessionIndex from the AuthnStatement Could be used to be stored in the local session in order to be used in a future Logout Request that the SP could send to the SP, to set what specific session must be deleted :returns: The SessionIndex value :rtype: string|None
[ "Gets", "the", "SessionIndex", "from", "the", "AuthnStatement", "Could", "be", "used", "to", "be", "stored", "in", "the", "local", "session", "in", "order", "to", "be", "used", "in", "a", "future", "Logout", "Request", "that", "the", "SP", "could", "send",...
python
train
CodeReclaimers/neat-python
examples/memory-variable/visualize.py
https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/examples/memory-variable/visualize.py#L12-L40
def plot_stats(statistics, ylog=False, view=False, filename='avg_fitness.svg'): """ Plots the population's average and best fitness. """ if plt is None: warnings.warn("This display is not available due to a missing optional dependency (matplotlib)") return generation = range(len(statistics....
[ "def", "plot_stats", "(", "statistics", ",", "ylog", "=", "False", ",", "view", "=", "False", ",", "filename", "=", "'avg_fitness.svg'", ")", ":", "if", "plt", "is", "None", ":", "warnings", ".", "warn", "(", "\"This display is not available due to a missing opt...
Plots the population's average and best fitness.
[ "Plots", "the", "population", "s", "average", "and", "best", "fitness", "." ]
python
train
SBRG/ssbio
ssbio/protein/structure/structprop.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/structure/structprop.py#L223-L238
def add_chain_ids(self, chains): """Add chains by ID into the chains attribute Args: chains (str, list): Chain ID or list of IDs """ chains = ssbio.utils.force_list(chains) for c in chains: if self.chains.has_id(c): log.debug('{}: chain ...
[ "def", "add_chain_ids", "(", "self", ",", "chains", ")", ":", "chains", "=", "ssbio", ".", "utils", ".", "force_list", "(", "chains", ")", "for", "c", "in", "chains", ":", "if", "self", ".", "chains", ".", "has_id", "(", "c", ")", ":", "log", ".", ...
Add chains by ID into the chains attribute Args: chains (str, list): Chain ID or list of IDs
[ "Add", "chains", "by", "ID", "into", "the", "chains", "attribute" ]
python
train
ilblackdragon/django-misc
misc/views.py
https://github.com/ilblackdragon/django-misc/blob/0accd2dc97de656a1c9e275be81e817f78a2eb9d/misc/views.py#L38-L52
def handler404(request, template_name='404.html'): """ 404 error handler. Templates: `404.html` Context: MEDIA_URL Path of static media (e.g. "media.example.org") STATIC_URL """ t = loader.get_template(template_name) # You need to create a 404...
[ "def", "handler404", "(", "request", ",", "template_name", "=", "'404.html'", ")", ":", "t", "=", "loader", ".", "get_template", "(", "template_name", ")", "# You need to create a 404.html template.", "return", "http", ".", "HttpResponseNotFound", "(", "t", ".", "...
404 error handler. Templates: `404.html` Context: MEDIA_URL Path of static media (e.g. "media.example.org") STATIC_URL
[ "404", "error", "handler", "." ]
python
train
DataDog/integrations-core
tokumx/datadog_checks/tokumx/vendor/pymongo/database.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/database.py#L192-L204
def outgoing_manipulators(self): """**DEPRECATED**: All outgoing SON manipulators. .. versionchanged:: 3.5 Deprecated. .. versionadded:: 2.0 """ warnings.warn("Database.outgoing_manipulators() is deprecated", DeprecationWarning, stacklevel=2) ...
[ "def", "outgoing_manipulators", "(", "self", ")", ":", "warnings", ".", "warn", "(", "\"Database.outgoing_manipulators() is deprecated\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ")", "return", "[", "manipulator", ".", "__class__", ".", "__name__", "...
**DEPRECATED**: All outgoing SON manipulators. .. versionchanged:: 3.5 Deprecated. .. versionadded:: 2.0
[ "**", "DEPRECATED", "**", ":", "All", "outgoing", "SON", "manipulators", "." ]
python
train
manns/pyspread
pyspread/src/interfaces/pys.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/interfaces/pys.py#L392-L416
def to_code_array(self): """Replaces everything in code_array from pys_file""" state = None # Check if version section starts with first line first_line = True # Reset pys_file to start to enable multiple calls of this method self.pys_file.seek(0) for line in ...
[ "def", "to_code_array", "(", "self", ")", ":", "state", "=", "None", "# Check if version section starts with first line", "first_line", "=", "True", "# Reset pys_file to start to enable multiple calls of this method", "self", ".", "pys_file", ".", "seek", "(", "0", ")", "...
Replaces everything in code_array from pys_file
[ "Replaces", "everything", "in", "code_array", "from", "pys_file" ]
python
train
uw-it-aca/uw-restclients-nws
uw_nws/__init__.py
https://github.com/uw-it-aca/uw-restclients-nws/blob/ec6fd14342ffc883d14bcb53b2fe9bc288696027/uw_nws/__init__.py#L479-L492
def delete_message_type(self, message_type_id): """ Delete an existing message type :param message_type_id: is the id of the message type the client wants to delete """ self._validate_uuid(message_type_id) url = "/notification/v1/message-t...
[ "def", "delete_message_type", "(", "self", ",", "message_type_id", ")", ":", "self", ".", "_validate_uuid", "(", "message_type_id", ")", "url", "=", "\"/notification/v1/message-type/{}\"", ".", "format", "(", "message_type_id", ")", "response", "=", "NWS_DAO", "(", ...
Delete an existing message type :param message_type_id: is the id of the message type the client wants to delete
[ "Delete", "an", "existing", "message", "type", ":", "param", "message_type_id", ":", "is", "the", "id", "of", "the", "message", "type", "the", "client", "wants", "to", "delete" ]
python
train
bsolomon1124/pyfinance
pyfinance/utils.py
https://github.com/bsolomon1124/pyfinance/blob/c95925209a809b4e648e79cbeaf7711d8e5ff1a6/pyfinance/utils.py#L418-L426
def _uniquewords(*args): """Dictionary of words to their indices. Helper function to `encode.`""" words = {} n = 0 for word in itertools.chain(*args): if word not in words: words[word] = n n += 1 return words
[ "def", "_uniquewords", "(", "*", "args", ")", ":", "words", "=", "{", "}", "n", "=", "0", "for", "word", "in", "itertools", ".", "chain", "(", "*", "args", ")", ":", "if", "word", "not", "in", "words", ":", "words", "[", "word", "]", "=", "n", ...
Dictionary of words to their indices. Helper function to `encode.`
[ "Dictionary", "of", "words", "to", "their", "indices", ".", "Helper", "function", "to", "encode", "." ]
python
train
fastavro/fastavro
fastavro/_read_py.py
https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_read_py.py#L311-L342
def read_map(fo, writer_schema, reader_schema=None): """Maps are encoded as a series of blocks. Each block consists of a long count value, followed by that many key/value pairs. A block with count zero indicates the end of the map. Each item is encoded per the map's value schema. If a block's co...
[ "def", "read_map", "(", "fo", ",", "writer_schema", ",", "reader_schema", "=", "None", ")", ":", "if", "reader_schema", ":", "def", "item_reader", "(", "fo", ",", "w_schema", ",", "r_schema", ")", ":", "return", "read_data", "(", "fo", ",", "w_schema", "...
Maps are encoded as a series of blocks. Each block consists of a long count value, followed by that many key/value pairs. A block with count zero indicates the end of the map. Each item is encoded per the map's value schema. If a block's count is negative, then the count is followed immediately by a...
[ "Maps", "are", "encoded", "as", "a", "series", "of", "blocks", "." ]
python
train
sporsh/carnifex
carnifex/ssh/client.py
https://github.com/sporsh/carnifex/blob/82dd3bd2bc134dfb69a78f43171e227f2127060b/carnifex/ssh/client.py#L44-L51
def receiveError(self, reasonCode, description): """ Called when we receive a disconnect error message from the other side. """ error = disconnectErrors.get(reasonCode, DisconnectError) self.connectionClosed(error(reasonCode, description)) SSHClientTransport.recei...
[ "def", "receiveError", "(", "self", ",", "reasonCode", ",", "description", ")", ":", "error", "=", "disconnectErrors", ".", "get", "(", "reasonCode", ",", "DisconnectError", ")", "self", ".", "connectionClosed", "(", "error", "(", "reasonCode", ",", "descripti...
Called when we receive a disconnect error message from the other side.
[ "Called", "when", "we", "receive", "a", "disconnect", "error", "message", "from", "the", "other", "side", "." ]
python
train
toastdriven/alligator
alligator/gator.py
https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/gator.py#L234-L261
def task(self, func, *args, **kwargs): """ Pushes a task onto the queue. This will instantiate a ``Gator.task_class`` instance, configure the callable & its arguments, then push it onto the queue. You'll typically want to use either this method or the ``Gator.options`` ...
[ "def", "task", "(", "self", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "task", "=", "self", ".", "task_class", "(", ")", "return", "self", ".", "push", "(", "task", ",", "func", ",", "*", "args", ",", "*", "*", "kwargs", ...
Pushes a task onto the queue. This will instantiate a ``Gator.task_class`` instance, configure the callable & its arguments, then push it onto the queue. You'll typically want to use either this method or the ``Gator.options`` context manager (if you need to configure the ``Task`` argu...
[ "Pushes", "a", "task", "onto", "the", "queue", "." ]
python
train
amanusk/s-tui
s_tui/s_tui.py
https://github.com/amanusk/s-tui/blob/5e89d15081e716024db28ec03b1e3a7710330951/s_tui/s_tui.py#L256-L268
def on_reset_button(self, _): """Reset graph data and display empty graph""" for graph in self.visible_graphs.values(): graph.reset() for graph in self.graphs.values(): try: graph.source.reset() except NotImplementedError: pass ...
[ "def", "on_reset_button", "(", "self", ",", "_", ")", ":", "for", "graph", "in", "self", ".", "visible_graphs", ".", "values", "(", ")", ":", "graph", ".", "reset", "(", ")", "for", "graph", "in", "self", ".", "graphs", ".", "values", "(", ")", ":"...
Reset graph data and display empty graph
[ "Reset", "graph", "data", "and", "display", "empty", "graph" ]
python
train
summa-tx/riemann
riemann/blake256.py
https://github.com/summa-tx/riemann/blob/04ae336dfd4007ceaed748daadc91cc32fa278ec/riemann/blake256.py#L361-L415
def update(self, data): """ update the state with new data, storing excess data as necessary. may be called multiple times and if a call sends less than a full block in size, the leftover is cached and will be consumed in the next call data: data to be hashed (b...
[ "def", "update", "(", "self", ",", "data", ")", ":", "self", ".", "state", "=", "2", "BLKBYTES", "=", "self", ".", "BLKBYTES", "# de-referenced for improved readability", "BLKBITS", "=", "self", ".", "BLKBITS", "datalen", "=", "len", "(", "data", ")", "if"...
update the state with new data, storing excess data as necessary. may be called multiple times and if a call sends less than a full block in size, the leftover is cached and will be consumed in the next call data: data to be hashed (bytestring)
[ "update", "the", "state", "with", "new", "data", "storing", "excess", "data", "as", "necessary", ".", "may", "be", "called", "multiple", "times", "and", "if", "a", "call", "sends", "less", "than", "a", "full", "block", "in", "size", "the", "leftover", "i...
python
train
bcbio/bcbio-nextgen
bcbio/structural/manta.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/manta.py#L71-L81
def _get_out_file(work_dir, paired): """Retrieve manta output variant file, depending on analysis. """ if paired: if paired.normal_bam: base_file = "somaticSV.vcf.gz" else: base_file = "tumorSV.vcf.gz" else: base_file = "diploidSV.vcf.gz" return os.pat...
[ "def", "_get_out_file", "(", "work_dir", ",", "paired", ")", ":", "if", "paired", ":", "if", "paired", ".", "normal_bam", ":", "base_file", "=", "\"somaticSV.vcf.gz\"", "else", ":", "base_file", "=", "\"tumorSV.vcf.gz\"", "else", ":", "base_file", "=", "\"dipl...
Retrieve manta output variant file, depending on analysis.
[ "Retrieve", "manta", "output", "variant", "file", "depending", "on", "analysis", "." ]
python
train
fabioz/PyDev.Debugger
_pydev_bundle/_pydev_jy_imports_tipper.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/_pydev_bundle/_pydev_jy_imports_tipper.py#L177-L295
def ismethod(func): '''this function should return the information gathered on a function @param func: this is the function we want to get info on @return a tuple where: 0 = indicates whether the parameter passed is a method or not 1 = a list of classes 'Info', with the info gathered from t...
[ "def", "ismethod", "(", "func", ")", ":", "try", ":", "if", "isinstance", "(", "func", ",", "core", ".", "PyFunction", ")", ":", "#ok, this is from python, created by jython", "#print_ ' PyFunction'", "def", "getargs", "(", "func_code", ")", ":", "\"\"\"Get inf...
this function should return the information gathered on a function @param func: this is the function we want to get info on @return a tuple where: 0 = indicates whether the parameter passed is a method or not 1 = a list of classes 'Info', with the info gathered from the function thi...
[ "this", "function", "should", "return", "the", "information", "gathered", "on", "a", "function" ]
python
train
guma44/GEOparse
GEOparse/GEOparse.py
https://github.com/guma44/GEOparse/blob/7ee8d5b8678d780382a6bf884afa69d2033f5ca0/GEOparse/GEOparse.py#L395-L492
def parse_GPL(filepath, entry_name=None, partial=None): """Parse GPL entry from SOFT file. Args: filepath (:obj:`str` or :obj:`Iterable`): Path to file with 1 GPL entry or list of lines representing GPL from GSE file. entry_name (:obj:`str`, optional): Name of the entry. By default ...
[ "def", "parse_GPL", "(", "filepath", ",", "entry_name", "=", "None", ",", "partial", "=", "None", ")", ":", "gsms", "=", "{", "}", "gses", "=", "{", "}", "gpl_soft", "=", "[", "]", "has_table", "=", "False", "gpl_name", "=", "entry_name", "database", ...
Parse GPL entry from SOFT file. Args: filepath (:obj:`str` or :obj:`Iterable`): Path to file with 1 GPL entry or list of lines representing GPL from GSE file. entry_name (:obj:`str`, optional): Name of the entry. By default it is inferred from the data. partial (:obj...
[ "Parse", "GPL", "entry", "from", "SOFT", "file", "." ]
python
train
hozn/stravalib
stravalib/client.py
https://github.com/hozn/stravalib/blob/5500ebc39e0bf4706bb1ca4c27b25e56becaaa5f/stravalib/client.py#L82-L111
def authorization_url(self, client_id, redirect_uri, approval_prompt='auto', scope=None, state=None): """ Get the URL needed to authorize your application to access a Strava user's information. :param client_id: The numeric developer client id. :type client_id:...
[ "def", "authorization_url", "(", "self", ",", "client_id", ",", "redirect_uri", ",", "approval_prompt", "=", "'auto'", ",", "scope", "=", "None", ",", "state", "=", "None", ")", ":", "return", "self", ".", "protocol", ".", "authorization_url", "(", "client_i...
Get the URL needed to authorize your application to access a Strava user's information. :param client_id: The numeric developer client id. :type client_id: int :param redirect_uri: The URL that Strava will redirect to after successful (or failed) authorization. :type redirect_uri: str ...
[ "Get", "the", "URL", "needed", "to", "authorize", "your", "application", "to", "access", "a", "Strava", "user", "s", "information", "." ]
python
train
olitheolix/qtmacs
qtmacs/extensions/qtmacsscintilla_widget.py
https://github.com/olitheolix/qtmacs/blob/36253b082b82590f183fe154b053eb3a1e741be2/qtmacs/extensions/qtmacsscintilla_widget.py#L840-L895
def SCIGetStyledText(self, selectionPos: tuple): """ Pythonic wrapper for the SCI_GETSTYLEDTEXT command. For example, to get the raw text and styling bits for the first five characters in the widget use:: text, style = SCIGetStyledText((0, 0, 0, 5)) print(text.d...
[ "def", "SCIGetStyledText", "(", "self", ",", "selectionPos", ":", "tuple", ")", ":", "# Sanity check.", "if", "not", "self", ".", "isSelectionPositionValid", "(", "selectionPos", ")", ":", "return", "None", "# Convert the start- and end point of the selection into", "# ...
Pythonic wrapper for the SCI_GETSTYLEDTEXT command. For example, to get the raw text and styling bits for the first five characters in the widget use:: text, style = SCIGetStyledText((0, 0, 0, 5)) print(text.decode('utf-8')) |Args| * ``selectionPos`` (**tuple*...
[ "Pythonic", "wrapper", "for", "the", "SCI_GETSTYLEDTEXT", "command", "." ]
python
train
cognitect/transit-python
transit/sosjson.py
https://github.com/cognitect/transit-python/blob/59e27e7d322feaa3a7e8eb3de06ae96d8adb614f/transit/sosjson.py#L25-L39
def read_chunk(stream): """Ignore whitespace outside of strings. If we hit a string, read it in its entirety. """ chunk = stream.read(1) while chunk in SKIP: chunk = stream.read(1) if chunk == "\"": chunk += stream.read(1) while not chunk.endswith("\""): if ch...
[ "def", "read_chunk", "(", "stream", ")", ":", "chunk", "=", "stream", ".", "read", "(", "1", ")", "while", "chunk", "in", "SKIP", ":", "chunk", "=", "stream", ".", "read", "(", "1", ")", "if", "chunk", "==", "\"\\\"\"", ":", "chunk", "+=", "stream"...
Ignore whitespace outside of strings. If we hit a string, read it in its entirety.
[ "Ignore", "whitespace", "outside", "of", "strings", ".", "If", "we", "hit", "a", "string", "read", "it", "in", "its", "entirety", "." ]
python
train
pyhys/minimalmodbus
omegacn7500.py
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L317-L330
def get_pattern_additional_cycles(self, patternnumber): """Get the number of additional cycles for a given pattern. Args: patternnumber (integer): 0-7 Returns: The number of additional cycles (int). """ _checkPatternN...
[ "def", "get_pattern_additional_cycles", "(", "self", ",", "patternnumber", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "address", "=", "_calculateRegisterAddress", "(", "'cycles'", ",", "patternnumber", ")", "return", "self", ".", "read_register", "(",...
Get the number of additional cycles for a given pattern. Args: patternnumber (integer): 0-7 Returns: The number of additional cycles (int).
[ "Get", "the", "number", "of", "additional", "cycles", "for", "a", "given", "pattern", "." ]
python
train
saltstack/salt
salt/pillar/vmware_pillar.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/vmware_pillar.py#L495-L517
def _crawl_attribute(this_data, this_attr): ''' helper function to crawl an attribute specified for retrieval ''' if isinstance(this_data, list): t_list = [] for d in this_data: t_list.append(_crawl_attribute(d, this_attr)) return t_list else: if isinstanc...
[ "def", "_crawl_attribute", "(", "this_data", ",", "this_attr", ")", ":", "if", "isinstance", "(", "this_data", ",", "list", ")", ":", "t_list", "=", "[", "]", "for", "d", "in", "this_data", ":", "t_list", ".", "append", "(", "_crawl_attribute", "(", "d",...
helper function to crawl an attribute specified for retrieval
[ "helper", "function", "to", "crawl", "an", "attribute", "specified", "for", "retrieval" ]
python
train
goshuirc/irc
girc/__init__.py
https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/__init__.py#L102-L130
def handler(self, direction, verb, priority=10): """Register this function as an event handler. Args: direction (str): ``in``, ``out``, ``both``, ``raw``. verb (str): Event name. priority (int): Handler priority (lower priority executes first). Example: ...
[ "def", "handler", "(", "self", ",", "direction", ",", "verb", ",", "priority", "=", "10", ")", ":", "def", "parent_fn", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "child_fn", "(", "msg", ")", ":", "func", "(", ...
Register this function as an event handler. Args: direction (str): ``in``, ``out``, ``both``, ``raw``. verb (str): Event name. priority (int): Handler priority (lower priority executes first). Example: These handlers print out a pretty raw log:: ...
[ "Register", "this", "function", "as", "an", "event", "handler", "." ]
python
train
NeuralEnsemble/lazyarray
lazyarray.py
https://github.com/NeuralEnsemble/lazyarray/blob/391a4cef3be85309c36adac0c17824de3d82f5be/lazyarray.py#L347-L384
def _partially_evaluate(self, addr, simplify=False): """ Return part of the lazy array. """ if self.is_homogeneous: if simplify: base_val = self.base_value else: base_val = self._homogeneous_array(addr) * self.base_value eli...
[ "def", "_partially_evaluate", "(", "self", ",", "addr", ",", "simplify", "=", "False", ")", ":", "if", "self", ".", "is_homogeneous", ":", "if", "simplify", ":", "base_val", "=", "self", ".", "base_value", "else", ":", "base_val", "=", "self", ".", "_hom...
Return part of the lazy array.
[ "Return", "part", "of", "the", "lazy", "array", "." ]
python
train
bcbio/bcbio-nextgen
bcbio/distributed/ipython.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/distributed/ipython.py#L67-L78
def per_machine_target_cores(cores, num_jobs): """Select target cores on larger machines to leave room for batch script and controller. On resource constrained environments, we want to pack all bcbio submissions onto a specific number of machines. This gives up some cores to enable sharing cores with the c...
[ "def", "per_machine_target_cores", "(", "cores", ",", "num_jobs", ")", ":", "if", "cores", ">=", "32", "and", "num_jobs", "==", "1", ":", "cores", "=", "cores", "-", "2", "elif", "cores", ">=", "16", "and", "num_jobs", "in", "[", "1", ",", "2", "]", ...
Select target cores on larger machines to leave room for batch script and controller. On resource constrained environments, we want to pack all bcbio submissions onto a specific number of machines. This gives up some cores to enable sharing cores with the controller and batch script on larger machines.
[ "Select", "target", "cores", "on", "larger", "machines", "to", "leave", "room", "for", "batch", "script", "and", "controller", "." ]
python
train
tradenity/python-sdk
tradenity/resources/payment_card.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/payment_card.py#L966-L987
def update_payment_card_by_id(cls, payment_card_id, payment_card, **kwargs): """Update PaymentCard Update attributes of PaymentCard This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.update_payme...
[ "def", "update_payment_card_by_id", "(", "cls", ",", "payment_card_id", ",", "payment_card", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls"...
Update PaymentCard Update attributes of PaymentCard This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.update_payment_card_by_id(payment_card_id, payment_card, async=True) >>> result = thread.get...
[ "Update", "PaymentCard" ]
python
train
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/build/build_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/build/build_client.py#L576-L589
def get_build_controller(self, controller_id): """GetBuildController. Gets a controller :param int controller_id: :rtype: :class:`<BuildController> <azure.devops.v5_0.build.models.BuildController>` """ route_values = {} if controller_id is not None: ro...
[ "def", "get_build_controller", "(", "self", ",", "controller_id", ")", ":", "route_values", "=", "{", "}", "if", "controller_id", "is", "not", "None", ":", "route_values", "[", "'controllerId'", "]", "=", "self", ".", "_serialize", ".", "url", "(", "'control...
GetBuildController. Gets a controller :param int controller_id: :rtype: :class:`<BuildController> <azure.devops.v5_0.build.models.BuildController>`
[ "GetBuildController", ".", "Gets", "a", "controller", ":", "param", "int", "controller_id", ":", ":", "rtype", ":", ":", "class", ":", "<BuildController", ">", "<azure", ".", "devops", ".", "v5_0", ".", "build", ".", "models", ".", "BuildController", ">" ]
python
train
fkarb/xltable
xltable/expression.py
https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/expression.py#L72-L79
def has_value(self): """return True if value has been set""" try: if isinstance(self.__value, Expression): return self.__value.has_value return True except AttributeError: return False
[ "def", "has_value", "(", "self", ")", ":", "try", ":", "if", "isinstance", "(", "self", ".", "__value", ",", "Expression", ")", ":", "return", "self", ".", "__value", ".", "has_value", "return", "True", "except", "AttributeError", ":", "return", "False" ]
return True if value has been set
[ "return", "True", "if", "value", "has", "been", "set" ]
python
train
moonso/vcftoolbox
vcftoolbox/add_variant_information.py
https://github.com/moonso/vcftoolbox/blob/438fb1d85a83812c389774b94802eb5921c89e3a/vcftoolbox/add_variant_information.py#L19-L79
def replace_vcf_info(keyword, annotation, variant_line=None, variant_dict=None): """Replace the information of a info field of a vcf variant line or a variant dict. Arguments: variant_line (str): A vcf formatted variant line variant_dict (dict): A variant dictionary keyword...
[ "def", "replace_vcf_info", "(", "keyword", ",", "annotation", ",", "variant_line", "=", "None", ",", "variant_dict", "=", "None", ")", ":", "new_info", "=", "'{0}={1}'", ".", "format", "(", "keyword", ",", "annotation", ")", "logger", ".", "debug", "(", "\...
Replace the information of a info field of a vcf variant line or a variant dict. Arguments: variant_line (str): A vcf formatted variant line variant_dict (dict): A variant dictionary keyword (str): The info field key annotation (str): If the annotation is a key, value p...
[ "Replace", "the", "information", "of", "a", "info", "field", "of", "a", "vcf", "variant", "line", "or", "a", "variant", "dict", ".", "Arguments", ":", "variant_line", "(", "str", ")", ":", "A", "vcf", "formatted", "variant", "line", "variant_dict", "(", ...
python
train
robotools/fontParts
Lib/fontParts/base/segment.py
https://github.com/robotools/fontParts/blob/d2ff106fe95f9d566161d936a645157626568712/Lib/fontParts/base/segment.py#L159-L193
def _set_type(self, newType): """ Subclasses may override this method. """ oldType = self.type if oldType == newType: return contour = self.contour if contour is None: raise FontPartsError("The segment does not belong to a contour.") ...
[ "def", "_set_type", "(", "self", ",", "newType", ")", ":", "oldType", "=", "self", ".", "type", "if", "oldType", "==", "newType", ":", "return", "contour", "=", "self", ".", "contour", "if", "contour", "is", "None", ":", "raise", "FontPartsError", "(", ...
Subclasses may override this method.
[ "Subclasses", "may", "override", "this", "method", "." ]
python
train
raymontag/kppy
kppy/database.py
https://github.com/raymontag/kppy/blob/a43f1fff7d49da1da4b3d8628a1b3ebbaf47f43a/kppy/database.py#L846-L859
def _cbc_decrypt(self, final_key, crypted_content): """This method decrypts the database""" # Just decrypt the content with the created key aes = AES.new(final_key, AES.MODE_CBC, self._enc_iv) decrypted_content = aes.decrypt(crypted_content) padding = decrypted_content[-1] ...
[ "def", "_cbc_decrypt", "(", "self", ",", "final_key", ",", "crypted_content", ")", ":", "# Just decrypt the content with the created key", "aes", "=", "AES", ".", "new", "(", "final_key", ",", "AES", ".", "MODE_CBC", ",", "self", ".", "_enc_iv", ")", "decrypted_...
This method decrypts the database
[ "This", "method", "decrypts", "the", "database" ]
python
train
yyuu/botornado
boto/dynamodb/layer2.py
https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/dynamodb/layer2.py#L367-L383
def update_throughput(self, table, read_units, write_units): """ Update the ProvisionedThroughput for the Amazon DynamoDB Table. :type table: :class:`boto.dynamodb.table.Table` :param table: The Table object whose throughput is being updated. :type read_units: int ...
[ "def", "update_throughput", "(", "self", ",", "table", ",", "read_units", ",", "write_units", ")", ":", "response", "=", "self", ".", "layer1", ".", "update_table", "(", "table", ".", "name", ",", "{", "'ReadCapacityUnits'", ":", "read_units", ",", "'WriteCa...
Update the ProvisionedThroughput for the Amazon DynamoDB Table. :type table: :class:`boto.dynamodb.table.Table` :param table: The Table object whose throughput is being updated. :type read_units: int :param read_units: The new value for ReadCapacityUnits. :type...
[ "Update", "the", "ProvisionedThroughput", "for", "the", "Amazon", "DynamoDB", "Table", "." ]
python
train
gitpython-developers/GitPython
git/diff.py
https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/diff.py#L404-L459
def _index_from_patch_format(cls, repo, proc): """Create a new DiffIndex from the given text which must be in patch format :param repo: is the repository we are operating on - it is required :param stream: result of 'git diff' as a stream (supporting file protocol) :return: git.DiffIndex...
[ "def", "_index_from_patch_format", "(", "cls", ",", "repo", ",", "proc", ")", ":", "## FIXME: Here SLURPING raw, need to re-phrase header-regexes linewise.", "text", "=", "[", "]", "handle_process_output", "(", "proc", ",", "text", ".", "append", ",", "None", ",", "...
Create a new DiffIndex from the given text which must be in patch format :param repo: is the repository we are operating on - it is required :param stream: result of 'git diff' as a stream (supporting file protocol) :return: git.DiffIndex
[ "Create", "a", "new", "DiffIndex", "from", "the", "given", "text", "which", "must", "be", "in", "patch", "format", ":", "param", "repo", ":", "is", "the", "repository", "we", "are", "operating", "on", "-", "it", "is", "required", ":", "param", "stream", ...
python
train
mojaie/chorus
chorus/topology.py
https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/topology.py#L21-L81
def recognize(mol): """ Detect cycle basis, biconnected and isolated components (DFS). This will add following attribute to the molecule instance object. mol.ring: Cycle basis mol.scaffold: biconnected components mol.isolated: isolated components other than the largest one To find minimum set ...
[ "def", "recognize", "(", "mol", ")", ":", "g", "=", "set", "(", "i", "for", "i", ",", "_", "in", "mol", ".", "atoms_iter", "(", ")", ")", "bccs", "=", "{", "}", "# BiConnected Components", "isoc", "=", "[", "]", "# ISOlated Components", "while", "g",...
Detect cycle basis, biconnected and isolated components (DFS). This will add following attribute to the molecule instance object. mol.ring: Cycle basis mol.scaffold: biconnected components mol.isolated: isolated components other than the largest one To find minimum set of rings, additionally execu...
[ "Detect", "cycle", "basis", "biconnected", "and", "isolated", "components", "(", "DFS", ")", ".", "This", "will", "add", "following", "attribute", "to", "the", "molecule", "instance", "object", "." ]
python
train
tgbugs/pyontutils
ilxutils/ilxutils/tools.py
https://github.com/tgbugs/pyontutils/blob/3d913db29c177db39151592909a4f56170ef8b35/ilxutils/ilxutils/tools.py#L11-L49
def string_profiler(string, start_delimiter='(', end_delimiter=')', remove=True): ''' long = '(life is is good) love world "(blah) blah" "here I am" once again "yes" blah ' print(string_profiler(long)) null = '' print(string_profiler(null)) short = '(life love) yes(and much m...
[ "def", "string_profiler", "(", "string", ",", "start_delimiter", "=", "'('", ",", "end_delimiter", "=", "')'", ",", "remove", "=", "True", ")", ":", "mark", "=", "0", "string_list", "=", "[", "]", "tmp_string", "=", "''", "for", "i", "in", "range", "("...
long = '(life is is good) love world "(blah) blah" "here I am" once again "yes" blah ' print(string_profiler(long)) null = '' print(string_profiler(null)) short = '(life love) yes(and much more)' print(string_profiler(short)) short = 'yes "life love"' print(string...
[ "long", "=", "(", "life", "is", "is", "good", ")", "love", "world", "(", "blah", ")", "blah", "here", "I", "am", "once", "again", "yes", "blah", "print", "(", "string_profiler", "(", "long", "))", "null", "=", "print", "(", "string_profiler", "(", "n...
python
train
soravux/scoop
scoop/futures.py
https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/futures.py#L282-L305
def submit(func, *args, **kwargs): """Submit an independent asynchronous :class:`~scoop._types.Future` that will either run locally or remotely as `func(*args)`. :param func: Any picklable callable object (function or class object with *__call__* method); this object will be called to execute the F...
[ "def", "submit", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "child", "=", "_createFuture", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", "control", ".", "futureDict", "[", "control", ".", "current", ".", "id", ...
Submit an independent asynchronous :class:`~scoop._types.Future` that will either run locally or remotely as `func(*args)`. :param func: Any picklable callable object (function or class object with *__call__* method); this object will be called to execute the Future. The callable must return a ...
[ "Submit", "an", "independent", "asynchronous", ":", "class", ":", "~scoop", ".", "_types", ".", "Future", "that", "will", "either", "run", "locally", "or", "remotely", "as", "func", "(", "*", "args", ")", "." ]
python
train
lingthio/Flask-User
flask_user/user_manager__utils.py
https://github.com/lingthio/Flask-User/blob/a379fa0a281789618c484b459cb41236779b95b1/flask_user/user_manager__utils.py#L36-L44
def email_is_available(self, new_email): """Check if ``new_email`` is available. | Returns True if ``new_email`` does not exist or belongs to the current user. | Return False otherwise. """ user, user_email = self.db_manager.get_user_and_user_email_by_email(new_email) r...
[ "def", "email_is_available", "(", "self", ",", "new_email", ")", ":", "user", ",", "user_email", "=", "self", ".", "db_manager", ".", "get_user_and_user_email_by_email", "(", "new_email", ")", "return", "(", "user", "==", "None", ")" ]
Check if ``new_email`` is available. | Returns True if ``new_email`` does not exist or belongs to the current user. | Return False otherwise.
[ "Check", "if", "new_email", "is", "available", "." ]
python
train
Kortemme-Lab/klab
klab/bio/pymolmod/colors.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/bio/pymolmod/colors.py#L385-L397
def update(self, path, node): '''Update the dict with a new color using a 'path' through the dict. You can either pass an existing path e.g. 'Scaffold.mutations' to override a color or part of the hierarchy or you can add a new leaf node or dict.''' assert(type(path) == type(self.name)) ...
[ "def", "update", "(", "self", ",", "path", ",", "node", ")", ":", "assert", "(", "type", "(", "path", ")", "==", "type", "(", "self", ".", "name", ")", ")", "assert", "(", "type", "(", "node", ")", "==", "type", "(", "self", ".", "name", ")", ...
Update the dict with a new color using a 'path' through the dict. You can either pass an existing path e.g. 'Scaffold.mutations' to override a color or part of the hierarchy or you can add a new leaf node or dict.
[ "Update", "the", "dict", "with", "a", "new", "color", "using", "a", "path", "through", "the", "dict", ".", "You", "can", "either", "pass", "an", "existing", "path", "e", ".", "g", ".", "Scaffold", ".", "mutations", "to", "override", "a", "color", "or",...
python
train
QualiSystems/vCenterShell
package/cloudshell/cp/vcenter/commands/command_orchestrator.py
https://github.com/QualiSystems/vCenterShell/blob/e2e24cd938a92a68f4a8e6a860810d3ef72aae6d/package/cloudshell/cp/vcenter/commands/command_orchestrator.py#L358-L372
def DeleteInstance(self, context, ports): """ Destroy Vm Command, will only destroy the vm and will not remove the resource :param models.QualiDriverModels.ResourceRemoteCommandContext context: the context the command runs on :param list[string] ports: the ports of the connection betwee...
[ "def", "DeleteInstance", "(", "self", ",", "context", ",", "ports", ")", ":", "resource_details", "=", "self", ".", "_parse_remote_model", "(", "context", ")", "# execute command", "res", "=", "self", ".", "command_wrapper", ".", "execute_command_with_connection", ...
Destroy Vm Command, will only destroy the vm and will not remove the resource :param models.QualiDriverModels.ResourceRemoteCommandContext context: the context the command runs on :param list[string] ports: the ports of the connection between the remote resource and the local resource, NOT IN USE!!!
[ "Destroy", "Vm", "Command", "will", "only", "destroy", "the", "vm", "and", "will", "not", "remove", "the", "resource" ]
python
train
tdgunes/pyplyn
pyplyn/pyp.py
https://github.com/tdgunes/pyplyn/blob/4b390e9b6137432d5e3db17436fc32d2238d1eff/pyplyn/pyp.py#L32-L43
def make_assertions(input_pipe, other_pipes, output_pipe): """ To assure that the pipe is correctly settled :param input_pipe: :param other_pipes: can be [] :param output_pipe: :return: """ assert isinstance(input_pipe, elements.InPypElement), 'Wrong input...
[ "def", "make_assertions", "(", "input_pipe", ",", "other_pipes", ",", "output_pipe", ")", ":", "assert", "isinstance", "(", "input_pipe", ",", "elements", ".", "InPypElement", ")", ",", "'Wrong input element type, want a InPypElement!'", "assert", "isinstance", "(", "...
To assure that the pipe is correctly settled :param input_pipe: :param other_pipes: can be [] :param output_pipe: :return:
[ "To", "assure", "that", "the", "pipe", "is", "correctly", "settled", ":", "param", "input_pipe", ":", ":", "param", "other_pipes", ":", "can", "be", "[]", ":", "param", "output_pipe", ":", ":", "return", ":" ]
python
train
PredixDev/predixpy
predix/admin/blobstore.py
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/blobstore.py#L46-L75
def add_to_manifest(self, manifest): """ Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry...
[ "def", "add_to_manifest", "(", "self", ",", "manifest", ")", ":", "# Add this service to the list of services", "manifest", ".", "add_service", "(", "self", ".", "service", ".", "name", ")", "# Add environment variables", "url", "=", "predix", ".", "config", ".", ...
Add useful details to the manifest about this service so that it can be used in an application. :param manifest: An predix.admin.app.Manifest object instance that manages reading/writing manifest config for a cloud foundry app.
[ "Add", "useful", "details", "to", "the", "manifest", "about", "this", "service", "so", "that", "it", "can", "be", "used", "in", "an", "application", "." ]
python
train
gem/oq-engine
openquake/hazardlib/geo/surface/base.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/base.py#L377-L414
def get_hypo_location(self, mesh_spacing, hypo_loc=None): """ The method determines the location of the hypocentre within the rupture :param mesh: :class:`~openquake.hazardlib.geo.mesh.Mesh` of points :param mesh_spacing: The desired distance between two adjacent...
[ "def", "get_hypo_location", "(", "self", ",", "mesh_spacing", ",", "hypo_loc", "=", "None", ")", ":", "mesh", "=", "self", ".", "mesh", "centroid", "=", "mesh", ".", "get_middle_point", "(", ")", "if", "hypo_loc", "is", "None", ":", "return", "centroid", ...
The method determines the location of the hypocentre within the rupture :param mesh: :class:`~openquake.hazardlib.geo.mesh.Mesh` of points :param mesh_spacing: The desired distance between two adjacent points in source's ruptures' mesh, in km. Mainly this parameter a...
[ "The", "method", "determines", "the", "location", "of", "the", "hypocentre", "within", "the", "rupture" ]
python
train
pazz/urwidtrees
urwidtrees/tree.py
https://github.com/pazz/urwidtrees/blob/d1fa38ce4f37db00bdfc574b856023b5db4c7ead/urwidtrees/tree.py#L102-L111
def next_position(self, pos): """returns the next position in depth-first order""" candidate = None if pos is not None: candidate = self.first_child_position(pos) if candidate is None: candidate = self.next_sibling_position(pos) if candidat...
[ "def", "next_position", "(", "self", ",", "pos", ")", ":", "candidate", "=", "None", "if", "pos", "is", "not", "None", ":", "candidate", "=", "self", ".", "first_child_position", "(", "pos", ")", "if", "candidate", "is", "None", ":", "candidate", "=", ...
returns the next position in depth-first order
[ "returns", "the", "next", "position", "in", "depth", "-", "first", "order" ]
python
train
Komnomnomnom/swigibpy
swigibpy.py
https://github.com/Komnomnomnom/swigibpy/blob/cfd307fdbfaffabc69a2dc037538d7e34a8b8daf/swigibpy.py#L1125-L1127
def placeOrder(self, id, contract, order): """placeOrder(EClient self, OrderId id, Contract contract, Order order)""" return _swigibpy.EClient_placeOrder(self, id, contract, order)
[ "def", "placeOrder", "(", "self", ",", "id", ",", "contract", ",", "order", ")", ":", "return", "_swigibpy", ".", "EClient_placeOrder", "(", "self", ",", "id", ",", "contract", ",", "order", ")" ]
placeOrder(EClient self, OrderId id, Contract contract, Order order)
[ "placeOrder", "(", "EClient", "self", "OrderId", "id", "Contract", "contract", "Order", "order", ")" ]
python
train
sdispater/cleo
cleo/commands/command.py
https://github.com/sdispater/cleo/blob/cf44ac2eba2d6435516501e47e5521ee2da9115a/cleo/commands/command.py#L284-L288
def progress_indicator(self, fmt=None, interval=100, values=None): """ Creates a new progress indicator. """ return ProgressIndicator(self.io, fmt, interval, values)
[ "def", "progress_indicator", "(", "self", ",", "fmt", "=", "None", ",", "interval", "=", "100", ",", "values", "=", "None", ")", ":", "return", "ProgressIndicator", "(", "self", ".", "io", ",", "fmt", ",", "interval", ",", "values", ")" ]
Creates a new progress indicator.
[ "Creates", "a", "new", "progress", "indicator", "." ]
python
train
apache/incubator-mxnet
python/mxnet/recordio.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L123-L132
def close(self): """Closes the record file.""" if not self.is_open: return if self.writable: check_call(_LIB.MXRecordIOWriterFree(self.handle)) else: check_call(_LIB.MXRecordIOReaderFree(self.handle)) self.is_open = False self.pid = Non...
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "is_open", ":", "return", "if", "self", ".", "writable", ":", "check_call", "(", "_LIB", ".", "MXRecordIOWriterFree", "(", "self", ".", "handle", ")", ")", "else", ":", "check_call", "(",...
Closes the record file.
[ "Closes", "the", "record", "file", "." ]
python
train
pandas-dev/pandas
pandas/io/stata.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/stata.py#L2810-L2835
def _write_map(self): """Called twice during file write. The first populates the values in the map with 0s. The second call writes the final map locations when all blocks have been written.""" if self._map is None: self._map = OrderedDict((('stata_data', 0), ...
[ "def", "_write_map", "(", "self", ")", ":", "if", "self", ".", "_map", "is", "None", ":", "self", ".", "_map", "=", "OrderedDict", "(", "(", "(", "'stata_data'", ",", "0", ")", ",", "(", "'map'", ",", "self", ".", "_file", ".", "tell", "(", ")", ...
Called twice during file write. The first populates the values in the map with 0s. The second call writes the final map locations when all blocks have been written.
[ "Called", "twice", "during", "file", "write", ".", "The", "first", "populates", "the", "values", "in", "the", "map", "with", "0s", ".", "The", "second", "call", "writes", "the", "final", "map", "locations", "when", "all", "blocks", "have", "been", "written...
python
train
pinax/pinax-ratings
pinax/ratings/templatetags/pinax_ratings_tags.py
https://github.com/pinax/pinax-ratings/blob/eca388fea1ccd09ba844ac29a7489e41b64267f5/pinax/ratings/templatetags/pinax_ratings_tags.py#L115-L126
def rating_count(obj): """ Total amount of users who have submitted a positive rating for this object. Usage: {% rating_count obj %} """ count = Rating.objects.filter( object_id=obj.pk, content_type=ContentType.objects.get_for_model(obj), ).exclude(rating=0).count() ...
[ "def", "rating_count", "(", "obj", ")", ":", "count", "=", "Rating", ".", "objects", ".", "filter", "(", "object_id", "=", "obj", ".", "pk", ",", "content_type", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "obj", ")", ",", ")", ".", ...
Total amount of users who have submitted a positive rating for this object. Usage: {% rating_count obj %}
[ "Total", "amount", "of", "users", "who", "have", "submitted", "a", "positive", "rating", "for", "this", "object", "." ]
python
train
dslackw/slpkg
slpkg/repolist.py
https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/repolist.py#L40-L76
def repos(self): """View or enabled or disabled repositories """ def_cnt, cus_cnt = 0, 0 print("") self.msg.template(78) print("{0}{1}{2}{3}{4}{5}{6}".format( "| Repo id", " " * 2, "Repo URL", " " * 44, "Default", " " * 3, "...
[ "def", "repos", "(", "self", ")", ":", "def_cnt", ",", "cus_cnt", "=", "0", ",", "0", "print", "(", "\"\"", ")", "self", ".", "msg", ".", "template", "(", "78", ")", "print", "(", "\"{0}{1}{2}{3}{4}{5}{6}\"", ".", "format", "(", "\"| Repo id\"", ",", ...
View or enabled or disabled repositories
[ "View", "or", "enabled", "or", "disabled", "repositories" ]
python
train
JukeboxPipeline/jukeboxmaya
src/jukeboxmaya/launcher.py
https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/launcher.py#L58-L68
def setup_launch_parser(self, parser): """Setup the given parser for the launch command :param parser: the argument parser to setup :type parser: :class:`argparse.ArgumentParser` :returns: None :rtype: None :raises: None """ parser.set_defaults(func=self....
[ "def", "setup_launch_parser", "(", "self", ",", "parser", ")", ":", "parser", ".", "set_defaults", "(", "func", "=", "self", ".", "launch", ")", "parser", ".", "add_argument", "(", "\"addon\"", ",", "help", "=", "\"The jukebox addon to launch. The addon should be ...
Setup the given parser for the launch command :param parser: the argument parser to setup :type parser: :class:`argparse.ArgumentParser` :returns: None :rtype: None :raises: None
[ "Setup", "the", "given", "parser", "for", "the", "launch", "command" ]
python
train
Alignak-monitoring/alignak
alignak/contactdowntime.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/contactdowntime.py#L123-L131
def exit(self, contacts): """Wrapper to call raise_exit_downtime_log_entry for ref (host/service) set can_be_deleted to True :return: None """ contact = contacts[self.ref] contact.raise_exit_downtime_log_entry() self.can_be_deleted = True
[ "def", "exit", "(", "self", ",", "contacts", ")", ":", "contact", "=", "contacts", "[", "self", ".", "ref", "]", "contact", ".", "raise_exit_downtime_log_entry", "(", ")", "self", ".", "can_be_deleted", "=", "True" ]
Wrapper to call raise_exit_downtime_log_entry for ref (host/service) set can_be_deleted to True :return: None
[ "Wrapper", "to", "call", "raise_exit_downtime_log_entry", "for", "ref", "(", "host", "/", "service", ")", "set", "can_be_deleted", "to", "True" ]
python
train