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
madedotcom/atomicpuppy
atomicpuppy/atomicpuppy.py
https://github.com/madedotcom/atomicpuppy/blob/3c262c26e74bcfc25199984b425a5dccac0911ac/atomicpuppy/atomicpuppy.py#L74-L87
def location(self): """Return a string uniquely identifying the event. This string can be used to find the event in the event store UI (cf. id attribute, which is the UUID that at time of writing doesn't let you easily find the event). """ if self._location is None: ...
[ "def", "location", "(", "self", ")", ":", "if", "self", ".", "_location", "is", "None", ":", "self", ".", "_location", "=", "\"{}/{}-{}\"", ".", "format", "(", "self", ".", "stream", ",", "self", ".", "type", ",", "self", ".", "sequence", ",", ")", ...
Return a string uniquely identifying the event. This string can be used to find the event in the event store UI (cf. id attribute, which is the UUID that at time of writing doesn't let you easily find the event).
[ "Return", "a", "string", "uniquely", "identifying", "the", "event", "." ]
python
train
rasbt/biopandas
biopandas/pdb/pandas_pdb.py
https://github.com/rasbt/biopandas/blob/615a7cf272692c12bbcfd9d1f217eab440120235/biopandas/pdb/pandas_pdb.py#L341-L373
def _construct_df(pdb_lines): """Construct DataFrames from list of PDB lines.""" valids = tuple(pdb_records.keys()) line_lists = {r: [] for r in valids} line_lists['OTHERS'] = [] for line_num, line in enumerate(pdb_lines): if line.strip(): if line.star...
[ "def", "_construct_df", "(", "pdb_lines", ")", ":", "valids", "=", "tuple", "(", "pdb_records", ".", "keys", "(", ")", ")", "line_lists", "=", "{", "r", ":", "[", "]", "for", "r", "in", "valids", "}", "line_lists", "[", "'OTHERS'", "]", "=", "[", "...
Construct DataFrames from list of PDB lines.
[ "Construct", "DataFrames", "from", "list", "of", "PDB", "lines", "." ]
python
train
wishtack/pysynthetic
synthetic/decorators.py
https://github.com/wishtack/pysynthetic/blob/f37a4a2f1e0313b8c544f60d37c93726bc806ec6/synthetic/decorators.py#L68-L112
def synthesize_member(member_name, default = None, contract = None, read_only = False, getter_name = None, setter_name = None, private_member_name = None): """ When applied to a cl...
[ "def", "synthesize_member", "(", "member_name", ",", "default", "=", "None", ",", "contract", "=", "None", ",", "read_only", "=", "False", ",", "getter_name", "=", "None", ",", "setter_name", "=", "None", ",", "private_member_name", "=", "None", ")", ":", ...
When applied to a class, this decorator adds getter/setter methods to it and overrides the constructor in order to set\ the default value of the member. By default, the getter will be named ``member_name``. (Ex.: ``member_name = 'member' => instance.member()``) By default, the setter will be named ``me...
[ "When", "applied", "to", "a", "class", "this", "decorator", "adds", "getter", "/", "setter", "methods", "to", "it", "and", "overrides", "the", "constructor", "in", "order", "to", "set", "\\", "the", "default", "value", "of", "the", "member", ".", "By", "...
python
train
intel-analytics/BigDL
pyspark/bigdl/keras/converter.py
https://github.com/intel-analytics/BigDL/blob/e9c19788285986ab789a2e2998f9a85d7524779f/pyspark/bigdl/keras/converter.py#L54-L63
def load_weights_from_json_hdf5(def_json, weights_hdf5, by_name=False): """ The file path can be stored in a local file system, HDFS, S3, or any Hadoop-supported file system. """ bmodel = DefinitionLoader.from_json_path(def_json) def_value = BCommon.text_from_path(def_jso...
[ "def", "load_weights_from_json_hdf5", "(", "def_json", ",", "weights_hdf5", ",", "by_name", "=", "False", ")", ":", "bmodel", "=", "DefinitionLoader", ".", "from_json_path", "(", "def_json", ")", "def_value", "=", "BCommon", ".", "text_from_path", "(", "def_json",...
The file path can be stored in a local file system, HDFS, S3, or any Hadoop-supported file system.
[ "The", "file", "path", "can", "be", "stored", "in", "a", "local", "file", "system", "HDFS", "S3", "or", "any", "Hadoop", "-", "supported", "file", "system", "." ]
python
test
decryptus/httpdis
httpdis/httpdis.py
https://github.com/decryptus/httpdis/blob/5d198cdc5558f416634602689b3df2c8aeb34984/httpdis/httpdis.py#L419-L440
def send_response(self, code, message=None, size='-'): """ Send the response header and log the response code. Also send two standard headers with the server software version and the current date. """ # pylint: disable-msg=W0221 if self._to_log or LOG.isEnabledFo...
[ "def", "send_response", "(", "self", ",", "code", ",", "message", "=", "None", ",", "size", "=", "'-'", ")", ":", "# pylint: disable-msg=W0221", "if", "self", ".", "_to_log", "or", "LOG", ".", "isEnabledFor", "(", "logging", ".", "DEBUG", ")", ":", "self...
Send the response header and log the response code. Also send two standard headers with the server software version and the current date.
[ "Send", "the", "response", "header", "and", "log", "the", "response", "code", "." ]
python
train
koalalorenzo/python-digitalocean
digitalocean/FloatingIP.py
https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/FloatingIP.py#L61-L80
def reserve(self, *args, **kwargs): """ Creates a FloatingIP in a region without assigning it to a specific Droplet. Note: Every argument and parameter given to this method will be assigned to the object. Args: region_slug: str - regi...
[ "def", "reserve", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "data", "=", "self", ".", "get_data", "(", "'floating_ips/'", ",", "type", "=", "POST", ",", "params", "=", "{", "'region'", ":", "self", ".", "region_slug", "}", "...
Creates a FloatingIP in a region without assigning it to a specific Droplet. Note: Every argument and parameter given to this method will be assigned to the object. Args: region_slug: str - region's slug (e.g. 'nyc3')
[ "Creates", "a", "FloatingIP", "in", "a", "region", "without", "assigning", "it", "to", "a", "specific", "Droplet", "." ]
python
valid
bububa/pyTOP
pyTOP/packages/requests/sessions.py
https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/packages/requests/sessions.py#L240-L248
def put(self, url, data=None, **kwargs): """Sends a PUT request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`. :param **kwargs: Optional arguments that ``req...
[ "def", "put", "(", "self", ",", "url", ",", "data", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "request", "(", "'put'", ",", "url", ",", "data", "=", "data", ",", "*", "*", "kwargs", ")" ]
Sends a PUT request. Returns :class:`Response` object. :param url: URL for the new :class:`Request` object. :param data: (optional) Dictionary or bytes to send in the body of the :class:`Request`. :param **kwargs: Optional arguments that ``request`` takes.
[ "Sends", "a", "PUT", "request", ".", "Returns", ":", "class", ":", "Response", "object", "." ]
python
train
bennyrowland/suspect
suspect/io/lcmodel.py
https://github.com/bennyrowland/suspect/blob/c09ab0a5013c5a199218214cdd791659243d7e41/suspect/io/lcmodel.py#L42-L150
def write_all_files(filename, data, wref_data=None, params=None): """ Creates an LCModel control file for processing the supplied MRSData, and optional water reference data, updating the default parameters with any values supplied through params. :param filename: the location where the control file...
[ "def", "write_all_files", "(", "filename", ",", "data", ",", "wref_data", "=", "None", ",", "params", "=", "None", ")", ":", "# we assume that the data has one spectral dimension, any others must be", "# spatial", "if", "len", "(", "data", ".", "shape", ")", "==", ...
Creates an LCModel control file for processing the supplied MRSData, and optional water reference data, updating the default parameters with any values supplied through params. :param filename: the location where the control file should be saved. :param data: MRSData to be processed. :param wref_da...
[ "Creates", "an", "LCModel", "control", "file", "for", "processing", "the", "supplied", "MRSData", "and", "optional", "water", "reference", "data", "updating", "the", "default", "parameters", "with", "any", "values", "supplied", "through", "params", "." ]
python
train
tensorflow/cleverhans
examples/nips17_adversarial_competition/eval_infra/code/eval_lib/image_batches.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/examples/nips17_adversarial_competition/eval_infra/code/eval_lib/image_batches.py#L291-L297
def count_generated_adv_examples(self): """Returns total number of all generated adversarial examples.""" result = {} for v in itervalues(self.data): s_id = v['submission_id'] result[s_id] = result.get(s_id, 0) + len(v['images']) return result
[ "def", "count_generated_adv_examples", "(", "self", ")", ":", "result", "=", "{", "}", "for", "v", "in", "itervalues", "(", "self", ".", "data", ")", ":", "s_id", "=", "v", "[", "'submission_id'", "]", "result", "[", "s_id", "]", "=", "result", ".", ...
Returns total number of all generated adversarial examples.
[ "Returns", "total", "number", "of", "all", "generated", "adversarial", "examples", "." ]
python
train
prompt-toolkit/pymux
pymux/arrangement.py
https://github.com/prompt-toolkit/pymux/blob/3f66e62b9de4b2251c7f9afad6c516dc5a30ec67/pymux/arrangement.py#L618-L622
def get_window_by_index(self, index): " Return the Window with this index or None if not found. " for w in self.windows: if w.index == index: return w
[ "def", "get_window_by_index", "(", "self", ",", "index", ")", ":", "for", "w", "in", "self", ".", "windows", ":", "if", "w", ".", "index", "==", "index", ":", "return", "w" ]
Return the Window with this index or None if not found.
[ "Return", "the", "Window", "with", "this", "index", "or", "None", "if", "not", "found", "." ]
python
train
portfors-lab/sparkle
sparkle/run/calibration_runner.py
https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/run/calibration_runner.py#L92-L101
def set_stim_by_index(self, index): """Sets the stimulus to be generated to the one referenced by index :param index: index number of stimulus to set from this class's internal list of stimuli :type index: int """ # remove any current components self.stimulus.clearCompon...
[ "def", "set_stim_by_index", "(", "self", ",", "index", ")", ":", "# remove any current components", "self", ".", "stimulus", ".", "clearComponents", "(", ")", "# add one to index because of tone curve", "self", ".", "stimulus", ".", "insertComponent", "(", "self", "."...
Sets the stimulus to be generated to the one referenced by index :param index: index number of stimulus to set from this class's internal list of stimuli :type index: int
[ "Sets", "the", "stimulus", "to", "be", "generated", "to", "the", "one", "referenced", "by", "index" ]
python
train
ANTsX/ANTsPy
ants/contrib/sampling/transforms.py
https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/contrib/sampling/transforms.py#L242-L273
def transform(self, X, y=None): """ Locally blur an image by applying a gradient anisotropic diffusion filter. Arguments --------- X : ANTsImage image to transform y : ANTsImage (optional) another image to transform. Example ----...
[ "def", "transform", "(", "self", ",", "X", ",", "y", "=", "None", ")", ":", "#if X.pixeltype != 'float':", "# raise ValueError('image.pixeltype must be float ... use TypeCast transform or clone to float')", "insuffix", "=", "X", ".", "_libsuffix", "cast_fn", "=", "utils"...
Locally blur an image by applying a gradient anisotropic diffusion filter. Arguments --------- X : ANTsImage image to transform y : ANTsImage (optional) another image to transform. Example ------- >>> import ants >>> blur = ants....
[ "Locally", "blur", "an", "image", "by", "applying", "a", "gradient", "anisotropic", "diffusion", "filter", "." ]
python
train
Nic30/hwt
hwt/synthesizer/rtlLevel/netlist.py
https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/synthesizer/rtlLevel/netlist.py#L175-L216
def markVisibilityOfSignals(ctx, ctxName, signals, interfaceSignals): """ * check if all signals are driven by something * mark signals with hidden = False if they are connecting statements or if they are external interface """ for sig in signals: driver_cnt = len(sig.drivers) ...
[ "def", "markVisibilityOfSignals", "(", "ctx", ",", "ctxName", ",", "signals", ",", "interfaceSignals", ")", ":", "for", "sig", "in", "signals", ":", "driver_cnt", "=", "len", "(", "sig", ".", "drivers", ")", "has_comb_driver", "=", "False", "if", "driver_cnt...
* check if all signals are driven by something * mark signals with hidden = False if they are connecting statements or if they are external interface
[ "*", "check", "if", "all", "signals", "are", "driven", "by", "something", "*", "mark", "signals", "with", "hidden", "=", "False", "if", "they", "are", "connecting", "statements", "or", "if", "they", "are", "external", "interface" ]
python
test
jazzband/django-axes
axes/middleware.py
https://github.com/jazzband/django-axes/blob/3e215a174030e43e7ab8c2a79c395eb0eeddc667/axes/middleware.py#L38-L49
def update_request(self, request: HttpRequest): """ Update given Django ``HttpRequest`` with necessary attributes before passing it on the ``get_response`` for further Django middleware and view processing. """ request.axes_attempt_time = now() request.axes_ip_ad...
[ "def", "update_request", "(", "self", ",", "request", ":", "HttpRequest", ")", ":", "request", ".", "axes_attempt_time", "=", "now", "(", ")", "request", ".", "axes_ip_address", "=", "get_client_ip_address", "(", "request", ")", "request", ".", "axes_user_agent"...
Update given Django ``HttpRequest`` with necessary attributes before passing it on the ``get_response`` for further Django middleware and view processing.
[ "Update", "given", "Django", "HttpRequest", "with", "necessary", "attributes", "before", "passing", "it", "on", "the", "get_response", "for", "further", "Django", "middleware", "and", "view", "processing", "." ]
python
train
gwastro/pycbc
pycbc/inference/geweke.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/inference/geweke.py#L22-L83
def geweke(x, seg_length, seg_stride, end_idx, ref_start, ref_end=None, seg_start=0): """ Calculates Geweke conervergence statistic for a chain of data. This function will advance along the chain and calculate the statistic for each step. Parameters ---------- x : numpy.array ...
[ "def", "geweke", "(", "x", ",", "seg_length", ",", "seg_stride", ",", "end_idx", ",", "ref_start", ",", "ref_end", "=", "None", ",", "seg_start", "=", "0", ")", ":", "# lists to hold statistic and end index", "stats", "=", "[", "]", "ends", "=", "[", "]", ...
Calculates Geweke conervergence statistic for a chain of data. This function will advance along the chain and calculate the statistic for each step. Parameters ---------- x : numpy.array A one-dimensional array of data. seg_length : int Number of samples to use for each Geweke c...
[ "Calculates", "Geweke", "conervergence", "statistic", "for", "a", "chain", "of", "data", ".", "This", "function", "will", "advance", "along", "the", "chain", "and", "calculate", "the", "statistic", "for", "each", "step", "." ]
python
train
abilian/abilian-core
abilian/core/models/attachment.py
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/core/models/attachment.py#L61-L66
def for_entity(obj, check_support_attachments=False): """Return attachments on an entity.""" if check_support_attachments and not supports_attachments(obj): return [] return getattr(obj, ATTRIBUTE)
[ "def", "for_entity", "(", "obj", ",", "check_support_attachments", "=", "False", ")", ":", "if", "check_support_attachments", "and", "not", "supports_attachments", "(", "obj", ")", ":", "return", "[", "]", "return", "getattr", "(", "obj", ",", "ATTRIBUTE", ")"...
Return attachments on an entity.
[ "Return", "attachments", "on", "an", "entity", "." ]
python
train
cokelaer/reports
reports/report.py
https://github.com/cokelaer/reports/blob/7703b1e27d440c3193ee6cc90bfecd78cc98b737/reports/report.py#L230-L240
def get_time_now(self): """Returns a time stamp""" import datetime import getpass username = getpass.getuser() # this is not working on some systems: os.environ["USERNAME"] timenow = str(datetime.datetime.now()) timenow = timenow.split('.')[0] msg = '<div ...
[ "def", "get_time_now", "(", "self", ")", ":", "import", "datetime", "import", "getpass", "username", "=", "getpass", ".", "getuser", "(", ")", "# this is not working on some systems: os.environ[\"USERNAME\"]", "timenow", "=", "str", "(", "datetime", ".", "datetime", ...
Returns a time stamp
[ "Returns", "a", "time", "stamp" ]
python
train
jjgomera/iapws
iapws/iapws97.py
https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/iapws97.py#L423-L473
def _PSat_s(s): """Define the saturated line, P=f(s) for region 3 Parameters ---------- s : float Specific entropy, [kJ/kgK] Returns ------- P : float Pressure, [MPa] Notes ------ Raise :class:`NotImplementedError` if input isn't in limit: * s'(623.15K...
[ "def", "_PSat_s", "(", "s", ")", ":", "# Check input parameters", "smin_Ps3", "=", "_Region1", "(", "623.15", ",", "Ps_623", ")", "[", "\"s\"", "]", "smax_Ps3", "=", "_Region2", "(", "623.15", ",", "Ps_623", ")", "[", "\"s\"", "]", "if", "s", "<", "smi...
Define the saturated line, P=f(s) for region 3 Parameters ---------- s : float Specific entropy, [kJ/kgK] Returns ------- P : float Pressure, [MPa] Notes ------ Raise :class:`NotImplementedError` if input isn't in limit: * s'(623.15K) ≤ s ≤ s''(623.15K) ...
[ "Define", "the", "saturated", "line", "P", "=", "f", "(", "s", ")", "for", "region", "3" ]
python
train
pypa/pipenv
pipenv/vendor/distlib/database.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/distlib/database.py#L1330-L1339
def make_dist(name, version, **kwargs): """ A convenience method for making a dist given just a name and version. """ summary = kwargs.pop('summary', 'Placeholder for summary') md = Metadata(**kwargs) md.name = name md.version = version md.summary = summary or 'Placeholder for summary' ...
[ "def", "make_dist", "(", "name", ",", "version", ",", "*", "*", "kwargs", ")", ":", "summary", "=", "kwargs", ".", "pop", "(", "'summary'", ",", "'Placeholder for summary'", ")", "md", "=", "Metadata", "(", "*", "*", "kwargs", ")", "md", ".", "name", ...
A convenience method for making a dist given just a name and version.
[ "A", "convenience", "method", "for", "making", "a", "dist", "given", "just", "a", "name", "and", "version", "." ]
python
train
delph-in/pydelphin
delphin/itsdb.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/itsdb.py#L1858-L1883
def apply_rows(applicators, rows): """ Yield rows after applying the applicator functions to them. Applicators are simple unary functions that return a value, and that value is stored in the yielded row. E.g. `row[col] = applicator(row[col])`. These are useful to, e.g., cast strings to numeric ...
[ "def", "apply_rows", "(", "applicators", ",", "rows", ")", ":", "for", "row", "in", "rows", ":", "for", "(", "cols", ",", "function", ")", "in", "applicators", ":", "for", "col", "in", "(", "cols", "or", "[", "]", ")", ":", "value", "=", "row", "...
Yield rows after applying the applicator functions to them. Applicators are simple unary functions that return a value, and that value is stored in the yielded row. E.g. `row[col] = applicator(row[col])`. These are useful to, e.g., cast strings to numeric datatypes, to convert formats stored in a cell,...
[ "Yield", "rows", "after", "applying", "the", "applicator", "functions", "to", "them", "." ]
python
train
deep-compute/basescript
basescript/log.py
https://github.com/deep-compute/basescript/blob/f7233963c5291530fcb2444a7f45b556e6407b90/basescript/log.py#L166-L175
def error(self, event=None, *args, **kw): """ Process event and call :meth:`logging.Logger.error` with the result. """ if not self._logger.isEnabledFor(logging.ERROR): return kw = self._add_base_info(kw) kw['level'] = "error" return self._proxy_to_log...
[ "def", "error", "(", "self", ",", "event", "=", "None", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "not", "self", ".", "_logger", ".", "isEnabledFor", "(", "logging", ".", "ERROR", ")", ":", "return", "kw", "=", "self", ".", "_add_bas...
Process event and call :meth:`logging.Logger.error` with the result.
[ "Process", "event", "and", "call", ":", "meth", ":", "logging", ".", "Logger", ".", "error", "with", "the", "result", "." ]
python
train
watson-developer-cloud/python-sdk
ibm_watson/natural_language_understanding_v1.py
https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/natural_language_understanding_v1.py#L633-L638
def _to_dict(self): """Return a json dictionary representing this model.""" _dict = {} if hasattr(self, 'name') and self.name is not None: _dict['name'] = self.name return _dict
[ "def", "_to_dict", "(", "self", ")", ":", "_dict", "=", "{", "}", "if", "hasattr", "(", "self", ",", "'name'", ")", "and", "self", ".", "name", "is", "not", "None", ":", "_dict", "[", "'name'", "]", "=", "self", ".", "name", "return", "_dict" ]
Return a json dictionary representing this model.
[ "Return", "a", "json", "dictionary", "representing", "this", "model", "." ]
python
train
RedFantom/ttkwidgets
ttkwidgets/color/functions.py
https://github.com/RedFantom/ttkwidgets/blob/02150322060f867b6e59a175522ef84b09168019/ttkwidgets/color/functions.py#L79-L89
def hexa_to_rgb(color): """Convert hexadecimal color to RGB.""" r = int(color[1:3], 16) g = int(color[3:5], 16) b = int(color[5:7], 16) if len(color) == 7: return r, g, b elif len(color) == 9: return r, g, b, int(color[7:9], 16) else: raise ValueError("Invalid hexadec...
[ "def", "hexa_to_rgb", "(", "color", ")", ":", "r", "=", "int", "(", "color", "[", "1", ":", "3", "]", ",", "16", ")", "g", "=", "int", "(", "color", "[", "3", ":", "5", "]", ",", "16", ")", "b", "=", "int", "(", "color", "[", "5", ":", ...
Convert hexadecimal color to RGB.
[ "Convert", "hexadecimal", "color", "to", "RGB", "." ]
python
train
cs50/python-cs50
src/cs50/sql.py
https://github.com/cs50/python-cs50/blob/f987e9036bcf1bf60adf50a2827cc2cd5b9fd08a/src/cs50/sql.py#L68-L87
def _parse(self, e): """Parses an exception, returns its message.""" # MySQL matches = re.search(r"^\(_mysql_exceptions\.OperationalError\) \(\d+, \"(.+)\"\)$", str(e)) if matches: return matches.group(1) # PostgreSQL matches = re.search(r"^\(psycopg2\.Opera...
[ "def", "_parse", "(", "self", ",", "e", ")", ":", "# MySQL", "matches", "=", "re", ".", "search", "(", "r\"^\\(_mysql_exceptions\\.OperationalError\\) \\(\\d+, \\\"(.+)\\\"\\)$\"", ",", "str", "(", "e", ")", ")", "if", "matches", ":", "return", "matches", ".", ...
Parses an exception, returns its message.
[ "Parses", "an", "exception", "returns", "its", "message", "." ]
python
train
thombashi/DateTimeRange
datetimerange/__init__.py
https://github.com/thombashi/DateTimeRange/blob/542a3b69ec256d28cc5d5469fd68207c1b509c9c/datetimerange/__init__.py#L442-L473
def set_end_datetime(self, value, timezone=None): """ Set the end time of the time range. :param datetime.datetime/str value: |param_end_datetime| :raises ValueError: If the value is invalid as a |datetime| value. :Sample Code: .. code:: python from...
[ "def", "set_end_datetime", "(", "self", ",", "value", ",", "timezone", "=", "None", ")", ":", "if", "value", "is", "None", ":", "self", ".", "__end_datetime", "=", "None", "return", "try", ":", "self", ".", "__end_datetime", "=", "typepy", ".", "type", ...
Set the end time of the time range. :param datetime.datetime/str value: |param_end_datetime| :raises ValueError: If the value is invalid as a |datetime| value. :Sample Code: .. code:: python from datetimerange import DateTimeRange time_range = DateT...
[ "Set", "the", "end", "time", "of", "the", "time", "range", "." ]
python
train
Esri/ArcREST
src/arcresthelper/common.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/common.py#L459-L488
def find_replace_string(obj, find, replace): """Performs a string.replace() on the input object. Args: obj (object): The object to find/replace. It will be cast to ``str``. find (str): The string to search for. replace (str): The string to replace with. Returns: str: The rep...
[ "def", "find_replace_string", "(", "obj", ",", "find", ",", "replace", ")", ":", "try", ":", "strobj", "=", "str", "(", "obj", ")", "newStr", "=", "string", ".", "replace", "(", "strobj", ",", "find", ",", "replace", ")", "if", "newStr", "==", "strob...
Performs a string.replace() on the input object. Args: obj (object): The object to find/replace. It will be cast to ``str``. find (str): The string to search for. replace (str): The string to replace with. Returns: str: The replaced string.
[ "Performs", "a", "string", ".", "replace", "()", "on", "the", "input", "object", "." ]
python
train
konstantint/matplotlib-venn
matplotlib_venn/_venn2.py
https://github.com/konstantint/matplotlib-venn/blob/c26796c9925bdac512edf48387452fbd1848c791/matplotlib_venn/_venn2.py#L104-L114
def compute_venn2_colors(set_colors): ''' Given two base colors, computes combinations of colors corresponding to all regions of the venn diagram. returns a list of 3 elements, providing colors for regions (10, 01, 11). >>> compute_venn2_colors(('r', 'g')) (array([ 1., 0., 0.]), array([ 0. , 0.5...
[ "def", "compute_venn2_colors", "(", "set_colors", ")", ":", "ccv", "=", "ColorConverter", "(", ")", "base_colors", "=", "[", "np", ".", "array", "(", "ccv", ".", "to_rgb", "(", "c", ")", ")", "for", "c", "in", "set_colors", "]", "return", "(", "base_co...
Given two base colors, computes combinations of colors corresponding to all regions of the venn diagram. returns a list of 3 elements, providing colors for regions (10, 01, 11). >>> compute_venn2_colors(('r', 'g')) (array([ 1., 0., 0.]), array([ 0. , 0.5, 0. ]), array([ 0.7 , 0.35, 0. ]))
[ "Given", "two", "base", "colors", "computes", "combinations", "of", "colors", "corresponding", "to", "all", "regions", "of", "the", "venn", "diagram", ".", "returns", "a", "list", "of", "3", "elements", "providing", "colors", "for", "regions", "(", "10", "01...
python
train
springload/draftjs_exporter
draftjs_exporter/command.py
https://github.com/springload/draftjs_exporter/blob/1e391a46f162740f90511cde1ef615858e8de5cb/draftjs_exporter/command.py#L29-L36
def start_stop(name, start, stop, data=''): """ Builds a pair of start/stop commands with the same data. """ return [ Command('start_%s' % name, start, data), Command('stop_%s' % name, stop, data), ]
[ "def", "start_stop", "(", "name", ",", "start", ",", "stop", ",", "data", "=", "''", ")", ":", "return", "[", "Command", "(", "'start_%s'", "%", "name", ",", "start", ",", "data", ")", ",", "Command", "(", "'stop_%s'", "%", "name", ",", "stop", ","...
Builds a pair of start/stop commands with the same data.
[ "Builds", "a", "pair", "of", "start", "/", "stop", "commands", "with", "the", "same", "data", "." ]
python
train
gwastro/pycbc
pycbc/tmpltbank/lambda_mapping.py
https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/tmpltbank/lambda_mapping.py#L138-L155
def ethinca_order_from_string(order): """ Returns the integer giving twice the post-Newtonian order used by the ethinca calculation. Currently valid only for TaylorF2 metric Parameters ---------- order : string Returns ------- int """ if order in get_ethinca_orders().keys()...
[ "def", "ethinca_order_from_string", "(", "order", ")", ":", "if", "order", "in", "get_ethinca_orders", "(", ")", ".", "keys", "(", ")", ":", "return", "get_ethinca_orders", "(", ")", "[", "order", "]", "else", ":", "raise", "ValueError", "(", "\"Order \"", ...
Returns the integer giving twice the post-Newtonian order used by the ethinca calculation. Currently valid only for TaylorF2 metric Parameters ---------- order : string Returns ------- int
[ "Returns", "the", "integer", "giving", "twice", "the", "post", "-", "Newtonian", "order", "used", "by", "the", "ethinca", "calculation", ".", "Currently", "valid", "only", "for", "TaylorF2", "metric" ]
python
train
bkg/greenwich
greenwich/raster.py
https://github.com/bkg/greenwich/blob/57ec644dadfe43ce0ecf2cfd32a2de71e0c8c141/greenwich/raster.py#L45-L61
def geom_to_array(geom, size, affine): """Converts an OGR polygon to a 2D NumPy array. Arguments: geom -- OGR Geometry size -- array size in pixels as a tuple of (width, height) affine -- AffineTransform """ driver = ImageDriver('MEM') rast = driver.raster(driver.ShortName, size) ra...
[ "def", "geom_to_array", "(", "geom", ",", "size", ",", "affine", ")", ":", "driver", "=", "ImageDriver", "(", "'MEM'", ")", "rast", "=", "driver", ".", "raster", "(", "driver", ".", "ShortName", ",", "size", ")", "rast", ".", "affine", "=", "affine", ...
Converts an OGR polygon to a 2D NumPy array. Arguments: geom -- OGR Geometry size -- array size in pixels as a tuple of (width, height) affine -- AffineTransform
[ "Converts", "an", "OGR", "polygon", "to", "a", "2D", "NumPy", "array", "." ]
python
test
iotile/coretools
iotilecore/iotile/core/utilities/formatting.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/utilities/formatting.py#L20-L27
def indent_list(inlist, level): """Join a list of strings, one per line with 'level' spaces before each one""" indent = ' '*level joinstr = '\n' + indent retval = joinstr.join(inlist) return indent + retval
[ "def", "indent_list", "(", "inlist", ",", "level", ")", ":", "indent", "=", "' '", "*", "level", "joinstr", "=", "'\\n'", "+", "indent", "retval", "=", "joinstr", ".", "join", "(", "inlist", ")", "return", "indent", "+", "retval" ]
Join a list of strings, one per line with 'level' spaces before each one
[ "Join", "a", "list", "of", "strings", "one", "per", "line", "with", "level", "spaces", "before", "each", "one" ]
python
train
QunarOPS/qg.core
qg/core/importutils.py
https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/importutils.py#L24-L33
def import_class(import_str): """Returns a class from a string including module and class.""" mod_str, _sep, class_str = import_str.rpartition('.') try: __import__(mod_str) return getattr(sys.modules[mod_str], class_str) except (ValueError, AttributeError): raise ImportError('Cla...
[ "def", "import_class", "(", "import_str", ")", ":", "mod_str", ",", "_sep", ",", "class_str", "=", "import_str", ".", "rpartition", "(", "'.'", ")", "try", ":", "__import__", "(", "mod_str", ")", "return", "getattr", "(", "sys", ".", "modules", "[", "mod...
Returns a class from a string including module and class.
[ "Returns", "a", "class", "from", "a", "string", "including", "module", "and", "class", "." ]
python
train
python-cmd2/cmd2
cmd2/cmd2.py
https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/cmd2/cmd2.py#L3505-L3508
def do_eos(self, _: argparse.Namespace) -> None: """Handle cleanup when a script has finished executing""" if self._script_dir: self._script_dir.pop()
[ "def", "do_eos", "(", "self", ",", "_", ":", "argparse", ".", "Namespace", ")", "->", "None", ":", "if", "self", ".", "_script_dir", ":", "self", ".", "_script_dir", ".", "pop", "(", ")" ]
Handle cleanup when a script has finished executing
[ "Handle", "cleanup", "when", "a", "script", "has", "finished", "executing" ]
python
train
Guake/guake
guake/prefs.py
https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/prefs.py#L1073-L1313
def load_configs(self): """Load configurations for all widgets in General, Scrolling and Appearance tabs from dconf. """ self._load_default_shell_settings() # restore tabs startup value = self.settings.general.get_boolean('restore-tabs-startup') self.get_widget('...
[ "def", "load_configs", "(", "self", ")", ":", "self", ".", "_load_default_shell_settings", "(", ")", "# restore tabs startup", "value", "=", "self", ".", "settings", ".", "general", ".", "get_boolean", "(", "'restore-tabs-startup'", ")", "self", ".", "get_widget",...
Load configurations for all widgets in General, Scrolling and Appearance tabs from dconf.
[ "Load", "configurations", "for", "all", "widgets", "in", "General", "Scrolling", "and", "Appearance", "tabs", "from", "dconf", "." ]
python
train
fastai/fastai
fastai/text/models/transformer.py
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/text/models/transformer.py#L255-L260
def tfmer_lm_split(model:nn.Module) -> List[nn.Module]: "Split a RNN `model` in groups for differential learning rates." encoder = model[0] n = len(encoder.layers)//3 groups = [list(encoder.layers[:n]), list(encoder.layers[n:2*n]), list(encoder.layers[2*n:])] return groups + [[encoder.encoder, model...
[ "def", "tfmer_lm_split", "(", "model", ":", "nn", ".", "Module", ")", "->", "List", "[", "nn", ".", "Module", "]", ":", "encoder", "=", "model", "[", "0", "]", "n", "=", "len", "(", "encoder", ".", "layers", ")", "//", "3", "groups", "=", "[", ...
Split a RNN `model` in groups for differential learning rates.
[ "Split", "a", "RNN", "model", "in", "groups", "for", "differential", "learning", "rates", "." ]
python
train
ergo/ziggurat_foundations
ziggurat_foundations/models/services/resource_tree.py
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/services/resource_tree.py#L36-L46
def delete_branch(self, resource_id=None, db_session=None, *args, **kwargs): """ This deletes whole branch with children starting from resource_id :param resource_id: :param db_session: :return: """ return self.service.delete_branch( resource_id=resou...
[ "def", "delete_branch", "(", "self", ",", "resource_id", "=", "None", ",", "db_session", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "service", ".", "delete_branch", "(", "resource_id", "=", "resource_id", ","...
This deletes whole branch with children starting from resource_id :param resource_id: :param db_session: :return:
[ "This", "deletes", "whole", "branch", "with", "children", "starting", "from", "resource_id" ]
python
train
respondcreate/django-versatileimagefield
versatileimagefield/registry.py
https://github.com/respondcreate/django-versatileimagefield/blob/d41e279c39cccffafbe876c67596184704ae8877/versatileimagefield/registry.py#L145-L157
def unregister_sizer(self, attr_name): """ Unregister the SizedImage subclass currently assigned to `attr_name`. If a SizedImage subclass isn't already registered to `attr_name` NotRegistered will raise. """ if attr_name not in self._sizedimage_registry: rais...
[ "def", "unregister_sizer", "(", "self", ",", "attr_name", ")", ":", "if", "attr_name", "not", "in", "self", ".", "_sizedimage_registry", ":", "raise", "NotRegistered", "(", "'No SizedImage subclass is registered to %s'", "%", "attr_name", ")", "else", ":", "del", ...
Unregister the SizedImage subclass currently assigned to `attr_name`. If a SizedImage subclass isn't already registered to `attr_name` NotRegistered will raise.
[ "Unregister", "the", "SizedImage", "subclass", "currently", "assigned", "to", "attr_name", "." ]
python
test
sirfoga/pyhal
hal/hashes/md5.py
https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/hashes/md5.py#L19-L34
def file_to_md5(filename, block_size=8192): """Calculate the md5 hash of a file. Memory-friendly solution, it reads the file piece by piece. See stackoverflow.com/questions/1131220/ :param filename: filename to convert :param block_size: size of block :return: MD5 hash of file content """ m...
[ "def", "file_to_md5", "(", "filename", ",", "block_size", "=", "8192", ")", ":", "md5", "=", "hashlib", ".", "md5", "(", ")", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "while", "True", ":", "data", "=", "f", ".", "read", ...
Calculate the md5 hash of a file. Memory-friendly solution, it reads the file piece by piece. See stackoverflow.com/questions/1131220/ :param filename: filename to convert :param block_size: size of block :return: MD5 hash of file content
[ "Calculate", "the", "md5", "hash", "of", "a", "file", ".", "Memory", "-", "friendly", "solution", "it", "reads", "the", "file", "piece", "by", "piece", ".", "See", "stackoverflow", ".", "com", "/", "questions", "/", "1131220", "/" ]
python
train
synw/dataswim
dataswim/charts/chartjs.py
https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/chartjs.py#L19-L52
def _get_chartjs_chart(self, xcol, ycol, chart_type, label=None, opts={}, style={}, options={}, **kwargs): """ Get Chartjs html """ try: xdata = list(self.df[xcol]) except Exception as e: self.err(e, self._get_chartjs_chart, ...
[ "def", "_get_chartjs_chart", "(", "self", ",", "xcol", ",", "ycol", ",", "chart_type", ",", "label", "=", "None", ",", "opts", "=", "{", "}", ",", "style", "=", "{", "}", ",", "options", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "try", ...
Get Chartjs html
[ "Get", "Chartjs", "html" ]
python
train
python-gitlab/python-gitlab
gitlab/v4/objects.py
https://github.com/python-gitlab/python-gitlab/blob/16de1b03fde3dbbe8f851614dd1d8c09de102fe5/gitlab/v4/objects.py#L978-L989
def ldap_sync(self, **kwargs): """Sync LDAP groups. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server cannot perform the request """ ...
[ "def", "ldap_sync", "(", "self", ",", "*", "*", "kwargs", ")", ":", "path", "=", "'/groups/%s/ldap_sync'", "%", "self", ".", "get_id", "(", ")", "self", ".", "manager", ".", "gitlab", ".", "http_post", "(", "path", ",", "*", "*", "kwargs", ")" ]
Sync LDAP groups. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server cannot perform the request
[ "Sync", "LDAP", "groups", "." ]
python
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Environment.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Environment.py#L2241-L2263
def FindSourceFiles(self, node='.'): """ returns a list of all source files. """ node = self.arg2nodes(node, self.fs.Entry)[0] sources = [] def build_source(ss): for s in ss: if isinstance(s, SCons.Node.FS.Dir): build_source(s.all_...
[ "def", "FindSourceFiles", "(", "self", ",", "node", "=", "'.'", ")", ":", "node", "=", "self", ".", "arg2nodes", "(", "node", ",", "self", ".", "fs", ".", "Entry", ")", "[", "0", "]", "sources", "=", "[", "]", "def", "build_source", "(", "ss", ")...
returns a list of all source files.
[ "returns", "a", "list", "of", "all", "source", "files", "." ]
python
train
senaite/senaite.core
bika/lims/browser/workflow/__init__.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/workflow/__init__.py#L75-L94
def get_action(self): """Returns the action to be taken from the request. Returns None if no action is found """ action = self.request.get("workflow_action_id", None) action = self.request.get("workflow_action", action) if not action: return None # A ...
[ "def", "get_action", "(", "self", ")", ":", "action", "=", "self", ".", "request", ".", "get", "(", "\"workflow_action_id\"", ",", "None", ")", "action", "=", "self", ".", "request", ".", "get", "(", "\"workflow_action\"", ",", "action", ")", "if", "not"...
Returns the action to be taken from the request. Returns None if no action is found
[ "Returns", "the", "action", "to", "be", "taken", "from", "the", "request", ".", "Returns", "None", "if", "no", "action", "is", "found" ]
python
train
opendatateam/udata
udata/core/site/rdf.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/core/site/rdf.py#L15-L68
def build_catalog(site, datasets, format=None): '''Build the DCAT catalog for this site''' site_url = url_for('site.home_redirect', _external=True) catalog_url = url_for('site.rdf_catalog', _external=True) graph = Graph(namespace_manager=namespace_manager) catalog = graph.resource(URIRef(catalog_url...
[ "def", "build_catalog", "(", "site", ",", "datasets", ",", "format", "=", "None", ")", ":", "site_url", "=", "url_for", "(", "'site.home_redirect'", ",", "_external", "=", "True", ")", "catalog_url", "=", "url_for", "(", "'site.rdf_catalog'", ",", "_external",...
Build the DCAT catalog for this site
[ "Build", "the", "DCAT", "catalog", "for", "this", "site" ]
python
train
svinota/mdns
mdns/zeroconf.py
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L907-L913
def add_answer_at_time(self, record, now): """Adds an answer if if does not expire by a certain time""" if record is not None: if now == 0 or not record.is_expired(now): self.answers.append((record, now)) if record.rrsig is not None: self.a...
[ "def", "add_answer_at_time", "(", "self", ",", "record", ",", "now", ")", ":", "if", "record", "is", "not", "None", ":", "if", "now", "==", "0", "or", "not", "record", ".", "is_expired", "(", "now", ")", ":", "self", ".", "answers", ".", "append", ...
Adds an answer if if does not expire by a certain time
[ "Adds", "an", "answer", "if", "if", "does", "not", "expire", "by", "a", "certain", "time" ]
python
train
manns/pyspread
pyspread/src/actions/_grid_actions.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/actions/_grid_actions.py#L529-L555
def _save_pys(self, filepath): """Saves file as pys file and returns True if save success Parameters ---------- filepath: String \tTarget file path for xls file """ try: with Bz2AOpen(filepath, "wb", main_window=self.main_...
[ "def", "_save_pys", "(", "self", ",", "filepath", ")", ":", "try", ":", "with", "Bz2AOpen", "(", "filepath", ",", "\"wb\"", ",", "main_window", "=", "self", ".", "main_window", ")", "as", "outfile", ":", "interface", "=", "Pys", "(", "self", ".", "grid...
Saves file as pys file and returns True if save success Parameters ---------- filepath: String \tTarget file path for xls file
[ "Saves", "file", "as", "pys", "file", "and", "returns", "True", "if", "save", "success" ]
python
train
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_0/work_item_tracking_process/work_item_tracking_process_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_0/work_item_tracking_process/work_item_tracking_process_client.py#L434-L457
def remove_group(self, process_id, wit_ref_name, page_id, section_id, group_id): """RemoveGroup. [Preview API] Removes a group from the work item form. :param str process_id: The ID of the process :param str wit_ref_name: The reference name of the work item type :param str page_i...
[ "def", "remove_group", "(", "self", ",", "process_id", ",", "wit_ref_name", ",", "page_id", ",", "section_id", ",", "group_id", ")", ":", "route_values", "=", "{", "}", "if", "process_id", "is", "not", "None", ":", "route_values", "[", "'processId'", "]", ...
RemoveGroup. [Preview API] Removes a group from the work item form. :param str process_id: The ID of the process :param str wit_ref_name: The reference name of the work item type :param str page_id: The ID of the page the group is in :param str section_id: The ID of the section t...
[ "RemoveGroup", ".", "[", "Preview", "API", "]", "Removes", "a", "group", "from", "the", "work", "item", "form", ".", ":", "param", "str", "process_id", ":", "The", "ID", "of", "the", "process", ":", "param", "str", "wit_ref_name", ":", "The", "reference"...
python
train
JukeboxPipeline/jukebox-core
src/jukeboxcore/gui/widgets/releasewin.py
https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgets/releasewin.py#L117-L130
def set_release_actions(self, actions): """Set the widget that gives users options about the release, e.g. importing references :param actions: Release actions that define the sanity checks and cleanup actions :type actions: :class:`jukeboxcore.release.ReleaseActions` :returns: None ...
[ "def", "set_release_actions", "(", "self", ",", "actions", ")", ":", "self", ".", "release_actions", "=", "actions", "self", ".", "option_widget", "=", "self", ".", "release_actions", ".", "option_widget", "(", ")", "if", "self", ".", "option_widget", ":", "...
Set the widget that gives users options about the release, e.g. importing references :param actions: Release actions that define the sanity checks and cleanup actions :type actions: :class:`jukeboxcore.release.ReleaseActions` :returns: None :rtype: None :raises: None
[ "Set", "the", "widget", "that", "gives", "users", "options", "about", "the", "release", "e", ".", "g", ".", "importing", "references" ]
python
train
Microsoft/knack
knack/cli.py
https://github.com/Microsoft/knack/blob/5f1a480a33f103e2688c46eef59fb2d9eaf2baad/knack/cli.py#L139-L150
def unregister_event(self, event_name, handler): """ Unregister a callable that will be called when event is raised. :param event_name: The name of the event (see knack.events for in-built events) :type event_name: str :param handler: The callback that was used to register the event ...
[ "def", "unregister_event", "(", "self", ",", "event_name", ",", "handler", ")", ":", "try", ":", "self", ".", "_event_handlers", "[", "event_name", "]", ".", "remove", "(", "handler", ")", "except", "ValueError", ":", "pass" ]
Unregister a callable that will be called when event is raised. :param event_name: The name of the event (see knack.events for in-built events) :type event_name: str :param handler: The callback that was used to register the event :type handler: function
[ "Unregister", "a", "callable", "that", "will", "be", "called", "when", "event", "is", "raised", "." ]
python
train
androguard/androguard
androguard/core/bytecodes/apk.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/apk.py#L710-L727
def _get_crc32(self, filename): """ Calculates and compares the CRC32 and returns the raw buffer. The CRC32 is added to `files_crc32` dictionary, if not present. :param filename: filename inside the zipfile :rtype: bytes """ buffer = self.zip.read(filename) ...
[ "def", "_get_crc32", "(", "self", ",", "filename", ")", ":", "buffer", "=", "self", ".", "zip", ".", "read", "(", "filename", ")", "if", "filename", "not", "in", "self", ".", "files_crc32", ":", "self", ".", "files_crc32", "[", "filename", "]", "=", ...
Calculates and compares the CRC32 and returns the raw buffer. The CRC32 is added to `files_crc32` dictionary, if not present. :param filename: filename inside the zipfile :rtype: bytes
[ "Calculates", "and", "compares", "the", "CRC32", "and", "returns", "the", "raw", "buffer", "." ]
python
train
jobovy/galpy
galpy/potential/Potential.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/Potential.py#L2872-L2900
def turn_physical_off(Pot): """ NAME: turn_physical_off PURPOSE: turn off automatic returning of outputs in physical units INPUT: (none) OUTPUT: (none) HISTORY: 2016-01-30 - Written - Bovy (UofT) """ if isinstance(Pot,list): for po...
[ "def", "turn_physical_off", "(", "Pot", ")", ":", "if", "isinstance", "(", "Pot", ",", "list", ")", ":", "for", "pot", "in", "Pot", ":", "turn_physical_off", "(", "pot", ")", "else", ":", "Pot", ".", "turn_physical_off", "(", ")", "return", "None" ]
NAME: turn_physical_off PURPOSE: turn off automatic returning of outputs in physical units INPUT: (none) OUTPUT: (none) HISTORY: 2016-01-30 - Written - Bovy (UofT)
[ "NAME", ":", "turn_physical_off" ]
python
train
python-diamond/Diamond
src/collectors/processresources/processresources.py
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/processresources/processresources.py#L99-L125
def process_config(self): super(ProcessResourcesCollector, self).process_config() """ prepare self.processes, which is a descriptor dictionary in pg_name: { exe: [regex], name: [regex], cmdline: [regex], selfmon: [boolean], proc...
[ "def", "process_config", "(", "self", ")", ":", "super", "(", "ProcessResourcesCollector", ",", "self", ")", ".", "process_config", "(", ")", "self", ".", "processes", "=", "{", "}", "self", ".", "processes_info", "=", "{", "}", "for", "pg_name", ",", "c...
prepare self.processes, which is a descriptor dictionary in pg_name: { exe: [regex], name: [regex], cmdline: [regex], selfmon: [boolean], procs: [psutil.Process], count_workers: [boolean] }
[ "prepare", "self", ".", "processes", "which", "is", "a", "descriptor", "dictionary", "in", "pg_name", ":", "{", "exe", ":", "[", "regex", "]", "name", ":", "[", "regex", "]", "cmdline", ":", "[", "regex", "]", "selfmon", ":", "[", "boolean", "]", "pr...
python
train
CalebBell/fluids
fluids/nrlmsise00/nrlmsise_00.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/nrlmsise00/nrlmsise_00.py#L165-L184
def ccor2(alt, r, h1, zh, h2): ''' /* CHEMISTRY/DISSOCIATION CORRECTION FOR MSIS MODELS * ALT - altitude * R - target ratio * H1 - transition scale length * ZH - altitude of 1/2 R * H2 - transition scale length #2 ? */ ''' e1 = (alt - zh) / h1; e2 = (alt...
[ "def", "ccor2", "(", "alt", ",", "r", ",", "h1", ",", "zh", ",", "h2", ")", ":", "e1", "=", "(", "alt", "-", "zh", ")", "/", "h1", "e2", "=", "(", "alt", "-", "zh", ")", "/", "h2", "if", "(", "(", "e1", ">", "70.0", ")", "or", "(", "e...
/* CHEMISTRY/DISSOCIATION CORRECTION FOR MSIS MODELS * ALT - altitude * R - target ratio * H1 - transition scale length * ZH - altitude of 1/2 R * H2 - transition scale length #2 ? */
[ "/", "*", "CHEMISTRY", "/", "DISSOCIATION", "CORRECTION", "FOR", "MSIS", "MODELS", "*", "ALT", "-", "altitude", "*", "R", "-", "target", "ratio", "*", "H1", "-", "transition", "scale", "length", "*", "ZH", "-", "altitude", "of", "1", "/", "2", "R", "...
python
train
earlye/nephele
nephele/AwsRoot.py
https://github.com/earlye/nephele/blob/a7dadc68f4124671457f09119419978c4d22013e/nephele/AwsRoot.py#L114-L124
def do_stack_resource(self, args): """Use specified stack resource. stack_resource -h for detailed help.""" parser = CommandArgumentParser() parser.add_argument('-s','--stack-name',dest='stack-name',help='name of the stack resource'); parser.add_argument('-i','--logical-id',dest='logical...
[ "def", "do_stack_resource", "(", "self", ",", "args", ")", ":", "parser", "=", "CommandArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'-s'", ",", "'--stack-name'", ",", "dest", "=", "'stack-name'", ",", "help", "=", "'name of the stack resource'...
Use specified stack resource. stack_resource -h for detailed help.
[ "Use", "specified", "stack", "resource", ".", "stack_resource", "-", "h", "for", "detailed", "help", "." ]
python
train
openstack/networking-cisco
networking_cisco/plugins/cisco/cfg_agent/device_drivers/iosxe/iosxe_routing_driver.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/cfg_agent/device_drivers/iosxe/iosxe_routing_driver.py#L530-L561
def caller_name(self, skip=2): """ Get a name of a caller in the format module.class.method `skip` specifies how many levels of stack to skip while getting caller name. skip=1 means "who calls me", skip=2 "who calls my caller" etc. An empty string is returned if skipped levels exc...
[ "def", "caller_name", "(", "self", ",", "skip", "=", "2", ")", ":", "stack", "=", "inspect", ".", "stack", "(", ")", "start", "=", "0", "+", "skip", "if", "len", "(", "stack", ")", "<", "start", "+", "1", ":", "return", "''", "parentframe", "=", ...
Get a name of a caller in the format module.class.method `skip` specifies how many levels of stack to skip while getting caller name. skip=1 means "who calls me", skip=2 "who calls my caller" etc. An empty string is returned if skipped levels exceed stack height
[ "Get", "a", "name", "of", "a", "caller", "in", "the", "format", "module", ".", "class", ".", "method" ]
python
train
tensorflow/datasets
tensorflow_datasets/text/cnn_dailymail.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/text/cnn_dailymail.py#L111-L126
def _find_files(dl_paths, publisher, url_dict): """Find files corresponding to urls.""" if publisher == 'cnn': top_dir = os.path.join(dl_paths['cnn_stories'], 'cnn', 'stories') elif publisher == 'dm': top_dir = os.path.join(dl_paths['dm_stories'], 'dailymail', 'stories') else: logging.fatal('Unsuppo...
[ "def", "_find_files", "(", "dl_paths", ",", "publisher", ",", "url_dict", ")", ":", "if", "publisher", "==", "'cnn'", ":", "top_dir", "=", "os", ".", "path", ".", "join", "(", "dl_paths", "[", "'cnn_stories'", "]", ",", "'cnn'", ",", "'stories'", ")", ...
Find files corresponding to urls.
[ "Find", "files", "corresponding", "to", "urls", "." ]
python
train
ntoll/uflash
uflash.py
https://github.com/ntoll/uflash/blob/867468d386da0aa20212b69a152ce8bfc0972366/uflash.py#L379-L452
def main(argv=None): """ Entry point for the command line tool 'uflash'. Will print help text if the optional first argument is "help". Otherwise it will ensure the optional first argument ends in ".py" (the source Python script). An optional second argument is used to reference the path to th...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "if", "not", "argv", ":", "argv", "=", "sys", ".", "argv", "[", "1", ":", "]", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "_HELP_TEXT", ")", "parser", ".", "add_argume...
Entry point for the command line tool 'uflash'. Will print help text if the optional first argument is "help". Otherwise it will ensure the optional first argument ends in ".py" (the source Python script). An optional second argument is used to reference the path to the micro:bit device. Any more ...
[ "Entry", "point", "for", "the", "command", "line", "tool", "uflash", "." ]
python
train
blockstack/blockstack-core
blockstack/blockstackd.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/blockstackd.py#L1757-L1842
def rpc_put_zonefiles( self, zonefile_datas, **con_info ): """ Replicate one or more zonefiles, given as serialized strings. Only stores zone files whose zone file hashes were announced on the blockchain (i.e. not subdomain zone files) Returns {'status': True, 'saved': [0|1]'} on success...
[ "def", "rpc_put_zonefiles", "(", "self", ",", "zonefile_datas", ",", "*", "*", "con_info", ")", ":", "conf", "=", "get_blockstack_opts", "(", ")", "if", "not", "is_atlas_enabled", "(", "conf", ")", ":", "return", "{", "'error'", ":", "'No data'", ",", "'ht...
Replicate one or more zonefiles, given as serialized strings. Only stores zone files whose zone file hashes were announced on the blockchain (i.e. not subdomain zone files) Returns {'status': True, 'saved': [0|1]'} on success ('saved' is a vector of success/failure) Returns {'error': ...} on err...
[ "Replicate", "one", "or", "more", "zonefiles", "given", "as", "serialized", "strings", ".", "Only", "stores", "zone", "files", "whose", "zone", "file", "hashes", "were", "announced", "on", "the", "blockchain", "(", "i", ".", "e", ".", "not", "subdomain", "...
python
train
Azure/azure-sdk-for-python
azure-cognitiveservices-search-imagesearch/azure/cognitiveservices/search/imagesearch/operations/images_operations.py
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-cognitiveservices-search-imagesearch/azure/cognitiveservices/search/imagesearch/operations/images_operations.py#L499-L897
def details( self, query, accept_language=None, content_type=None, user_agent=None, client_id=None, client_ip=None, location=None, crop_bottom=None, crop_left=None, crop_right=None, crop_top=None, crop_type=None, country_code=None, id=None, image_url=None, insights_token=None, modules=None, market=None, saf...
[ "def", "details", "(", "self", ",", "query", ",", "accept_language", "=", "None", ",", "content_type", "=", "None", ",", "user_agent", "=", "None", ",", "client_id", "=", "None", ",", "client_ip", "=", "None", ",", "location", "=", "None", ",", "crop_bot...
The Image Detail Search API lets you search on Bing and get back insights about an image, such as webpages that include the image. This section provides technical details about the query parameters and headers that you use to request insights of images and the JSON response objects that ...
[ "The", "Image", "Detail", "Search", "API", "lets", "you", "search", "on", "Bing", "and", "get", "back", "insights", "about", "an", "image", "such", "as", "webpages", "that", "include", "the", "image", ".", "This", "section", "provides", "technical", "details...
python
test
iotile/coretools
iotilecore/iotile/core/dev/registry.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilecore/iotile/core/dev/registry.py#L390-L408
def SetBackingStore(cls, backing): """Set the global backing type used by the ComponentRegistry from this point forward This function must be called before any operations that use the registry are initiated otherwise they will work from different registries that will likely contain different da...
[ "def", "SetBackingStore", "(", "cls", ",", "backing", ")", ":", "if", "backing", "not", "in", "[", "'json'", ",", "'sqlite'", ",", "'memory'", "]", ":", "raise", "ArgumentError", "(", "\"Unknown backing store type that is not json or sqlite\"", ",", "backing", "="...
Set the global backing type used by the ComponentRegistry from this point forward This function must be called before any operations that use the registry are initiated otherwise they will work from different registries that will likely contain different data
[ "Set", "the", "global", "backing", "type", "used", "by", "the", "ComponentRegistry", "from", "this", "point", "forward" ]
python
train
benmoran56/esper
esper.py
https://github.com/benmoran56/esper/blob/5b6cd0c51718d5dcfa0e5613f824b5251cf092ac/esper.py#L259-L274
def try_component(self, entity: int, component_type: Type): """Try to get a single component type for an Entity. This method will return the requested Component if it exists, but will pass silently if it does not. This allows a way to access optional Componen...
[ "def", "try_component", "(", "self", ",", "entity", ":", "int", ",", "component_type", ":", "Type", ")", ":", "if", "component_type", "in", "self", ".", "_entities", "[", "entity", "]", ":", "yield", "self", ".", "_entities", "[", "entity", "]", "[", "...
Try to get a single component type for an Entity. This method will return the requested Component if it exists, but will pass silently if it does not. This allows a way to access optional Components that may or may not exist. :param entity: The Entity ID to ...
[ "Try", "to", "get", "a", "single", "component", "type", "for", "an", "Entity", ".", "This", "method", "will", "return", "the", "requested", "Component", "if", "it", "exists", "but", "will", "pass", "silently", "if", "it", "does", "not", ".", "This", "all...
python
train
razor-x/scipy-data_fitting
scipy_data_fitting/data.py
https://github.com/razor-x/scipy-data_fitting/blob/c756a645da8629699b3f22244bfb7d5d4d88b179/scipy_data_fitting/data.py#L253-L294
def load_error(self): """ Loads error values from `scipy_data_fitting.Data.path` using [`numpy.genfromtxt`][1] and returns a two element tuple where each element is of a form described by cases 3 and 4 in `scipy_data_fitting.Data.error`. The columns to import are set by `scipy_d...
[ "def", "load_error", "(", "self", ")", ":", "usecols", "=", "[", "]", "for", "v", "in", "self", ".", "error_columns", ":", "if", "v", "is", "None", ":", "pass", "elif", "isinstance", "(", "v", ",", "int", ")", ":", "usecols", ".", "append", "(", ...
Loads error values from `scipy_data_fitting.Data.path` using [`numpy.genfromtxt`][1] and returns a two element tuple where each element is of a form described by cases 3 and 4 in `scipy_data_fitting.Data.error`. The columns to import are set by `scipy_data_fitting.Data.error_columns`. ...
[ "Loads", "error", "values", "from", "scipy_data_fitting", ".", "Data", ".", "path", "using", "[", "numpy", ".", "genfromtxt", "]", "[", "1", "]", "and", "returns", "a", "two", "element", "tuple", "where", "each", "element", "is", "of", "a", "form", "desc...
python
train
saltstack/salt
salt/modules/openvswitch.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/openvswitch.py#L251-L274
def bridge_to_parent(br): ''' Returns the parent bridge of a bridge. Args: br: A string - bridge name Returns: Name of the parent bridge. This is the same as the bridge name if the bridge is not a fake bridge. If the bridge does not exist, False is returned. CLI Ex...
[ "def", "bridge_to_parent", "(", "br", ")", ":", "cmd", "=", "'ovs-vsctl br-to-parent {0}'", ".", "format", "(", "br", ")", "result", "=", "__salt__", "[", "'cmd.run_all'", "]", "(", "cmd", ")", "if", "result", "[", "'retcode'", "]", "!=", "0", ":", "retu...
Returns the parent bridge of a bridge. Args: br: A string - bridge name Returns: Name of the parent bridge. This is the same as the bridge name if the bridge is not a fake bridge. If the bridge does not exist, False is returned. CLI Example: .. code-block:: bash ...
[ "Returns", "the", "parent", "bridge", "of", "a", "bridge", "." ]
python
train
angr/angr
angr/sim_procedure.py
https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/sim_procedure.py#L90-L100
def _describe_me(self): """ return a 5-tuple of strings sufficient for formatting with ``%s%s%s%s%s`` to verbosely describe the procedure """ return ( self.display_name, ' (cont: %s)' % self.run_func if self.is_continuation else '', ' (syscall)' if sel...
[ "def", "_describe_me", "(", "self", ")", ":", "return", "(", "self", ".", "display_name", ",", "' (cont: %s)'", "%", "self", ".", "run_func", "if", "self", ".", "is_continuation", "else", "''", ",", "' (syscall)'", "if", "self", ".", "is_syscall", "else", ...
return a 5-tuple of strings sufficient for formatting with ``%s%s%s%s%s`` to verbosely describe the procedure
[ "return", "a", "5", "-", "tuple", "of", "strings", "sufficient", "for", "formatting", "with", "%s%s%s%s%s", "to", "verbosely", "describe", "the", "procedure" ]
python
train
pypa/pipenv
pipenv/project.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/project.py#L462-L465
def register_proper_name(self, name): """Registers a proper name to the database.""" with self.proper_names_db_path.open("a") as f: f.write(u"{0}\n".format(name))
[ "def", "register_proper_name", "(", "self", ",", "name", ")", ":", "with", "self", ".", "proper_names_db_path", ".", "open", "(", "\"a\"", ")", "as", "f", ":", "f", ".", "write", "(", "u\"{0}\\n\"", ".", "format", "(", "name", ")", ")" ]
Registers a proper name to the database.
[ "Registers", "a", "proper", "name", "to", "the", "database", "." ]
python
train
OpenVolunteeringPlatform/django-ovp-search
ovp_search/filters.py
https://github.com/OpenVolunteeringPlatform/django-ovp-search/blob/003ceecc0a87be31fe8195f65367c52631f72b57/ovp_search/filters.py#L78-L87
def by_skills(queryset, skill_string=None): """ Filter queryset by a comma delimeted skill list """ if skill_string: operator, items = get_operator_and_items(skill_string) q_obj = SQ() for s in items: if len(s) > 0: q_obj.add(SQ(skills=s), operator) queryset = queryset.filter(q_obj) ...
[ "def", "by_skills", "(", "queryset", ",", "skill_string", "=", "None", ")", ":", "if", "skill_string", ":", "operator", ",", "items", "=", "get_operator_and_items", "(", "skill_string", ")", "q_obj", "=", "SQ", "(", ")", "for", "s", "in", "items", ":", "...
Filter queryset by a comma delimeted skill list
[ "Filter", "queryset", "by", "a", "comma", "delimeted", "skill", "list" ]
python
train
CS207-Final-Project-Group-10/cs207-FinalProject
solar_system/earth_sun.py
https://github.com/CS207-Final-Project-Group-10/cs207-FinalProject/blob/842e9c2d3ca1490cef18c086dfde81856d8d3a82/solar_system/earth_sun.py#L131-L170
def accel_ES(q: np.ndarray): """ Compute the gravitational accelerations in the earth-sun system. q in row vector of 6 elements: sun (x, y, z), earth (x, y, z) """ # Number of celestial bodies num_bodies: int = 2 # Number of dimensions in arrays; 3 spatial dimensions times the number of bod...
[ "def", "accel_ES", "(", "q", ":", "np", ".", "ndarray", ")", ":", "# Number of celestial bodies", "num_bodies", ":", "int", "=", "2", "# Number of dimensions in arrays; 3 spatial dimensions times the number of bodies", "dims", "=", "3", "*", "num_bodies", "# Body 0 is the...
Compute the gravitational accelerations in the earth-sun system. q in row vector of 6 elements: sun (x, y, z), earth (x, y, z)
[ "Compute", "the", "gravitational", "accelerations", "in", "the", "earth", "-", "sun", "system", ".", "q", "in", "row", "vector", "of", "6", "elements", ":", "sun", "(", "x", "y", "z", ")", "earth", "(", "x", "y", "z", ")" ]
python
train
hydpy-dev/hydpy
hydpy/models/lland/lland_model.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_model.py#L279-L394
def calc_nbes_inzp_v1(self): """Calculate stand precipitation and update the interception storage accordingly. Required control parameters: |NHRU| |Lnk| Required derived parameter: |KInz| Required flux sequence: |NKor| Calculated flux sequence: |NBes| Updat...
[ "def", "calc_nbes_inzp_v1", "(", "self", ")", ":", "con", "=", "self", ".", "parameters", ".", "control", ".", "fastaccess", "der", "=", "self", ".", "parameters", ".", "derived", ".", "fastaccess", "flu", "=", "self", ".", "sequences", ".", "fluxes", "....
Calculate stand precipitation and update the interception storage accordingly. Required control parameters: |NHRU| |Lnk| Required derived parameter: |KInz| Required flux sequence: |NKor| Calculated flux sequence: |NBes| Updated state sequence: |Inzp| ...
[ "Calculate", "stand", "precipitation", "and", "update", "the", "interception", "storage", "accordingly", "." ]
python
train
chrisspen/burlap
burlap/dj.py
https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/dj.py#L446-L517
def load_django_settings(self): """ Loads Django settings for the current site and sets them so Django internals can be run. """ r = self.local_renderer # Save environment variables so we can restore them later. _env = {} save_vars = ['ALLOW_CELERY', 'DJANGO_SETT...
[ "def", "load_django_settings", "(", "self", ")", ":", "r", "=", "self", ".", "local_renderer", "# Save environment variables so we can restore them later.", "_env", "=", "{", "}", "save_vars", "=", "[", "'ALLOW_CELERY'", ",", "'DJANGO_SETTINGS_MODULE'", "]", "for", "v...
Loads Django settings for the current site and sets them so Django internals can be run.
[ "Loads", "Django", "settings", "for", "the", "current", "site", "and", "sets", "them", "so", "Django", "internals", "can", "be", "run", "." ]
python
valid
gabstopper/smc-python
smc/examples/ip_lists.py
https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/examples/ip_lists.py#L113-L125
def download_as_json(name): """ Download IPList as json. This would allow for easily manipulation of the IPList, but generally recommended only for smaller lists :param str name: name of IPList :return: None """ location = list(IPList.objects.filter(name)) if location: ipli...
[ "def", "download_as_json", "(", "name", ")", ":", "location", "=", "list", "(", "IPList", ".", "objects", ".", "filter", "(", "name", ")", ")", "if", "location", ":", "iplist", "=", "location", "[", "0", "]", "return", "iplist", ".", "download", "(", ...
Download IPList as json. This would allow for easily manipulation of the IPList, but generally recommended only for smaller lists :param str name: name of IPList :return: None
[ "Download", "IPList", "as", "json", ".", "This", "would", "allow", "for", "easily", "manipulation", "of", "the", "IPList", "but", "generally", "recommended", "only", "for", "smaller", "lists" ]
python
train
GuiltyTargets/ppi-network-annotation
src/ppi_network_annotation/parsers.py
https://github.com/GuiltyTargets/ppi-network-annotation/blob/4d7b6713485f2d0a0957e6457edc1b1b5a237460/src/ppi_network_annotation/parsers.py#L172-L189
def parse_disease_associations(path: str, excluded_disease_ids: set): """Parse the disease-drug target associations file. :param str path: Path to the disease-drug target associations file. :param list excluded_disease_ids: Identifiers of the disease for which drug targets are being predicted. :return:...
[ "def", "parse_disease_associations", "(", "path", ":", "str", ",", "excluded_disease_ids", ":", "set", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", "or", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "logger", ...
Parse the disease-drug target associations file. :param str path: Path to the disease-drug target associations file. :param list excluded_disease_ids: Identifiers of the disease for which drug targets are being predicted. :return: Dictionary of drug target-disease mappings.
[ "Parse", "the", "disease", "-", "drug", "target", "associations", "file", "." ]
python
train
libtcod/python-tcod
tcod/libtcodpy.py
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/libtcodpy.py#L1973-L1985
def path_new_using_map( m: tcod.map.Map, dcost: float = 1.41 ) -> tcod.path.AStar: """Return a new AStar using the given Map. Args: m (Map): A Map instance. dcost (float): The path-finding cost of diagonal movement. Can be set to 0 to disable diagonal movement. Re...
[ "def", "path_new_using_map", "(", "m", ":", "tcod", ".", "map", ".", "Map", ",", "dcost", ":", "float", "=", "1.41", ")", "->", "tcod", ".", "path", ".", "AStar", ":", "return", "tcod", ".", "path", ".", "AStar", "(", "m", ",", "dcost", ")" ]
Return a new AStar using the given Map. Args: m (Map): A Map instance. dcost (float): The path-finding cost of diagonal movement. Can be set to 0 to disable diagonal movement. Returns: AStar: A new AStar instance.
[ "Return", "a", "new", "AStar", "using", "the", "given", "Map", "." ]
python
train
google/grr
grr/client/grr_response_client/client_actions/cloud.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_actions/cloud.py#L34-L42
def IsCloud(self, request, bios_version, services): """Test to see if we're on a cloud machine.""" if request.bios_version_regex and bios_version: if re.match(request.bios_version_regex, bios_version): return True if request.service_name_regex and services: if re.search(request.service_n...
[ "def", "IsCloud", "(", "self", ",", "request", ",", "bios_version", ",", "services", ")", ":", "if", "request", ".", "bios_version_regex", "and", "bios_version", ":", "if", "re", ".", "match", "(", "request", ".", "bios_version_regex", ",", "bios_version", "...
Test to see if we're on a cloud machine.
[ "Test", "to", "see", "if", "we", "re", "on", "a", "cloud", "machine", "." ]
python
train
cole/aiosmtplib
src/aiosmtplib/email.py
https://github.com/cole/aiosmtplib/blob/0cd00e5059005371cbdfca995feff9183a16a51f/src/aiosmtplib/email.py#L84-L105
def _extract_recipients( message: Message, resent_dates: List[Union[str, Header]] = None ) -> List[str]: """ Extract the recipients from the message object given. """ recipients = [] # type: List[str] if resent_dates: recipient_headers = ("Resent-To", "Resent-Cc", "Resent-Bcc") els...
[ "def", "_extract_recipients", "(", "message", ":", "Message", ",", "resent_dates", ":", "List", "[", "Union", "[", "str", ",", "Header", "]", "]", "=", "None", ")", "->", "List", "[", "str", "]", ":", "recipients", "=", "[", "]", "# type: List[str]", "...
Extract the recipients from the message object given.
[ "Extract", "the", "recipients", "from", "the", "message", "object", "given", "." ]
python
train
insomnia-lab/libreant
archivant/archivant.py
https://github.com/insomnia-lab/libreant/blob/55d529435baf4c05a86b8341899e9f5e14e50245/archivant/archivant.py#L340-L349
def update_volume(self, volumeID, metadata): '''update existing volume metadata the given metadata will substitute the old one ''' log.debug('updating volume metadata: {}'.format(volumeID)) rawVolume = self._req_raw_volume(volumeID) normalized = self.normalize_volume(r...
[ "def", "update_volume", "(", "self", ",", "volumeID", ",", "metadata", ")", ":", "log", ".", "debug", "(", "'updating volume metadata: {}'", ".", "format", "(", "volumeID", ")", ")", "rawVolume", "=", "self", ".", "_req_raw_volume", "(", "volumeID", ")", "no...
update existing volume metadata the given metadata will substitute the old one
[ "update", "existing", "volume", "metadata", "the", "given", "metadata", "will", "substitute", "the", "old", "one" ]
python
train
tobami/littlechef
littlechef/lib.py
https://github.com/tobami/littlechef/blob/aab8c94081b38100a69cc100bc4278ae7419c58e/littlechef/lib.py#L174-L191
def get_nodes_with_recipe(recipe_name, environment=None): """Get all nodes which include a given recipe, prefix-searches are also supported """ prefix_search = recipe_name.endswith("*") if prefix_search: recipe_name = recipe_name.rstrip("*") for n in get_nodes(environment): reci...
[ "def", "get_nodes_with_recipe", "(", "recipe_name", ",", "environment", "=", "None", ")", ":", "prefix_search", "=", "recipe_name", ".", "endswith", "(", "\"*\"", ")", "if", "prefix_search", ":", "recipe_name", "=", "recipe_name", ".", "rstrip", "(", "\"*\"", ...
Get all nodes which include a given recipe, prefix-searches are also supported
[ "Get", "all", "nodes", "which", "include", "a", "given", "recipe", "prefix", "-", "searches", "are", "also", "supported" ]
python
train
robertpeteuil/aws-shortcuts
awss/core.py
https://github.com/robertpeteuil/aws-shortcuts/blob/cf453ca996978a4d88015d1cf6125bce8ca4873b/awss/core.py#L376-L400
def qry_helper(flag_id, qry_string, param_str, flag_filt=False, filt_st=""): """Dynamically add syntaxtical elements to query. This functions adds syntactical elements to the query string, and report title, based on the types and number of items added thus far. Args: flag_filt (bool): at least...
[ "def", "qry_helper", "(", "flag_id", ",", "qry_string", ",", "param_str", ",", "flag_filt", "=", "False", ",", "filt_st", "=", "\"\"", ")", ":", "if", "flag_id", "or", "flag_filt", ":", "qry_string", "+=", "\", \"", "param_str", "+=", "\", \"", "if", "not"...
Dynamically add syntaxtical elements to query. This functions adds syntactical elements to the query string, and report title, based on the types and number of items added thus far. Args: flag_filt (bool): at least one filter item specified. qry_string (str): portion of the query construct...
[ "Dynamically", "add", "syntaxtical", "elements", "to", "query", "." ]
python
train
log2timeline/plaso
plaso/engine/path_helper.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/engine/path_helper.py#L238-L286
def ExpandWindowsPath(cls, path, environment_variables): """Expands a Windows path containing environment variables. Args: path (str): Windows path with environment variables. environment_variables (list[EnvironmentVariableArtifact]): environment variables. Returns: str: expand...
[ "def", "ExpandWindowsPath", "(", "cls", ",", "path", ",", "environment_variables", ")", ":", "if", "environment_variables", "is", "None", ":", "environment_variables", "=", "[", "]", "lookup_table", "=", "{", "}", "if", "environment_variables", ":", "for", "envi...
Expands a Windows path containing environment variables. Args: path (str): Windows path with environment variables. environment_variables (list[EnvironmentVariableArtifact]): environment variables. Returns: str: expanded Windows path.
[ "Expands", "a", "Windows", "path", "containing", "environment", "variables", "." ]
python
train
OCHA-DAP/hdx-python-api
src/hdx/data/dataset.py
https://github.com/OCHA-DAP/hdx-python-api/blob/212440f54f73805826a16db77dbcb6033b18a313/src/hdx/data/dataset.py#L1123-L1137
def add_region_location(self, region, locations=None, use_live=True): # type: (str, Optional[List[str]], bool) -> bool """Add all countries in a region. If a 3 digit UNStats M49 region code is not provided, value is parsed as a region name. If any country is already added, it is ignored. ...
[ "def", "add_region_location", "(", "self", ",", "region", ",", "locations", "=", "None", ",", "use_live", "=", "True", ")", ":", "# type: (str, Optional[List[str]], bool) -> bool", "return", "self", ".", "add_country_locations", "(", "Country", ".", "get_countries_in_...
Add all countries in a region. If a 3 digit UNStats M49 region code is not provided, value is parsed as a region name. If any country is already added, it is ignored. Args: region (str): M49 region, intermediate region or subregion to add locations (Optional[List[str]]): Valid l...
[ "Add", "all", "countries", "in", "a", "region", ".", "If", "a", "3", "digit", "UNStats", "M49", "region", "code", "is", "not", "provided", "value", "is", "parsed", "as", "a", "region", "name", ".", "If", "any", "country", "is", "already", "added", "it"...
python
train
tensorflow/tensor2tensor
tensor2tensor/models/research/transformer_moe.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/transformer_moe.py#L315-L327
def transformer_moe_8k(): """Hyper parameters specifics for long sequence generation.""" hparams = transformer_moe_base() hparams.batch_size = 8192 hparams.max_length = 0 # max_length == batch_size hparams.eval_drop_long_sequences = True hparams.min_length_bucket = 256 # Avoid cyclic problems for big bat...
[ "def", "transformer_moe_8k", "(", ")", ":", "hparams", "=", "transformer_moe_base", "(", ")", "hparams", ".", "batch_size", "=", "8192", "hparams", ".", "max_length", "=", "0", "# max_length == batch_size", "hparams", ".", "eval_drop_long_sequences", "=", "True", ...
Hyper parameters specifics for long sequence generation.
[ "Hyper", "parameters", "specifics", "for", "long", "sequence", "generation", "." ]
python
train
pyQode/pyqode.core
pyqode/core/widgets/interactive.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/interactive.py#L98-L113
def set_writer(self, writer): """ Changes the writer function to handle writing to the text edit. A writer function must have the following prototype: .. code-block:: python def write(text_edit, text, color) :param writer: write function as described above. ...
[ "def", "set_writer", "(", "self", ",", "writer", ")", ":", "if", "self", ".", "_writer", "!=", "writer", "and", "self", ".", "_writer", ":", "self", ".", "_writer", "=", "None", "if", "writer", ":", "self", ".", "_writer", "=", "writer" ]
Changes the writer function to handle writing to the text edit. A writer function must have the following prototype: .. code-block:: python def write(text_edit, text, color) :param writer: write function as described above.
[ "Changes", "the", "writer", "function", "to", "handle", "writing", "to", "the", "text", "edit", "." ]
python
train
RIPE-NCC/ripe-atlas-cousteau
ripe/atlas/cousteau/stream.py
https://github.com/RIPE-NCC/ripe-atlas-cousteau/blob/ffee2556aaa4df86525b88c269bb098de11678ec/ripe/atlas/cousteau/stream.py#L158-L165
def subscribe(self, stream_type, **parameters): """Subscribe to stream with give parameters.""" parameters["stream_type"] = stream_type if (stream_type == "result") and ("buffering" not in parameters): parameters["buffering"] = True self.socketIO.emit(self.EVENT_NAME_SUBSCR...
[ "def", "subscribe", "(", "self", ",", "stream_type", ",", "*", "*", "parameters", ")", ":", "parameters", "[", "\"stream_type\"", "]", "=", "stream_type", "if", "(", "stream_type", "==", "\"result\"", ")", "and", "(", "\"buffering\"", "not", "in", "parameter...
Subscribe to stream with give parameters.
[ "Subscribe", "to", "stream", "with", "give", "parameters", "." ]
python
train
fjwCode/cerium
cerium/utils.py
https://github.com/fjwCode/cerium/blob/f6e06e0dcf83a0bc924828e9d6cb81383ed2364f/cerium/utils.py#L34-L53
def is_connectable(host: str, port: Union[int, str]) -> bool: """Tries to connect to the device to see if it is connectable. Args: host: The host to connect. port: The port to connect. Returns: True or False. """ socket_ = None try: socket_ = socket.create_conne...
[ "def", "is_connectable", "(", "host", ":", "str", ",", "port", ":", "Union", "[", "int", ",", "str", "]", ")", "->", "bool", ":", "socket_", "=", "None", "try", ":", "socket_", "=", "socket", ".", "create_connection", "(", "(", "host", ",", "port", ...
Tries to connect to the device to see if it is connectable. Args: host: The host to connect. port: The port to connect. Returns: True or False.
[ "Tries", "to", "connect", "to", "the", "device", "to", "see", "if", "it", "is", "connectable", "." ]
python
train
ShenggaoZhu/midict
midict/__init__.py
https://github.com/ShenggaoZhu/midict/blob/2fad2edcfb753035b443a70fe15852affae1b5bb/midict/__init__.py#L1412-L1444
def update(self, *args, **kw): ''' Update the dictionary with items and names:: (items, names, **kw) (dict, names, **kw) (MIDict, names, **kw) Optional positional argument ``names`` is only allowed when ``self.indices`` is empty (no indices are set y...
[ "def", "update", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "if", "len", "(", "args", ")", ">", "1", "and", "self", ".", "indices", ":", "raise", "ValueError", "(", "'Only one positional argument is allowed when the'", "'index names are al...
Update the dictionary with items and names:: (items, names, **kw) (dict, names, **kw) (MIDict, names, **kw) Optional positional argument ``names`` is only allowed when ``self.indices`` is empty (no indices are set yet).
[ "Update", "the", "dictionary", "with", "items", "and", "names", "::" ]
python
train
neuropsychology/NeuroKit.py
examples/UnderDev/eeg/eeg_time_frequency.py
https://github.com/neuropsychology/NeuroKit.py/blob/c9589348fbbde0fa7e986048c48f38e6b488adfe/examples/UnderDev/eeg/eeg_time_frequency.py#L20-L87
def eeg_name_frequencies(freqs): """ Name frequencies according to standart classifications. Parameters ---------- freqs : list or numpy.array list of floats containing frequencies to classify. Returns ---------- freqs_names : list Named frequencies Example ---...
[ "def", "eeg_name_frequencies", "(", "freqs", ")", ":", "freqs", "=", "list", "(", "freqs", ")", "freqs_names", "=", "[", "]", "for", "freq", "in", "freqs", ":", "if", "freq", "<", "1", ":", "freqs_names", ".", "append", "(", "\"UltraLow\"", ")", "elif"...
Name frequencies according to standart classifications. Parameters ---------- freqs : list or numpy.array list of floats containing frequencies to classify. Returns ---------- freqs_names : list Named frequencies Example ---------- >>> import neurokit as nk >>>...
[ "Name", "frequencies", "according", "to", "standart", "classifications", "." ]
python
train
jjgomera/iapws
iapws/iapws97.py
https://github.com/jjgomera/iapws/blob/1e5812aab38212fb8a63736f61cdcfa427d223b1/iapws/iapws97.py#L2220-L2270
def _Backward3a_T_Ph(P, h): """Backward equation for region 3a, T=f(P,h) Parameters ---------- P : float Pressure, [MPa] h : float Specific enthalpy, [kJ/kg] Returns ------- T : float Temperature, [K] References ---------- IAPWS, Revised Supplementa...
[ "def", "_Backward3a_T_Ph", "(", "P", ",", "h", ")", ":", "I", "=", "[", "-", "12", ",", "-", "12", ",", "-", "12", ",", "-", "12", ",", "-", "12", ",", "-", "12", ",", "-", "12", ",", "-", "12", ",", "-", "10", ",", "-", "10", ",", "-...
Backward equation for region 3a, T=f(P,h) Parameters ---------- P : float Pressure, [MPa] h : float Specific enthalpy, [kJ/kg] Returns ------- T : float Temperature, [K] References ---------- IAPWS, Revised Supplementary Release on Backward Equations fo...
[ "Backward", "equation", "for", "region", "3a", "T", "=", "f", "(", "P", "h", ")" ]
python
train
bitshares/uptick
uptick/api.py
https://github.com/bitshares/uptick/blob/66c102200fdbf96cef4fd55cc69d00e690f62001/uptick/api.py#L28-L37
def create(ctx): """ Create default config file """ import shutil this_dir, this_filename = os.path.split(__file__) default_config_file = os.path.join(this_dir, "apis/example-config.yaml") config_file = ctx.obj["configfile"] shutil.copyfile(default_config_file, config_file) print_messag...
[ "def", "create", "(", "ctx", ")", ":", "import", "shutil", "this_dir", ",", "this_filename", "=", "os", ".", "path", ".", "split", "(", "__file__", ")", "default_config_file", "=", "os", ".", "path", ".", "join", "(", "this_dir", ",", "\"apis/example-confi...
Create default config file
[ "Create", "default", "config", "file" ]
python
train
PythonCharmers/python-future
src/future/types/newstr.py
https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/future/types/newstr.py#L179-L218
def encode(self, encoding='utf-8', errors='strict'): """ Returns bytes Encode S using the codec registered for encoding. Default encoding is 'utf-8'. errors may be given to set a different error handling scheme. Default is 'strict' meaning that encoding errors raise a Un...
[ "def", "encode", "(", "self", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "from", "future", ".", "types", ".", "newbytes", "import", "newbytes", "# Py2 unicode.encode() takes encoding and errors as optional parameter,", "# not keyword argu...
Returns bytes Encode S using the codec registered for encoding. Default encoding is 'utf-8'. errors may be given to set a different error handling scheme. Default is 'strict' meaning that encoding errors raise a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and ...
[ "Returns", "bytes" ]
python
train
cltk/cltk
cltk/phonology/syllabify.py
https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/phonology/syllabify.py#L23-L72
def get_onsets(text, vowels="aeiou", threshold=0.0002): """ Source: Resonances in Middle High German: New Methodologies in Prosody, 2017, C. L. Hench :param text: str list: text to be analysed :param vowels: str: valid vowels constituting the syllable :param threshold: minimum frequency count...
[ "def", "get_onsets", "(", "text", ",", "vowels", "=", "\"aeiou\"", ",", "threshold", "=", "0.0002", ")", ":", "onset_dict", "=", "defaultdict", "(", "lambda", ":", "0", ")", "n", "=", "len", "(", "text", ")", "for", "word", "in", "text", ":", "onset"...
Source: Resonances in Middle High German: New Methodologies in Prosody, 2017, C. L. Hench :param text: str list: text to be analysed :param vowels: str: valid vowels constituting the syllable :param threshold: minimum frequency count for valid onset, C. Hench noted that the algorithm produces the...
[ "Source", ":", "Resonances", "in", "Middle", "High", "German", ":", "New", "Methodologies", "in", "Prosody", "2017", "C", ".", "L", ".", "Hench" ]
python
train
tensorforce/tensorforce
tensorforce/models/model.py
https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L1481-L1498
def observe(self, terminal, reward, index=0): """ Adds an observation (reward and is-terminal) to the model without updating its trainable variables. Args: terminal (List[bool]): List of is-terminal signals. reward (List[float]): List of reward signals. index...
[ "def", "observe", "(", "self", ",", "terminal", ",", "reward", ",", "index", "=", "0", ")", ":", "fetches", "=", "self", ".", "episode_output", "feed_dict", "=", "self", ".", "get_feed_dict", "(", "terminal", "=", "terminal", ",", "reward", "=", "reward"...
Adds an observation (reward and is-terminal) to the model without updating its trainable variables. Args: terminal (List[bool]): List of is-terminal signals. reward (List[float]): List of reward signals. index: (int) parallel episode you want to observe Returns: ...
[ "Adds", "an", "observation", "(", "reward", "and", "is", "-", "terminal", ")", "to", "the", "model", "without", "updating", "its", "trainable", "variables", "." ]
python
valid
redhat-cip/python-dciclient
dciclient/v1/api/file.py
https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/api/file.py#L26-L65
def create(context, name, content=None, file_path=None, mime='text/plain', jobstate_id=None, md5=None, job_id=None, test_id=None): """Method to create a file on the Control-Server This method allows one to upload a file to the Control-Server. The file to be uploaded can be specified in two diffe...
[ "def", "create", "(", "context", ",", "name", ",", "content", "=", "None", ",", "file_path", "=", "None", ",", "mime", "=", "'text/plain'", ",", "jobstate_id", "=", "None", ",", "md5", "=", "None", ",", "job_id", "=", "None", ",", "test_id", "=", "No...
Method to create a file on the Control-Server This method allows one to upload a file to the Control-Server. The file to be uploaded can be specified in two different ways either by specifying its content directly or or by specifying the file_path where the file is located. content can be in the f...
[ "Method", "to", "create", "a", "file", "on", "the", "Control", "-", "Server" ]
python
train
pypa/pipenv
pipenv/patched/notpip/_vendor/html5lib/_inputstream.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/patched/notpip/_vendor/html5lib/_inputstream.py#L438-L455
def openStream(self, source): """Produces a file object from source. source can be either a file object, local filename or a string. """ # Already a file object if hasattr(source, 'read'): stream = source else: stream = BytesIO(source) t...
[ "def", "openStream", "(", "self", ",", "source", ")", ":", "# Already a file object", "if", "hasattr", "(", "source", ",", "'read'", ")", ":", "stream", "=", "source", "else", ":", "stream", "=", "BytesIO", "(", "source", ")", "try", ":", "stream", ".", ...
Produces a file object from source. source can be either a file object, local filename or a string.
[ "Produces", "a", "file", "object", "from", "source", "." ]
python
train
django-treebeard/django-treebeard
treebeard/templatetags/admin_tree.py
https://github.com/django-treebeard/django-treebeard/blob/8042ee939cb45394909237da447f8925e3cc6aa3/treebeard/templatetags/admin_tree.py#L219-L231
def check_empty_dict(GET_dict): """ Returns True if the GET querstring contains on values, but it can contain empty keys. This is better than doing not bool(request.GET) as an empty key will return True """ empty = True for k, v in GET_dict.items(): # Don't disable on p(age) or '...
[ "def", "check_empty_dict", "(", "GET_dict", ")", ":", "empty", "=", "True", "for", "k", ",", "v", "in", "GET_dict", ".", "items", "(", ")", ":", "# Don't disable on p(age) or 'all' GET param", "if", "v", "and", "k", "!=", "'p'", "and", "k", "!=", "'all'", ...
Returns True if the GET querstring contains on values, but it can contain empty keys. This is better than doing not bool(request.GET) as an empty key will return True
[ "Returns", "True", "if", "the", "GET", "querstring", "contains", "on", "values", "but", "it", "can", "contain", "empty", "keys", ".", "This", "is", "better", "than", "doing", "not", "bool", "(", "request", ".", "GET", ")", "as", "an", "empty", "key", "...
python
train
google/dotty
efilter/parsers/common/ast_transforms.py
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/common/ast_transforms.py#L43-L46
def ComplementEquivalence(*args, **kwargs): """Change x != y to not(x == y).""" return ast.Complement( ast.Equivalence(*args, **kwargs), **kwargs)
[ "def", "ComplementEquivalence", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "ast", ".", "Complement", "(", "ast", ".", "Equivalence", "(", "*", "args", ",", "*", "*", "kwargs", ")", ",", "*", "*", "kwargs", ")" ]
Change x != y to not(x == y).
[ "Change", "x", "!", "=", "y", "to", "not", "(", "x", "==", "y", ")", "." ]
python
train
rameshg87/pyremotevbox
pyremotevbox/ZSI/TC.py
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TC.py#L203-L229
def checktype(self, elt, ps): '''See if the type of the "elt" element is what we're looking for. Return the element's type. Parameters: elt -- the DOM element being parsed ps -- the ParsedSoap object. ''' typeName = _find_type(elt) if typeName is N...
[ "def", "checktype", "(", "self", ",", "elt", ",", "ps", ")", ":", "typeName", "=", "_find_type", "(", "elt", ")", "if", "typeName", "is", "None", "or", "typeName", "==", "\"\"", ":", "return", "(", "None", ",", "None", ")", "# Parse the QNAME.", "prefi...
See if the type of the "elt" element is what we're looking for. Return the element's type. Parameters: elt -- the DOM element being parsed ps -- the ParsedSoap object.
[ "See", "if", "the", "type", "of", "the", "elt", "element", "is", "what", "we", "re", "looking", "for", ".", "Return", "the", "element", "s", "type", ".", "Parameters", ":", "elt", "--", "the", "DOM", "element", "being", "parsed", "ps", "--", "the", "...
python
train
saltstack/salt
salt/modules/portage_config.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/portage_config.py#L326-L437
def append_to_package_conf(conf, atom='', flags=None, string='', overwrite=False): ''' Append a string or a list of flags for a given package or DEPEND atom to a given configuration file. CLI Example: .. code-block:: bash salt '*' portage_config.append_to_package_conf use string="app-admi...
[ "def", "append_to_package_conf", "(", "conf", ",", "atom", "=", "''", ",", "flags", "=", "None", ",", "string", "=", "''", ",", "overwrite", "=", "False", ")", ":", "if", "flags", "is", "None", ":", "flags", "=", "[", "]", "if", "conf", "in", "SUPP...
Append a string or a list of flags for a given package or DEPEND atom to a given configuration file. CLI Example: .. code-block:: bash salt '*' portage_config.append_to_package_conf use string="app-admin/salt ldap -libvirt" salt '*' portage_config.append_to_package_conf use atom="> = app-...
[ "Append", "a", "string", "or", "a", "list", "of", "flags", "for", "a", "given", "package", "or", "DEPEND", "atom", "to", "a", "given", "configuration", "file", "." ]
python
train
numenta/nupic
src/nupic/swarming/hypersearch/extended_logger.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/swarming/hypersearch/extended_logger.py#L111-L121
def log(self, level, msg, *args, **kwargs): """ Log 'msg % args' with the integer severity 'level'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.log(level, "We have a %s", "mysterious problem", exc_info=1) """ self._baseLogge...
[ "def", "log", "(", "self", ",", "level", ",", "msg", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_baseLogger", ".", "log", "(", "self", ",", "level", ",", "self", ".", "getExtendedMsg", "(", "msg", ")", ",", "*", "args", ...
Log 'msg % args' with the integer severity 'level'. To pass exception information, use the keyword argument exc_info with a true value, e.g. logger.log(level, "We have a %s", "mysterious problem", exc_info=1)
[ "Log", "msg", "%", "args", "with", "the", "integer", "severity", "level", "." ]
python
valid
TheHive-Project/Cortex-Analyzers
analyzers/MaxMind/ipaddr.py
https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/MaxMind/ipaddr.py#L41-L78
def IPAddress(address, version=None): """Take an IP string/int and return an object of the correct type. Args: address: A string or integer, the IP address. Either IPv4 or IPv6 addresses may be supplied; integers less than 2**32 will be considered to be IPv4 by default. ver...
[ "def", "IPAddress", "(", "address", ",", "version", "=", "None", ")", ":", "if", "version", ":", "if", "version", "==", "4", ":", "return", "IPv4Address", "(", "address", ")", "elif", "version", "==", "6", ":", "return", "IPv6Address", "(", "address", ...
Take an IP string/int and return an object of the correct type. Args: address: A string or integer, the IP address. Either IPv4 or IPv6 addresses may be supplied; integers less than 2**32 will be considered to be IPv4 by default. version: An Integer, 4 or 6. If set, don't try t...
[ "Take", "an", "IP", "string", "/", "int", "and", "return", "an", "object", "of", "the", "correct", "type", "." ]
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#L1885-L1909
def get_build_work_items_refs_from_commits(self, commit_ids, project, build_id, top=None): """GetBuildWorkItemsRefsFromCommits. Gets the work items associated with a build, filtered to specific commits. :param [str] commit_ids: A comma-delimited list of commit IDs. :param str project: Pr...
[ "def", "get_build_work_items_refs_from_commits", "(", "self", ",", "commit_ids", ",", "project", ",", "build_id", ",", "top", "=", "None", ")", ":", "route_values", "=", "{", "}", "if", "project", "is", "not", "None", ":", "route_values", "[", "'project'", "...
GetBuildWorkItemsRefsFromCommits. Gets the work items associated with a build, filtered to specific commits. :param [str] commit_ids: A comma-delimited list of commit IDs. :param str project: Project ID or project name :param int build_id: The ID of the build. :param int top: The...
[ "GetBuildWorkItemsRefsFromCommits", ".", "Gets", "the", "work", "items", "associated", "with", "a", "build", "filtered", "to", "specific", "commits", ".", ":", "param", "[", "str", "]", "commit_ids", ":", "A", "comma", "-", "delimited", "list", "of", "commit",...
python
train
tensorflow/cleverhans
cleverhans/utils.py
https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/utils.py#L247-L262
def create_logger(name): """ Create a logger object with the given name. If this is the first time that we call this method, then initialize the formatter. """ base = logging.getLogger("cleverhans") if len(base.handlers) == 0: ch = logging.StreamHandler() formatter = logging.Formatter('[%(levelna...
[ "def", "create_logger", "(", "name", ")", ":", "base", "=", "logging", ".", "getLogger", "(", "\"cleverhans\"", ")", "if", "len", "(", "base", ".", "handlers", ")", "==", "0", ":", "ch", "=", "logging", ".", "StreamHandler", "(", ")", "formatter", "=",...
Create a logger object with the given name. If this is the first time that we call this method, then initialize the formatter.
[ "Create", "a", "logger", "object", "with", "the", "given", "name", "." ]
python
train
MillionIntegrals/vel
vel/rl/models/q_stochastic_policy_model.py
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/models/q_stochastic_policy_model.py#L74-L87
def step(self, observation, argmax_sampling=False): """ Select actions based on model's output """ policy_params, q = self(observation) actions = self.action_head.sample(policy_params, argmax_sampling=argmax_sampling) # log probability - we can do that, because we support only discrete ...
[ "def", "step", "(", "self", ",", "observation", ",", "argmax_sampling", "=", "False", ")", ":", "policy_params", ",", "q", "=", "self", "(", "observation", ")", "actions", "=", "self", ".", "action_head", ".", "sample", "(", "policy_params", ",", "argmax_s...
Select actions based on model's output
[ "Select", "actions", "based", "on", "model", "s", "output" ]
python
train