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
kobejohn/PQHelper
pqhelper/base.py
https://github.com/kobejohn/PQHelper/blob/d2b78a22dcb631794295e6a159b06f39c3f10db6/pqhelper/base.py#L440-L492
def _simulated_chain_result(self, potential_chain, already_used_bonus): """Simulate any chain reactions. Arguments: potential_chain: a state to be tested for chain reactions already_used_bonus: boolean indicating whether a bonus turn was already applied during this action ...
[ "def", "_simulated_chain_result", "(", "self", ",", "potential_chain", ",", "already_used_bonus", ")", ":", "while", "potential_chain", ":", "# hook for capture game optimizations. no effect in base", "# warning: only do this ONCE for any given state or it will", "# always filter the s...
Simulate any chain reactions. Arguments: potential_chain: a state to be tested for chain reactions already_used_bonus: boolean indicating whether a bonus turn was already applied during this action Return: final result state or None (if state is filtered out in capture) ...
[ "Simulate", "any", "chain", "reactions", "." ]
python
train
abseil/abseil-py
absl/flags/_argument_parser.py
https://github.com/abseil/abseil-py/blob/9d73fdaa23a6b6726aa5731390f388c0c6250ee5/absl/flags/_argument_parser.py#L474-L481
def parse(self, argument): """See base class.""" if isinstance(argument, list): return argument elif not argument: return [] else: return [s.strip() for s in argument.split(self._token)]
[ "def", "parse", "(", "self", ",", "argument", ")", ":", "if", "isinstance", "(", "argument", ",", "list", ")", ":", "return", "argument", "elif", "not", "argument", ":", "return", "[", "]", "else", ":", "return", "[", "s", ".", "strip", "(", ")", "...
See base class.
[ "See", "base", "class", "." ]
python
train
adrn/gala
gala/dynamics/orbit.py
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/orbit.py#L422-L484
def pericenter(self, return_times=False, func=np.mean, interp_kwargs=None, minimize_kwargs=None, approximate=False): """ Estimate the pericenter(s) of the orbit by identifying local minima in the spherical radius and interpolating between timesteps near the ...
[ "def", "pericenter", "(", "self", ",", "return_times", "=", "False", ",", "func", "=", "np", ".", "mean", ",", "interp_kwargs", "=", "None", ",", "minimize_kwargs", "=", "None", ",", "approximate", "=", "False", ")", ":", "if", "return_times", "and", "fu...
Estimate the pericenter(s) of the orbit by identifying local minima in the spherical radius and interpolating between timesteps near the minima. By default, this returns the mean of all local minima (pericenters). To get, e.g., the minimum pericenter, pass in ``func=np.min``. To get ...
[ "Estimate", "the", "pericenter", "(", "s", ")", "of", "the", "orbit", "by", "identifying", "local", "minima", "in", "the", "spherical", "radius", "and", "interpolating", "between", "timesteps", "near", "the", "minima", "." ]
python
train
oauthlib/oauthlib
oauthlib/oauth1/rfc5849/__init__.py
https://github.com/oauthlib/oauthlib/blob/30321dd3c0ca784d3508a1970cf90d9f76835c79/oauthlib/oauth1/rfc5849/__init__.py#L153-L186
def get_oauth_params(self, request): """Get the basic OAuth parameters to be used in generating a signature. """ nonce = (generate_nonce() if self.nonce is None else self.nonce) timestamp = (generate_timestamp() if self.timestamp is None else self.ti...
[ "def", "get_oauth_params", "(", "self", ",", "request", ")", ":", "nonce", "=", "(", "generate_nonce", "(", ")", "if", "self", ".", "nonce", "is", "None", "else", "self", ".", "nonce", ")", "timestamp", "=", "(", "generate_timestamp", "(", ")", "if", "...
Get the basic OAuth parameters to be used in generating a signature.
[ "Get", "the", "basic", "OAuth", "parameters", "to", "be", "used", "in", "generating", "a", "signature", "." ]
python
train
nicolargo/glances
glances/config.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L33-L51
def user_config_dir(): r"""Return the per-user config dir (full path). - Linux, *BSD, SunOS: ~/.config/glances - macOS: ~/Library/Application Support/glances - Windows: %APPDATA%\glances """ if WINDOWS: path = os.environ.get('APPDATA') elif MACOS: path = os.path.expanduser('...
[ "def", "user_config_dir", "(", ")", ":", "if", "WINDOWS", ":", "path", "=", "os", ".", "environ", ".", "get", "(", "'APPDATA'", ")", "elif", "MACOS", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "'~/Library/Application Support'", ")", "el...
r"""Return the per-user config dir (full path). - Linux, *BSD, SunOS: ~/.config/glances - macOS: ~/Library/Application Support/glances - Windows: %APPDATA%\glances
[ "r", "Return", "the", "per", "-", "user", "config", "dir", "(", "full", "path", ")", "." ]
python
train
frascoweb/frasco
frasco/actions/common.py
https://github.com/frascoweb/frasco/blob/ea519d69dd5ca6deaf3650175692ee4a1a02518f/frasco/actions/common.py#L150-L157
def redirect(view=None, url=None, **kwargs): """Redirects to the specified view or url """ if view: if url: kwargs["url"] = url url = flask.url_for(view, **kwargs) current_context.exit(flask.redirect(url))
[ "def", "redirect", "(", "view", "=", "None", ",", "url", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "view", ":", "if", "url", ":", "kwargs", "[", "\"url\"", "]", "=", "url", "url", "=", "flask", ".", "url_for", "(", "view", ",", "*",...
Redirects to the specified view or url
[ "Redirects", "to", "the", "specified", "view", "or", "url" ]
python
train
python-visualization/branca
branca/utilities.py
https://github.com/python-visualization/branca/blob/4e89e88a5a7ff3586f0852249c2c125f72316da8/branca/utilities.py#L218-L256
def image_to_url(image, colormap=None, origin='upper'): """Infers the type of an image argument and transforms it into a URL. Parameters ---------- image: string, file or array-like object * If string, it will be written directly in the output file. * If file, it's content will be conve...
[ "def", "image_to_url", "(", "image", ",", "colormap", "=", "None", ",", "origin", "=", "'upper'", ")", ":", "if", "hasattr", "(", "image", ",", "'read'", ")", ":", "# We got an image file.", "if", "hasattr", "(", "image", ",", "'name'", ")", ":", "# We t...
Infers the type of an image argument and transforms it into a URL. Parameters ---------- image: string, file or array-like object * If string, it will be written directly in the output file. * If file, it's content will be converted as embedded in the output file. * If arr...
[ "Infers", "the", "type", "of", "an", "image", "argument", "and", "transforms", "it", "into", "a", "URL", "." ]
python
train
Telefonica/toolium
toolium/pageelements/page_elements.py
https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/pageelements/page_elements.py#L68-L78
def reset_object(self, driver_wrapper=None): """Reset each page element object :param driver_wrapper: driver wrapper instance """ if driver_wrapper: self.driver_wrapper = driver_wrapper for element in self._page_elements: element.reset_object(driver_wrapp...
[ "def", "reset_object", "(", "self", ",", "driver_wrapper", "=", "None", ")", ":", "if", "driver_wrapper", ":", "self", ".", "driver_wrapper", "=", "driver_wrapper", "for", "element", "in", "self", ".", "_page_elements", ":", "element", ".", "reset_object", "("...
Reset each page element object :param driver_wrapper: driver wrapper instance
[ "Reset", "each", "page", "element", "object" ]
python
train
googleapis/google-cloud-python
bigquery/google/cloud/bigquery/job.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigquery/google/cloud/bigquery/job.py#L2065-L2084
def destination(self): """google.cloud.bigquery.table.TableReference: table where results are written or :data:`None` if not set. The ``destination`` setter accepts: - a :class:`~google.cloud.bigquery.table.Table`, or - a :class:`~google.cloud.bigquery.table.TableReference`, or...
[ "def", "destination", "(", "self", ")", ":", "prop", "=", "self", ".", "_get_sub_prop", "(", "\"destinationTable\"", ")", "if", "prop", "is", "not", "None", ":", "prop", "=", "TableReference", ".", "from_api_repr", "(", "prop", ")", "return", "prop" ]
google.cloud.bigquery.table.TableReference: table where results are written or :data:`None` if not set. The ``destination`` setter accepts: - a :class:`~google.cloud.bigquery.table.Table`, or - a :class:`~google.cloud.bigquery.table.TableReference`, or - a :class:`str` of the f...
[ "google", ".", "cloud", ".", "bigquery", ".", "table", ".", "TableReference", ":", "table", "where", "results", "are", "written", "or", ":", "data", ":", "None", "if", "not", "set", "." ]
python
train
jtwhite79/pyemu
pyemu/pst/pst_handler.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/pst/pst_handler.py#L2585-L2602
def greater_than_obs_constraints(self): """get the names of the observations that are listed as greater than inequality constraints. Zero- weighted obs are skipped Returns ------- pandas.Series : obsnme of obseravtions that are non-zero weighted ...
[ "def", "greater_than_obs_constraints", "(", "self", ")", ":", "obs", "=", "self", ".", "observation_data", "gt_obs", "=", "obs", ".", "loc", "[", "obs", ".", "apply", "(", "lambda", "x", ":", "self", ".", "_is_greater_const", "(", "x", ".", "obgnme", ")"...
get the names of the observations that are listed as greater than inequality constraints. Zero- weighted obs are skipped Returns ------- pandas.Series : obsnme of obseravtions that are non-zero weighted greater than constraints
[ "get", "the", "names", "of", "the", "observations", "that", "are", "listed", "as", "greater", "than", "inequality", "constraints", ".", "Zero", "-", "weighted", "obs", "are", "skipped" ]
python
train
zhmcclient/python-zhmcclient
zhmcclient/_nic.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_nic.py#L291-L324
def update_properties(self, properties): """ Update writeable properties of this NIC. Authorization requirements: * Object-access permission to the Partition containing this NIC. * Object-access permission to the backing Adapter for this NIC. * Task permission to the "P...
[ "def", "update_properties", "(", "self", ",", "properties", ")", ":", "self", ".", "manager", ".", "session", ".", "post", "(", "self", ".", "uri", ",", "body", "=", "properties", ")", "is_rename", "=", "self", ".", "manager", ".", "_name_prop", "in", ...
Update writeable properties of this NIC. Authorization requirements: * Object-access permission to the Partition containing this NIC. * Object-access permission to the backing Adapter for this NIC. * Task permission to the "Partition Details" task. Parameters: prope...
[ "Update", "writeable", "properties", "of", "this", "NIC", "." ]
python
train
pymc-devs/pymc
pymc/diagnostics.py
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/diagnostics.py#L497-L552
def effective_n(x): """ Returns estimate of the effective sample size of a set of traces. Parameters ---------- x : array-like An array containing the 2 or more traces of a stochastic parameter. That is, an array of dimension m x n x k, where m is the number of traces, n the number of samples, an...
[ "def", "effective_n", "(", "x", ")", ":", "if", "np", ".", "shape", "(", "x", ")", "<", "(", "2", ",", ")", ":", "raise", "ValueError", "(", "'Calculation of effective sample size requires multiple chains of the same length.'", ")", "try", ":", "m", ",", "n", ...
Returns estimate of the effective sample size of a set of traces. Parameters ---------- x : array-like An array containing the 2 or more traces of a stochastic parameter. That is, an array of dimension m x n x k, where m is the number of traces, n the number of samples, and k the dimension of the sto...
[ "Returns", "estimate", "of", "the", "effective", "sample", "size", "of", "a", "set", "of", "traces", "." ]
python
train
opendatateam/udata
udata/core/dataset/models.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/core/dataset/models.py#L149-L185
def guess_one(cls, text): ''' Try to guess license from a string. Try to exact match on identifier then slugified title and fallback on edit distance ranking (after slugification) ''' if not text: return qs = cls.objects text = text.strip().lo...
[ "def", "guess_one", "(", "cls", ",", "text", ")", ":", "if", "not", "text", ":", "return", "qs", "=", "cls", ".", "objects", "text", "=", "text", ".", "strip", "(", ")", ".", "lower", "(", ")", "# Stored identifiers are lower case", "slug", "=", "cls",...
Try to guess license from a string. Try to exact match on identifier then slugified title and fallback on edit distance ranking (after slugification)
[ "Try", "to", "guess", "license", "from", "a", "string", "." ]
python
train
NuGrid/NuGridPy
nugridpy/mesa.py
https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/mesa.py#L1446-L1536
def kippenhahn_CO(self, num_frame, xax, t0_model=0, title='Kippenhahn diagram', tp_agb=0., ylim_CO=[0,0]): """ Kippenhahn plot as a function of time or model with CO ratio Parameters ---------- num_frame : integer Number of...
[ "def", "kippenhahn_CO", "(", "self", ",", "num_frame", ",", "xax", ",", "t0_model", "=", "0", ",", "title", "=", "'Kippenhahn diagram'", ",", "tp_agb", "=", "0.", ",", "ylim_CO", "=", "[", "0", ",", "0", "]", ")", ":", "pyl", ".", "figure", "(", "n...
Kippenhahn plot as a function of time or model with CO ratio Parameters ---------- num_frame : integer Number of frame to plot this plot into. xax : string Either model or time to indicate what is to be used on the x-axis. t0_model : integer, ...
[ "Kippenhahn", "plot", "as", "a", "function", "of", "time", "or", "model", "with", "CO", "ratio" ]
python
train
pandas-dev/pandas
pandas/core/arrays/categorical.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L2031-L2037
def _maybe_coerce_indexer(self, indexer): """ return an indexer coerced to the codes dtype """ if isinstance(indexer, np.ndarray) and indexer.dtype.kind == 'i': indexer = indexer.astype(self._codes.dtype) return indexer
[ "def", "_maybe_coerce_indexer", "(", "self", ",", "indexer", ")", ":", "if", "isinstance", "(", "indexer", ",", "np", ".", "ndarray", ")", "and", "indexer", ".", "dtype", ".", "kind", "==", "'i'", ":", "indexer", "=", "indexer", ".", "astype", "(", "se...
return an indexer coerced to the codes dtype
[ "return", "an", "indexer", "coerced", "to", "the", "codes", "dtype" ]
python
train
senaite/senaite.core
bika/lims/browser/analyses/view.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/analyses/view.py#L259-L293
def is_analysis_edition_allowed(self, analysis_brain): """Returns if the analysis passed in can be edited by the current user :param analysis_brain: Brain that represents an analysis :return: True if the user can edit the analysis, otherwise False """ if not self.context_active:...
[ "def", "is_analysis_edition_allowed", "(", "self", ",", "analysis_brain", ")", ":", "if", "not", "self", ".", "context_active", ":", "# The current context must be active. We cannot edit analyses from", "# inside a deactivated Analysis Request, for instance", "return", "False", "...
Returns if the analysis passed in can be edited by the current user :param analysis_brain: Brain that represents an analysis :return: True if the user can edit the analysis, otherwise False
[ "Returns", "if", "the", "analysis", "passed", "in", "can", "be", "edited", "by", "the", "current", "user" ]
python
train
dddomodossola/remi
examples/examples_from_contributors/Display_TreeTable.py
https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/examples/examples_from_contributors/Display_TreeTable.py#L51-L120
def Display_TreeTable(self, table): ''' Display a table in which the values in first column form one or more trees. The table has row with fields that are strings of identifiers/names. First convert each row into a row_widget and item_widgets that are displayed in a TableTree...
[ "def", "Display_TreeTable", "(", "self", ",", "table", ")", ":", "parent_names", "=", "[", "]", "hierarchy", "=", "{", "}", "indent_level", "=", "0", "widget_dict", "=", "{", "}", "# key, value = name, widget", "for", "row", "in", "table", ":", "parent_name"...
Display a table in which the values in first column form one or more trees. The table has row with fields that are strings of identifiers/names. First convert each row into a row_widget and item_widgets that are displayed in a TableTree. Each input row shall start with a ...
[ "Display", "a", "table", "in", "which", "the", "values", "in", "first", "column", "form", "one", "or", "more", "trees", ".", "The", "table", "has", "row", "with", "fields", "that", "are", "strings", "of", "identifiers", "/", "names", ".", "First", "conve...
python
train
nickmckay/LiPD-utilities
Python/lipd/dataframes.py
https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/dataframes.py#L36-L55
def create_dataframe(ensemble): """ Create a data frame from given nested lists of ensemble data :param list ensemble: Ensemble data :return obj: Dataframe """ logger_dataframes.info("enter ens_to_df") # "Flatten" the nested lists. Bring all nested lists up to top-level. Output looks like [ ...
[ "def", "create_dataframe", "(", "ensemble", ")", ":", "logger_dataframes", ".", "info", "(", "\"enter ens_to_df\"", ")", "# \"Flatten\" the nested lists. Bring all nested lists up to top-level. Output looks like [ [1,2], [1,2], ... ]", "ll", "=", "unwrap_arrays", "(", "ensemble", ...
Create a data frame from given nested lists of ensemble data :param list ensemble: Ensemble data :return obj: Dataframe
[ "Create", "a", "data", "frame", "from", "given", "nested", "lists", "of", "ensemble", "data", ":", "param", "list", "ensemble", ":", "Ensemble", "data", ":", "return", "obj", ":", "Dataframe" ]
python
train
zomux/deepy
examples/attention_models/first_glimpse_model.py
https://github.com/zomux/deepy/blob/090fbad22a08a809b12951cd0d4984f5bd432698/examples/attention_models/first_glimpse_model.py#L38-L54
def _first_glimpse_sensor(self, x_t): """ Compute first glimpse position using down-sampled image. """ downsampled_img = theano.tensor.signal.downsample.max_pool_2d(x_t, (4,4)) downsampled_img = downsampled_img.flatten() first_l = T.dot(downsampled_img, self.W_f) ...
[ "def", "_first_glimpse_sensor", "(", "self", ",", "x_t", ")", ":", "downsampled_img", "=", "theano", ".", "tensor", ".", "signal", ".", "downsample", ".", "max_pool_2d", "(", "x_t", ",", "(", "4", ",", "4", ")", ")", "downsampled_img", "=", "downsampled_im...
Compute first glimpse position using down-sampled image.
[ "Compute", "first", "glimpse", "position", "using", "down", "-", "sampled", "image", "." ]
python
test
MrYsLab/PyMata
examples/i2c/pymata_i2c_write/bicolor_display_controller.py
https://github.com/MrYsLab/PyMata/blob/7e0ec34670b5a0d3d6b74bcbe4f3808c845cc429/examples/i2c/pymata_i2c_write/bicolor_display_controller.py#L96-L104
def set_blink_rate(self, b): """ Set the user's desired blink rate (0 - 3) @param b: blink rate """ if b > 3: b = 0 # turn off if not sure self.firmata.i2c_write(self.board_address, (self.HT16K33_BLINK_CMD | self.HT16K33_BLINK_D...
[ "def", "set_blink_rate", "(", "self", ",", "b", ")", ":", "if", "b", ">", "3", ":", "b", "=", "0", "# turn off if not sure", "self", ".", "firmata", ".", "i2c_write", "(", "self", ".", "board_address", ",", "(", "self", ".", "HT16K33_BLINK_CMD", "|", "...
Set the user's desired blink rate (0 - 3) @param b: blink rate
[ "Set", "the", "user", "s", "desired", "blink", "rate", "(", "0", "-", "3", ")" ]
python
valid
apache/airflow
airflow/contrib/hooks/gcp_mlengine_hook.py
https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/contrib/hooks/gcp_mlengine_hook.py#L60-L121
def create_job(self, project_id, job, use_existing_job_fn=None): """ Launches a MLEngine job and wait for it to reach a terminal state. :param project_id: The Google Cloud project id within which MLEngine job will be launched. :type project_id: str :param job: MLEng...
[ "def", "create_job", "(", "self", ",", "project_id", ",", "job", ",", "use_existing_job_fn", "=", "None", ")", ":", "request", "=", "self", ".", "_mlengine", ".", "projects", "(", ")", ".", "jobs", "(", ")", ".", "create", "(", "parent", "=", "'project...
Launches a MLEngine job and wait for it to reach a terminal state. :param project_id: The Google Cloud project id within which MLEngine job will be launched. :type project_id: str :param job: MLEngine Job object that should be provided to the MLEngine API, such as: :: ...
[ "Launches", "a", "MLEngine", "job", "and", "wait", "for", "it", "to", "reach", "a", "terminal", "state", "." ]
python
test
waqasbhatti/astrobase
astrobase/varclass/starfeatures.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/varclass/starfeatures.py#L102-L174
def coord_features(objectinfo): '''Calculates object coordinates features, including: - galactic coordinates - total proper motion from pmra, pmdecl - reduced J proper motion from propermotion and Jmag Parameters ---------- objectinfo : dict This is an objectinfo dict from a ligh...
[ "def", "coord_features", "(", "objectinfo", ")", ":", "retdict", "=", "{", "'propermotion'", ":", "np", ".", "nan", ",", "'gl'", ":", "np", ".", "nan", ",", "'gb'", ":", "np", ".", "nan", ",", "'rpmj'", ":", "np", ".", "nan", "}", "if", "(", "'ra...
Calculates object coordinates features, including: - galactic coordinates - total proper motion from pmra, pmdecl - reduced J proper motion from propermotion and Jmag Parameters ---------- objectinfo : dict This is an objectinfo dict from a light curve file read into an `lcdic...
[ "Calculates", "object", "coordinates", "features", "including", ":" ]
python
valid
craigahobbs/chisel
src/chisel/app.py
https://github.com/craigahobbs/chisel/blob/d306a9eae2ff757647c6ca1c933bc944efa5c326/src/chisel/app.py#L178-L185
def add_header(self, key, value): """ Add a response header """ assert isinstance(key, str), 'header key must be of type str' assert isinstance(value, str), 'header value must be of type str' self.headers[key] = value
[ "def", "add_header", "(", "self", ",", "key", ",", "value", ")", ":", "assert", "isinstance", "(", "key", ",", "str", ")", ",", "'header key must be of type str'", "assert", "isinstance", "(", "value", ",", "str", ")", ",", "'header value must be of type str'", ...
Add a response header
[ "Add", "a", "response", "header" ]
python
train
rwl/pylon
pylon/io/excel.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L76-L84
def write_generator_data(self, file): """ Write generator data to file. """ generator_sheet = self.book.add_sheet("Generators") for j, generator in enumerate(self.case.generators): i = generator.bus._i for k, attr in enumerate(GENERATOR_ATTRS): ge...
[ "def", "write_generator_data", "(", "self", ",", "file", ")", ":", "generator_sheet", "=", "self", ".", "book", ".", "add_sheet", "(", "\"Generators\"", ")", "for", "j", ",", "generator", "in", "enumerate", "(", "self", ".", "case", ".", "generators", ")",...
Write generator data to file.
[ "Write", "generator", "data", "to", "file", "." ]
python
train
annoviko/pyclustering
pyclustering/nnet/legion.py
https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/legion.py#L193-L206
def allocate_sync_ensembles(self, tolerance = 0.1): """! @brief Allocate clusters in line with ensembles of synchronous oscillators where each synchronous ensemble corresponds to only one cluster. @param[in] tolerance (double): Maximum error for allocation of synchronous ensemble os...
[ "def", "allocate_sync_ensembles", "(", "self", ",", "tolerance", "=", "0.1", ")", ":", "if", "(", "self", ".", "__ccore_legion_dynamic_pointer", "is", "not", "None", ")", ":", "self", ".", "__output", "=", "wrapper", ".", "legion_dynamic_get_output", "(", "sel...
! @brief Allocate clusters in line with ensembles of synchronous oscillators where each synchronous ensemble corresponds to only one cluster. @param[in] tolerance (double): Maximum error for allocation of synchronous ensemble oscillators. @return (list) Grours of indexes o...
[ "!" ]
python
valid
jmgilman/Neolib
neolib/pyamf/amf3.py
https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf3.py#L1271-L1298
def writeList(self, n, is_proxy=False): """ Writes a C{tuple}, C{set} or C{list} to the stream. @type n: One of C{__builtin__.tuple}, C{__builtin__.set} or C{__builtin__.list} @param n: The C{list} data to be encoded to the AMF3 data stream. """ if self.use_p...
[ "def", "writeList", "(", "self", ",", "n", ",", "is_proxy", "=", "False", ")", ":", "if", "self", ".", "use_proxies", "and", "not", "is_proxy", ":", "self", ".", "writeProxy", "(", "n", ")", "return", "self", ".", "stream", ".", "write", "(", "TYPE_A...
Writes a C{tuple}, C{set} or C{list} to the stream. @type n: One of C{__builtin__.tuple}, C{__builtin__.set} or C{__builtin__.list} @param n: The C{list} data to be encoded to the AMF3 data stream.
[ "Writes", "a", "C", "{", "tuple", "}", "C", "{", "set", "}", "or", "C", "{", "list", "}", "to", "the", "stream", "." ]
python
train
AndrewIngram/django-extra-views
extra_views/formsets.py
https://github.com/AndrewIngram/django-extra-views/blob/188e1bf1f15a44d9a599028d020083af9fb43ea7/extra_views/formsets.py#L85-L102
def get_factory_kwargs(self): """ Returns the keyword arguments for calling the formset factory """ # Perform deprecation check for attr in ['extra', 'max_num', 'can_order', 'can_delete', 'ct_field', 'formfield_callback', 'fk_name', 'widgets', 'ct_fk_field']:...
[ "def", "get_factory_kwargs", "(", "self", ")", ":", "# Perform deprecation check", "for", "attr", "in", "[", "'extra'", ",", "'max_num'", ",", "'can_order'", ",", "'can_delete'", ",", "'ct_field'", ",", "'formfield_callback'", ",", "'fk_name'", ",", "'widgets'", "...
Returns the keyword arguments for calling the formset factory
[ "Returns", "the", "keyword", "arguments", "for", "calling", "the", "formset", "factory" ]
python
valid
pantsbuild/pants
src/python/pants/build_graph/build_configuration.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/build_graph/build_configuration.py#L116-L136
def register_optionables(self, optionables): """Registers the given subsystem types. :param optionables: The Optionable types to register. :type optionables: :class:`collections.Iterable` containing :class:`pants.option.optionable.Optionable` subclasses. """ if not isinstance...
[ "def", "register_optionables", "(", "self", ",", "optionables", ")", ":", "if", "not", "isinstance", "(", "optionables", ",", "Iterable", ")", ":", "raise", "TypeError", "(", "'The optionables must be an iterable, given {}'", ".", "format", "(", "optionables", ")", ...
Registers the given subsystem types. :param optionables: The Optionable types to register. :type optionables: :class:`collections.Iterable` containing :class:`pants.option.optionable.Optionable` subclasses.
[ "Registers", "the", "given", "subsystem", "types", "." ]
python
train
keenlabs/KeenClient-Python
keen/scoped_keys.py
https://github.com/keenlabs/KeenClient-Python/blob/266387c3376d1e000d117e17c45045ae3439d43f/keen/scoped_keys.py#L23-L32
def pad_aes256(s): """ Pads an input string to a given block size. :param s: string :returns: The padded string. """ if len(s) % AES.block_size == 0: return s return Padding.appendPadding(s, blocksize=AES.block_size)
[ "def", "pad_aes256", "(", "s", ")", ":", "if", "len", "(", "s", ")", "%", "AES", ".", "block_size", "==", "0", ":", "return", "s", "return", "Padding", ".", "appendPadding", "(", "s", ",", "blocksize", "=", "AES", ".", "block_size", ")" ]
Pads an input string to a given block size. :param s: string :returns: The padded string.
[ "Pads", "an", "input", "string", "to", "a", "given", "block", "size", ".", ":", "param", "s", ":", "string", ":", "returns", ":", "The", "padded", "string", "." ]
python
train
hyperledger/sawtooth-core
validator/sawtooth_validator/state/batch_tracker.py
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/batch_tracker.py#L112-L128
def get_status(self, batch_id): """Returns the status enum for a batch. Args: batch_id (str): The id of the batch to get the status for Returns: int: The status enum """ with self._lock: if self._batch_committed(batch_id): ret...
[ "def", "get_status", "(", "self", ",", "batch_id", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_batch_committed", "(", "batch_id", ")", ":", "return", "ClientBatchStatus", ".", "COMMITTED", "if", "batch_id", "in", "self", ".", "_invali...
Returns the status enum for a batch. Args: batch_id (str): The id of the batch to get the status for Returns: int: The status enum
[ "Returns", "the", "status", "enum", "for", "a", "batch", "." ]
python
train
wummel/linkchecker
third_party/dnspython/dns/message.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/dnspython/dns/message.py#L271-L290
def is_response(self, other): """Is other a response to self? @rtype: bool""" if other.flags & dns.flags.QR == 0 or \ self.id != other.id or \ dns.opcode.from_flags(self.flags) != \ dns.opcode.from_flags(other.flags): return False if dns.rcode...
[ "def", "is_response", "(", "self", ",", "other", ")", ":", "if", "other", ".", "flags", "&", "dns", ".", "flags", ".", "QR", "==", "0", "or", "self", ".", "id", "!=", "other", ".", "id", "or", "dns", ".", "opcode", ".", "from_flags", "(", "self",...
Is other a response to self? @rtype: bool
[ "Is", "other", "a", "response", "to", "self?" ]
python
train
kensho-technologies/graphql-compiler
graphql_compiler/compiler/expressions.py
https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L769-L779
def validate(self): """Validate that the BinaryComposition is correctly representable.""" _validate_operator_name(self.operator, BinaryComposition.SUPPORTED_OPERATORS) if not isinstance(self.left, Expression): raise TypeError(u'Expected Expression left, got: {} {} {}'.format( ...
[ "def", "validate", "(", "self", ")", ":", "_validate_operator_name", "(", "self", ".", "operator", ",", "BinaryComposition", ".", "SUPPORTED_OPERATORS", ")", "if", "not", "isinstance", "(", "self", ".", "left", ",", "Expression", ")", ":", "raise", "TypeError"...
Validate that the BinaryComposition is correctly representable.
[ "Validate", "that", "the", "BinaryComposition", "is", "correctly", "representable", "." ]
python
train
jobovy/galpy
galpy/potential/PowerSphericalPotentialwCutoff.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/PowerSphericalPotentialwCutoff.py#L132-L150
def _R2deriv(self,R,z,phi=0.,t=0.): """ NAME: _Rderiv PURPOSE: evaluate the second radial derivative for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT...
[ "def", "_R2deriv", "(", "self", ",", "R", ",", "z", ",", "phi", "=", "0.", ",", "t", "=", "0.", ")", ":", "r", "=", "nu", ".", "sqrt", "(", "R", "*", "R", "+", "z", "*", "z", ")", "return", "4.", "*", "nu", ".", "pi", "*", "r", "**", ...
NAME: _Rderiv PURPOSE: evaluate the second radial derivative for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: the second radial derivative HISTOR...
[ "NAME", ":", "_Rderiv", "PURPOSE", ":", "evaluate", "the", "second", "radial", "derivative", "for", "this", "potential", "INPUT", ":", "R", "-", "Galactocentric", "cylindrical", "radius", "z", "-", "vertical", "height", "phi", "-", "azimuth", "t", "-", "time...
python
train
greenape/mktheapidocs
mktheapidocs/mkapi.py
https://github.com/greenape/mktheapidocs/blob/a45e8b43ddd80ed360fe1e98d4f73dc11c4e7bf7/mktheapidocs/mkapi.py#L615-L632
def _split_props(thing, doc): """ Separate properties from other kinds of member. """ props = inspect.getmembers(thing, lambda o: isinstance(o, property)) ps = [] docs = [ (*_get_names(names, types), names, types, desc) for names, types, desc in doc ] for prop_name, prop in props...
[ "def", "_split_props", "(", "thing", ",", "doc", ")", ":", "props", "=", "inspect", ".", "getmembers", "(", "thing", ",", "lambda", "o", ":", "isinstance", "(", "o", ",", "property", ")", ")", "ps", "=", "[", "]", "docs", "=", "[", "(", "*", "_ge...
Separate properties from other kinds of member.
[ "Separate", "properties", "from", "other", "kinds", "of", "member", "." ]
python
train
proycon/pynlpl
pynlpl/formats/folia.py
https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1366-L1385
def setdocument(self, doc): """Associate a document with this element. Arguments: doc (:class:`Document`): A document Each element must be associated with a FoLiA document. """ assert isinstance(doc, Document) if not self.doc: self.doc = doc ...
[ "def", "setdocument", "(", "self", ",", "doc", ")", ":", "assert", "isinstance", "(", "doc", ",", "Document", ")", "if", "not", "self", ".", "doc", ":", "self", ".", "doc", "=", "doc", "if", "self", ".", "id", ":", "if", "self", ".", "id", "in", ...
Associate a document with this element. Arguments: doc (:class:`Document`): A document Each element must be associated with a FoLiA document.
[ "Associate", "a", "document", "with", "this", "element", "." ]
python
train
jonathf/chaospy
chaospy/poly/collection/core.py
https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/poly/collection/core.py#L259-L307
def swapdim(P, dim1=1, dim2=0): """ Swap the dim between two variables. Args: P (Poly): Input polynomial. dim1 (int): First dim dim2 (int): Second dim. Returns: (Poly): Polynomial with swapped dimensions. Examples: ...
[ "def", "swapdim", "(", "P", ",", "dim1", "=", "1", ",", "dim2", "=", "0", ")", ":", "if", "not", "isinstance", "(", "P", ",", "Poly", ")", ":", "return", "numpy", ".", "swapaxes", "(", "P", ",", "dim1", ",", "dim2", ")", "dim", "=", "P", ".",...
Swap the dim between two variables. Args: P (Poly): Input polynomial. dim1 (int): First dim dim2 (int): Second dim. Returns: (Poly): Polynomial with swapped dimensions. Examples: >>> x,y = variable(2) >>> P = ...
[ "Swap", "the", "dim", "between", "two", "variables", "." ]
python
train
amorison/loam
loam/cli.py
https://github.com/amorison/loam/blob/a566c943a75e068a4510099331a1ddfe5bbbdd94/loam/cli.py#L248-L292
def zsh_complete(self, path, cmd, *cmds, sourceable=False): """Write zsh compdef script. Args: path (path-like): desired path of the compdef script. cmd (str): command name that should be completed. cmds (str): extra command names that should be completed. ...
[ "def", "zsh_complete", "(", "self", ",", "path", ",", "cmd", ",", "*", "cmds", ",", "sourceable", "=", "False", ")", ":", "grouping", "=", "internal", ".", "zsh_version", "(", ")", ">=", "(", "5", ",", "4", ")", "path", "=", "pathlib", ".", "Path",...
Write zsh compdef script. Args: path (path-like): desired path of the compdef script. cmd (str): command name that should be completed. cmds (str): extra command names that should be completed. sourceable (bool): if True, the generated file will contain an ...
[ "Write", "zsh", "compdef", "script", "." ]
python
test
memphis-iis/GLUDB
gludb/backends/dynamodb.py
https://github.com/memphis-iis/GLUDB/blob/25692528ff6fe8184a3570f61f31f1a90088a388/gludb/backends/dynamodb.py#L116-L133
def ensure_table(self, cls): """Required functionality.""" exists = True conn = get_conn() try: descrip = conn.describe_table(cls.get_table_name()) assert descrip is not None except ResourceNotFoundException: # Expected - this is what we get i...
[ "def", "ensure_table", "(", "self", ",", "cls", ")", ":", "exists", "=", "True", "conn", "=", "get_conn", "(", ")", "try", ":", "descrip", "=", "conn", ".", "describe_table", "(", "cls", ".", "get_table_name", "(", ")", ")", "assert", "descrip", "is", ...
Required functionality.
[ "Required", "functionality", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/frontend/qt/console/rich_ipython_widget.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/rich_ipython_widget.py#L113-L134
def _handle_pyout(self, msg): """ Overridden to handle rich data types, like SVG. """ if not self._hidden and self._is_from_this_session(msg): content = msg['content'] prompt_number = content.get('execution_count', 0) data = content['data'] if data...
[ "def", "_handle_pyout", "(", "self", ",", "msg", ")", ":", "if", "not", "self", ".", "_hidden", "and", "self", ".", "_is_from_this_session", "(", "msg", ")", ":", "content", "=", "msg", "[", "'content'", "]", "prompt_number", "=", "content", ".", "get", ...
Overridden to handle rich data types, like SVG.
[ "Overridden", "to", "handle", "rich", "data", "types", "like", "SVG", "." ]
python
test
tchellomello/python-arlo
pyarlo/camera.py
https://github.com/tchellomello/python-arlo/blob/db70aeb81705309c56ad32bbab1094f6cd146524/pyarlo/camera.py#L244-L258
def triggers(self): """Get a camera's triggers.""" capabilities = self.capabilities if not capabilities: return None for capability in capabilities: if not isinstance(capability, dict): continue triggers = capability.get("Triggers") ...
[ "def", "triggers", "(", "self", ")", ":", "capabilities", "=", "self", ".", "capabilities", "if", "not", "capabilities", ":", "return", "None", "for", "capability", "in", "capabilities", ":", "if", "not", "isinstance", "(", "capability", ",", "dict", ")", ...
Get a camera's triggers.
[ "Get", "a", "camera", "s", "triggers", "." ]
python
train
cosven/feeluown-core
fuocore/netease/models.py
https://github.com/cosven/feeluown-core/blob/62dc64638f62971b16be0a75c0b8c7ae2999869e/fuocore/netease/models.py#L67-L88
def url(self): """ We will always check if this song file exists in local library, if true, we return the url of the local file. .. note:: As netease song url will be expired after a period of time, we can not use static url here. Currently, we assume that the ...
[ "def", "url", "(", "self", ")", ":", "local_path", "=", "self", ".", "_find_in_local", "(", ")", "if", "local_path", ":", "return", "local_path", "if", "not", "self", ".", "_url", ":", "self", ".", "_refresh_url", "(", ")", "elif", "time", ".", "time",...
We will always check if this song file exists in local library, if true, we return the url of the local file. .. note:: As netease song url will be expired after a period of time, we can not use static url here. Currently, we assume that the expiration time is 20 mi...
[ "We", "will", "always", "check", "if", "this", "song", "file", "exists", "in", "local", "library", "if", "true", "we", "return", "the", "url", "of", "the", "local", "file", "." ]
python
train
g2p/bedup
bedup/platform/chattr.py
https://github.com/g2p/bedup/blob/9694f6f718844c33017052eb271f68b6c0d0b7d3/bedup/platform/chattr.py#L74-L82
def getflags(fd): """ Gets per-file filesystem flags. """ flags_ptr = ffi.new('uint64_t*') flags_buf = ffi.buffer(flags_ptr) fcntl.ioctl(fd, lib.FS_IOC_GETFLAGS, flags_buf) return flags_ptr[0]
[ "def", "getflags", "(", "fd", ")", ":", "flags_ptr", "=", "ffi", ".", "new", "(", "'uint64_t*'", ")", "flags_buf", "=", "ffi", ".", "buffer", "(", "flags_ptr", ")", "fcntl", ".", "ioctl", "(", "fd", ",", "lib", ".", "FS_IOC_GETFLAGS", ",", "flags_buf",...
Gets per-file filesystem flags.
[ "Gets", "per", "-", "file", "filesystem", "flags", "." ]
python
train
datacamp/protowhat
protowhat/checks/check_funcs.py
https://github.com/datacamp/protowhat/blob/a392b4e51e07a2e50e7b7f6ad918b3f5cbb63edc/protowhat/checks/check_funcs.py#L37-L101
def check_node( state, name, index=0, missing_msg="Check the {ast_path}. Could not find the {index}{node_name}.", priority=None, ): """Select a node from abstract syntax tree (AST), using its name and index position. Args: state: State instance describing student and solution code. ...
[ "def", "check_node", "(", "state", ",", "name", ",", "index", "=", "0", ",", "missing_msg", "=", "\"Check the {ast_path}. Could not find the {index}{node_name}.\"", ",", "priority", "=", "None", ",", ")", ":", "df", "=", "partial", "(", "state", ".", "ast_dispat...
Select a node from abstract syntax tree (AST), using its name and index position. Args: state: State instance describing student and solution code. Can be omitted if used with Ex(). name : the name of the abstract syntax tree node to find. index: the position of that node (see below for det...
[ "Select", "a", "node", "from", "abstract", "syntax", "tree", "(", "AST", ")", "using", "its", "name", "and", "index", "position", "." ]
python
train
DistrictDataLabs/yellowbrick
yellowbrick/features/pcoords.py
https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/features/pcoords.py#L488-L520
def finalize(self, **kwargs): """ Finalize executes any subclass-specific axes finalization steps. The user calls poof and poof calls finalize. Parameters ---------- kwargs: generic keyword arguments. """ # Set the title self.set_title( ...
[ "def", "finalize", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Set the title", "self", ".", "set_title", "(", "'Parallel Coordinates for {} Features'", ".", "format", "(", "len", "(", "self", ".", "features_", ")", ")", ")", "# Add the vertical lines", ...
Finalize executes any subclass-specific axes finalization steps. The user calls poof and poof calls finalize. Parameters ---------- kwargs: generic keyword arguments.
[ "Finalize", "executes", "any", "subclass", "-", "specific", "axes", "finalization", "steps", ".", "The", "user", "calls", "poof", "and", "poof", "calls", "finalize", "." ]
python
train
AtomHash/evernode
evernode/classes/email.py
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/classes/email.py#L95-L107
def send(self): """ Construct and execute sendemail.py script Finds python binary by os.py, then uses the /usr/bin/python to execute email script """ self.__create() email_script = \ os.path.join(Path(__file__).parents[1], 'scripts', 'sendemail...
[ "def", "send", "(", "self", ")", ":", "self", ".", "__create", "(", ")", "email_script", "=", "os", ".", "path", ".", "join", "(", "Path", "(", "__file__", ")", ".", "parents", "[", "1", "]", ",", "'scripts'", ",", "'sendemail.py'", ")", "if", "os"...
Construct and execute sendemail.py script Finds python binary by os.py, then uses the /usr/bin/python to execute email script
[ "Construct", "and", "execute", "sendemail", ".", "py", "script", "Finds", "python", "binary", "by", "os", ".", "py", "then", "uses", "the", "/", "usr", "/", "bin", "/", "python", "to", "execute", "email", "script" ]
python
train
summa-tx/riemann
riemann/tx/tx.py
https://github.com/summa-tx/riemann/blob/04ae336dfd4007ceaed748daadc91cc32fa278ec/riemann/tx/tx.py#L588-L602
def _sighash_anyone_can_pay(self, index, copy_tx, sighash_type): ''' int, byte-like, Tx, int -> bytes Applies SIGHASH_ANYONECANPAY procedure. Should be called by another SIGHASH procedure. Not on its own. https://en.bitcoin.it/wiki/OP_CHECKSIG#Procedure_for_Hashtype_SIGHA...
[ "def", "_sighash_anyone_can_pay", "(", "self", ",", "index", ",", "copy_tx", ",", "sighash_type", ")", ":", "# The txCopy input vector is resized to a length of one.", "copy_tx_ins", "=", "[", "copy_tx", ".", "tx_ins", "[", "index", "]", "]", "copy_tx", "=", "copy_t...
int, byte-like, Tx, int -> bytes Applies SIGHASH_ANYONECANPAY procedure. Should be called by another SIGHASH procedure. Not on its own. https://en.bitcoin.it/wiki/OP_CHECKSIG#Procedure_for_Hashtype_SIGHASH_ANYONECANPAY
[ "int", "byte", "-", "like", "Tx", "int", "-", ">", "bytes", "Applies", "SIGHASH_ANYONECANPAY", "procedure", ".", "Should", "be", "called", "by", "another", "SIGHASH", "procedure", ".", "Not", "on", "its", "own", ".", "https", ":", "//", "en", ".", "bitco...
python
train
ansible/tower-cli
tower_cli/resources/job_template.py
https://github.com/ansible/tower-cli/blob/a2b151fed93c47725018d3034848cb3a1814bed7/tower_cli/resources/job_template.py#L174-L193
def associate_notification_template(self, job_template, notification_template, status): """Associate a notification template from this job template. =====API DOCS===== Associate a notification template from this job template. :param job_template:...
[ "def", "associate_notification_template", "(", "self", ",", "job_template", ",", "notification_template", ",", "status", ")", ":", "return", "self", ".", "_assoc", "(", "'notification_templates_%s'", "%", "status", ",", "job_template", ",", "notification_template", ")...
Associate a notification template from this job template. =====API DOCS===== Associate a notification template from this job template. :param job_template: The job template to associate to. :type job_template: str :param notification_template: The notification template to be as...
[ "Associate", "a", "notification", "template", "from", "this", "job", "template", "." ]
python
valid
log2timeline/plaso
plaso/cli/tools.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/cli/tools.py#L332-L360
def ParseNumericOption(self, options, name, base=10, default_value=None): """Parses a numeric option. If the option is not set the default value is returned. Args: options (argparse.Namespace): command line arguments. name (str): name of the numeric option. base (Optional[int]): base of ...
[ "def", "ParseNumericOption", "(", "self", ",", "options", ",", "name", ",", "base", "=", "10", ",", "default_value", "=", "None", ")", ":", "numeric_value", "=", "getattr", "(", "options", ",", "name", ",", "None", ")", "if", "not", "numeric_value", ":",...
Parses a numeric option. If the option is not set the default value is returned. Args: options (argparse.Namespace): command line arguments. name (str): name of the numeric option. base (Optional[int]): base of the numeric value. default_value (Optional[object]): default value. Re...
[ "Parses", "a", "numeric", "option", "." ]
python
train
cdriehuys/django-rest-email-auth
rest_email_auth/generics.py
https://github.com/cdriehuys/django-rest-email-auth/blob/7e752c4d77ae02d2d046f214f56e743aa12ab23f/rest_email_auth/generics.py#L14-L35
def post(self, request): """ Save the provided data using the class' serializer. Args: request: The request being made. Returns: An ``APIResponse`` instance. If the request was successful the response will have a 200 status code and c...
[ "def", "post", "(", "self", ",", "request", ")", ":", "serializer", "=", "self", ".", "get_serializer", "(", "data", "=", "request", ".", "data", ")", "if", "serializer", ".", "is_valid", "(", ")", ":", "serializer", ".", "save", "(", ")", "return", ...
Save the provided data using the class' serializer. Args: request: The request being made. Returns: An ``APIResponse`` instance. If the request was successful the response will have a 200 status code and contain the serializer's data. Oth...
[ "Save", "the", "provided", "data", "using", "the", "class", "serializer", "." ]
python
valid
trailofbits/manticore
manticore/platforms/linux.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/platforms/linux.py#L1619-L1636
def sys_chroot(self, path): """ An implementation of chroot that does perform some basic error checking, but does not actually chroot. :param path: Path to chroot """ if path not in self.current.memory: return -errno.EFAULT path_s = self.current.read...
[ "def", "sys_chroot", "(", "self", ",", "path", ")", ":", "if", "path", "not", "in", "self", ".", "current", ".", "memory", ":", "return", "-", "errno", ".", "EFAULT", "path_s", "=", "self", ".", "current", ".", "read_string", "(", "path", ")", "if", ...
An implementation of chroot that does perform some basic error checking, but does not actually chroot. :param path: Path to chroot
[ "An", "implementation", "of", "chroot", "that", "does", "perform", "some", "basic", "error", "checking", "but", "does", "not", "actually", "chroot", "." ]
python
valid
jmbhughes/suvi-trainer
suvitrainer/fileio.py
https://github.com/jmbhughes/suvi-trainer/blob/3d89894a4a037286221974c7eb5634d229b4f5d4/suvitrainer/fileio.py#L72-L113
def fetch(self, multithread=True, median_kernel=5, solar_diam=740): """ For all products in products, will call the correct fetch routine and download an image :param multithread: if true will fetch the files simultaneously :type multithread: bool :param median_kernel: the size o...
[ "def", "fetch", "(", "self", ",", "multithread", "=", "True", ",", "median_kernel", "=", "5", ",", "solar_diam", "=", "740", ")", ":", "# helper function to pull data", "def", "func_map", "(", "product", ")", ":", "\"\"\"\n determines which function to ca...
For all products in products, will call the correct fetch routine and download an image :param multithread: if true will fetch the files simultaneously :type multithread: bool :param median_kernel: the size of the kernel to smooth by :type median_kernel: int >= 0 :return: a dicti...
[ "For", "all", "products", "in", "products", "will", "call", "the", "correct", "fetch", "routine", "and", "download", "an", "image", ":", "param", "multithread", ":", "if", "true", "will", "fetch", "the", "files", "simultaneously", ":", "type", "multithread", ...
python
train
mongodb/mongo-python-driver
pymongo/command_cursor.py
https://github.com/mongodb/mongo-python-driver/blob/c29c21449e3aae74154207058cf85fd94018d4cd/pymongo/command_cursor.py#L122-L167
def __send_message(self, operation): """Send a getmore message and handle the response. """ def kill(): self.__killed = True self.__end_session(True) client = self.__collection.database.client try: response = client._run_operation_with_respons...
[ "def", "__send_message", "(", "self", ",", "operation", ")", ":", "def", "kill", "(", ")", ":", "self", ".", "__killed", "=", "True", "self", ".", "__end_session", "(", "True", ")", "client", "=", "self", ".", "__collection", ".", "database", ".", "cli...
Send a getmore message and handle the response.
[ "Send", "a", "getmore", "message", "and", "handle", "the", "response", "." ]
python
train
diffeo/rejester
rejester/_task_master.py
https://github.com/diffeo/rejester/blob/5438a4a18be2801d7826c46e2079ba9639d2ecb4/rejester/_task_master.py#L1596-L1599
def nice(self, work_spec_name, nice): '''Change the priority of an existing work spec.''' with self.registry.lock(identifier=self.worker_id) as session: session.update(NICE_LEVELS, dict(work_spec_name=nice))
[ "def", "nice", "(", "self", ",", "work_spec_name", ",", "nice", ")", ":", "with", "self", ".", "registry", ".", "lock", "(", "identifier", "=", "self", ".", "worker_id", ")", "as", "session", ":", "session", ".", "update", "(", "NICE_LEVELS", ",", "dic...
Change the priority of an existing work spec.
[ "Change", "the", "priority", "of", "an", "existing", "work", "spec", "." ]
python
train
TrafficSenseMSD/SumoTools
traci/_vehicle.py
https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/traci/_vehicle.py#L1161-L1167
def setTau(self, vehID, tau): """setTau(string, double) -> None Sets the driver's tau-parameter (reaction time or anticipation time depending on the car-following model) in s for this vehicle. """ self._connection._sendDoubleCmd( tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_TAU, vehI...
[ "def", "setTau", "(", "self", ",", "vehID", ",", "tau", ")", ":", "self", ".", "_connection", ".", "_sendDoubleCmd", "(", "tc", ".", "CMD_SET_VEHICLE_VARIABLE", ",", "tc", ".", "VAR_TAU", ",", "vehID", ",", "tau", ")" ]
setTau(string, double) -> None Sets the driver's tau-parameter (reaction time or anticipation time depending on the car-following model) in s for this vehicle.
[ "setTau", "(", "string", "double", ")", "-", ">", "None" ]
python
train
JarryShaw/PyPCAPKit
src/interface/__init__.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/interface/__init__.py#L134-L151
def analyse(file, length=None): """Analyse application layer packets. Keyword arguments: * file -- bytes or file-like object, packet to be analysed * length -- int, length of the analysing packet Returns: * Analysis -- an Analysis object from `pcapkit.analyser` """ if isin...
[ "def", "analyse", "(", "file", ",", "length", "=", "None", ")", ":", "if", "isinstance", "(", "file", ",", "bytes", ")", ":", "file", "=", "io", ".", "BytesIO", "(", "file", ")", "io_check", "(", "file", ")", "int_check", "(", "length", "or", "sys"...
Analyse application layer packets. Keyword arguments: * file -- bytes or file-like object, packet to be analysed * length -- int, length of the analysing packet Returns: * Analysis -- an Analysis object from `pcapkit.analyser`
[ "Analyse", "application", "layer", "packets", "." ]
python
train
fbcotter/py3nvml
py3nvml/py3nvml.py
https://github.com/fbcotter/py3nvml/blob/47f0f2c0eee56dec4e4beebec26b734e01d357b7/py3nvml/py3nvml.py#L3033-L3063
def nvmlDeviceGetPowerManagementLimit(handle): r""" /** * Retrieves the power management limit associated with this device. * * For Fermi &tm; or newer fully supported devices. * * The power limit defines the upper boundary for the card's power draw. If * the card's total power dra...
[ "def", "nvmlDeviceGetPowerManagementLimit", "(", "handle", ")", ":", "c_limit", "=", "c_uint", "(", ")", "fn", "=", "_nvmlGetFunctionPointer", "(", "\"nvmlDeviceGetPowerManagementLimit\"", ")", "ret", "=", "fn", "(", "handle", ",", "byref", "(", "c_limit", ")", ...
r""" /** * Retrieves the power management limit associated with this device. * * For Fermi &tm; or newer fully supported devices. * * The power limit defines the upper boundary for the card's power draw. If * the card's total power draw reaches this limit the power management algorithm...
[ "r", "/", "**", "*", "Retrieves", "the", "power", "management", "limit", "associated", "with", "this", "device", ".", "*", "*", "For", "Fermi", "&tm", ";", "or", "newer", "fully", "supported", "devices", ".", "*", "*", "The", "power", "limit", "defines",...
python
train
MisanthropicBit/colorise
colorise/BaseColorManager.py
https://github.com/MisanthropicBit/colorise/blob/e630df74b8b27680a43c370ddbe98766be50158c/colorise/BaseColorManager.py#L34-L36
def set_color(self, fg=None, bg=None, intensify=False, target=sys.stdout): """Set foreground- and background colors and intensity.""" raise NotImplementedError
[ "def", "set_color", "(", "self", ",", "fg", "=", "None", ",", "bg", "=", "None", ",", "intensify", "=", "False", ",", "target", "=", "sys", ".", "stdout", ")", ":", "raise", "NotImplementedError" ]
Set foreground- and background colors and intensity.
[ "Set", "foreground", "-", "and", "background", "colors", "and", "intensity", "." ]
python
train
Alignak-monitoring/alignak
alignak/objects/servicegroup.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/servicegroup.py#L260-L285
def explode(self): """ Get services and put them in members container :return: None """ # We do not want a same service group to be exploded again and again # so we tag it for tmp_sg in list(self.items.values()): tmp_sg.already_exploded = False ...
[ "def", "explode", "(", "self", ")", ":", "# We do not want a same service group to be exploded again and again", "# so we tag it", "for", "tmp_sg", "in", "list", "(", "self", ".", "items", ".", "values", "(", ")", ")", ":", "tmp_sg", ".", "already_exploded", "=", ...
Get services and put them in members container :return: None
[ "Get", "services", "and", "put", "them", "in", "members", "container" ]
python
train
limix/glimix-core
glimix_core/random/_canonical.py
https://github.com/limix/glimix-core/blob/cddd0994591d100499cc41c1f480ddd575e7a980/glimix_core/random/_canonical.py#L110-L144
def poisson_sample( offset, G, heritability=0.5, causal_variants=None, causal_variance=0, random_state=None, ): """Poisson likelihood sampling. Parameters ---------- random_state : random_state Set the initial random state. Example ------- .. doctest:: ...
[ "def", "poisson_sample", "(", "offset", ",", "G", ",", "heritability", "=", "0.5", ",", "causal_variants", "=", "None", ",", "causal_variance", "=", "0", ",", "random_state", "=", "None", ",", ")", ":", "mean", ",", "cov", "=", "_mean_cov", "(", "offset"...
Poisson likelihood sampling. Parameters ---------- random_state : random_state Set the initial random state. Example ------- .. doctest:: >>> from glimix_core.random import poisson_sample >>> from numpy.random import RandomState >>> offset = -0.5 >>> G...
[ "Poisson", "likelihood", "sampling", "." ]
python
valid
noirbizarre/flask-fs
flask_fs/storage.py
https://github.com/noirbizarre/flask-fs/blob/092e9327384b8411c9bb38ca257ecb558584d201/flask_fs/storage.py#L220-L229
def read(self, filename): ''' Read a file content. :param string filename: The storage root-relative filename :raises FileNotFound: If the file does not exists ''' if not self.backend.exists(filename): raise FileNotFound(filename) return self.backend....
[ "def", "read", "(", "self", ",", "filename", ")", ":", "if", "not", "self", ".", "backend", ".", "exists", "(", "filename", ")", ":", "raise", "FileNotFound", "(", "filename", ")", "return", "self", ".", "backend", ".", "read", "(", "filename", ")" ]
Read a file content. :param string filename: The storage root-relative filename :raises FileNotFound: If the file does not exists
[ "Read", "a", "file", "content", "." ]
python
train
IrvKalb/pygwidgets
pygwidgets/pygwidgets.py
https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L770-L837
def handleEvent(self, eventObj): """This method should be called every time through the main loop. It handles showing the up, over, and down states of the button. Parameters: | eventObj - the event object obtained by calling pygame.event.get() Returns: ...
[ "def", "handleEvent", "(", "self", ",", "eventObj", ")", ":", "if", "eventObj", ".", "type", "not", "in", "(", "MOUSEMOTION", ",", "MOUSEBUTTONUP", ",", "MOUSEBUTTONDOWN", ")", "or", "not", "self", ".", "visible", ":", "# The checkBox only cares bout mouse-relat...
This method should be called every time through the main loop. It handles showing the up, over, and down states of the button. Parameters: | eventObj - the event object obtained by calling pygame.event.get() Returns: | False most of the time | True...
[ "This", "method", "should", "be", "called", "every", "time", "through", "the", "main", "loop", ".", "It", "handles", "showing", "the", "up", "over", "and", "down", "states", "of", "the", "button", ".", "Parameters", ":", "|", "eventObj", "-", "the", "eve...
python
train
drewsonne/pyum
pyum/rpm.py
https://github.com/drewsonne/pyum/blob/5d2955f86575c9430ab7104211b3d67bd4c0febe/pyum/rpm.py#L126-L133
def dependencies(self): """ Read the contents of the rpm itself :return: """ cpio = self.rpm.gzip_file.read() content = cpio.read() return []
[ "def", "dependencies", "(", "self", ")", ":", "cpio", "=", "self", ".", "rpm", ".", "gzip_file", ".", "read", "(", ")", "content", "=", "cpio", ".", "read", "(", ")", "return", "[", "]" ]
Read the contents of the rpm itself :return:
[ "Read", "the", "contents", "of", "the", "rpm", "itself", ":", "return", ":" ]
python
test
niemasd/TreeSwift
treeswift/Tree.py
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L757-L783
def num_lineages_at(self, distance): '''Returns the number of lineages of this ``Tree`` that exist ``distance`` away from the root Args: ``distance`` (``float``): The distance away from the root Returns: ``int``: The number of lineages that exist ``distance`` away from ...
[ "def", "num_lineages_at", "(", "self", ",", "distance", ")", ":", "if", "not", "isinstance", "(", "distance", ",", "float", ")", "and", "not", "isinstance", "(", "distance", ",", "int", ")", ":", "raise", "TypeError", "(", "\"distance must be an int or a float...
Returns the number of lineages of this ``Tree`` that exist ``distance`` away from the root Args: ``distance`` (``float``): The distance away from the root Returns: ``int``: The number of lineages that exist ``distance`` away from the root
[ "Returns", "the", "number", "of", "lineages", "of", "this", "Tree", "that", "exist", "distance", "away", "from", "the", "root" ]
python
train
Capitains/Nautilus
capitains_nautilus/apis/dts.py
https://github.com/Capitains/Nautilus/blob/6be453fe0cc0e2c1b89ff06e5af1409165fc1411/capitains_nautilus/apis/dts.py#L41-L53
def r_dts_collection(self, objectId=None): """ DTS Collection Metadata reply for given objectId :param objectId: Collection Identifier :return: JSON Format of DTS Collection """ try: j = self.resolver.getMetadata(objectId=objectId).export(Mimetypes.JSON.DTS.Std) ...
[ "def", "r_dts_collection", "(", "self", ",", "objectId", "=", "None", ")", ":", "try", ":", "j", "=", "self", ".", "resolver", ".", "getMetadata", "(", "objectId", "=", "objectId", ")", ".", "export", "(", "Mimetypes", ".", "JSON", ".", "DTS", ".", "...
DTS Collection Metadata reply for given objectId :param objectId: Collection Identifier :return: JSON Format of DTS Collection
[ "DTS", "Collection", "Metadata", "reply", "for", "given", "objectId" ]
python
train
roclark/sportsreference
sportsreference/ncaab/schedule.py
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/ncaab/schedule.py#L195-L208
def datetime(self): """ Returns a datetime object to indicate the month, day, year, and time the requested game took place. """ date_string = '%s %s' % (self._date, self._time.upper()) date_string = re.sub(r'/.*', '', date_string) date_string = re.sub(r' ET', '', ...
[ "def", "datetime", "(", "self", ")", ":", "date_string", "=", "'%s %s'", "%", "(", "self", ".", "_date", ",", "self", ".", "_time", ".", "upper", "(", ")", ")", "date_string", "=", "re", ".", "sub", "(", "r'/.*'", ",", "''", ",", "date_string", ")"...
Returns a datetime object to indicate the month, day, year, and time the requested game took place.
[ "Returns", "a", "datetime", "object", "to", "indicate", "the", "month", "day", "year", "and", "time", "the", "requested", "game", "took", "place", "." ]
python
train
seomoz/qless-py
qless/queue.py
https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/queue.py#L131-L139
def pop(self, count=None): '''Passing in the queue from which to pull items, the current time, when the locks for these returned items should expire, and the number of items to be popped off.''' results = [Job(self.client, **job) for job in json.loads( self.client('pop', self...
[ "def", "pop", "(", "self", ",", "count", "=", "None", ")", ":", "results", "=", "[", "Job", "(", "self", ".", "client", ",", "*", "*", "job", ")", "for", "job", "in", "json", ".", "loads", "(", "self", ".", "client", "(", "'pop'", ",", "self", ...
Passing in the queue from which to pull items, the current time, when the locks for these returned items should expire, and the number of items to be popped off.
[ "Passing", "in", "the", "queue", "from", "which", "to", "pull", "items", "the", "current", "time", "when", "the", "locks", "for", "these", "returned", "items", "should", "expire", "and", "the", "number", "of", "items", "to", "be", "popped", "off", "." ]
python
train
crs4/hl7apy
hl7apy/parser.py
https://github.com/crs4/hl7apy/blob/91be488e9274f6ec975519a1d9c17045bc91bf74/hl7apy/parser.py#L38-L100
def parse_message(message, validation_level=None, find_groups=True, message_profile=None, report_file=None, force_validation=False): """ Parse the given ER7-encoded message and return an instance of :class:`Message <hl7apy.core.Message>`. :type message: ``str`` :param message: the ER7...
[ "def", "parse_message", "(", "message", ",", "validation_level", "=", "None", ",", "find_groups", "=", "True", ",", "message_profile", "=", "None", ",", "report_file", "=", "None", ",", "force_validation", "=", "False", ")", ":", "message", "=", "message", "...
Parse the given ER7-encoded message and return an instance of :class:`Message <hl7apy.core.Message>`. :type message: ``str`` :param message: the ER7-encoded message to be parsed :type validation_level: ``int`` :param validation_level: the validation level. Possible values are those defined in ...
[ "Parse", "the", "given", "ER7", "-", "encoded", "message", "and", "return", "an", "instance", "of", ":", "class", ":", "Message", "<hl7apy", ".", "core", ".", "Message", ">", "." ]
python
train
urinieto/msaf
msaf/base.py
https://github.com/urinieto/msaf/blob/9dbb57d77a1310465a65cc40f1641d083ca74385/msaf/base.py#L351-L355
def _compute_framesync_times(self): """Computes the framesync times based on the framesync features.""" self._framesync_times = librosa.core.frames_to_time( np.arange(self._framesync_features.shape[0]), self.sr, self.hop_length)
[ "def", "_compute_framesync_times", "(", "self", ")", ":", "self", ".", "_framesync_times", "=", "librosa", ".", "core", ".", "frames_to_time", "(", "np", ".", "arange", "(", "self", ".", "_framesync_features", ".", "shape", "[", "0", "]", ")", ",", "self",...
Computes the framesync times based on the framesync features.
[ "Computes", "the", "framesync", "times", "based", "on", "the", "framesync", "features", "." ]
python
test
briandilley/ebs-deploy
ebs_deploy/commands/swap_urls_command.py
https://github.com/briandilley/ebs-deploy/blob/4178c9c1282a9025fb987dab3470bea28c202e10/ebs_deploy/commands/swap_urls_command.py#L13-L26
def execute(helper, config, args): """ Swaps old and new URLs. If old_environment was active, new_environment will become the active environment """ old_env_name = args.old_environment new_env_name = args.new_environment # swap C-Names out("Assuming that {} is the currently active envir...
[ "def", "execute", "(", "helper", ",", "config", ",", "args", ")", ":", "old_env_name", "=", "args", ".", "old_environment", "new_env_name", "=", "args", ".", "new_environment", "# swap C-Names", "out", "(", "\"Assuming that {} is the currently active environment...\"", ...
Swaps old and new URLs. If old_environment was active, new_environment will become the active environment
[ "Swaps", "old", "and", "new", "URLs", ".", "If", "old_environment", "was", "active", "new_environment", "will", "become", "the", "active", "environment" ]
python
valid
hollenstein/maspy
maspy/featuregrouping.py
https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/featuregrouping.py#L534-L632
def lfqFeatureGrouping(fiContainer, timeLimit=40, massLimit=10*1e-6, eucLimit=None, timeKey='rt', massKey='mz', massScalingFactor=None, categoryKey='specfile', charges=None, matchArraySelector=None, specfiles=None): """ #TODO: docstring :para...
[ "def", "lfqFeatureGrouping", "(", "fiContainer", ",", "timeLimit", "=", "40", ",", "massLimit", "=", "10", "*", "1e-6", ",", "eucLimit", "=", "None", ",", "timeKey", "=", "'rt'", ",", "massKey", "=", "'mz'", ",", "massScalingFactor", "=", "None", ",", "c...
#TODO: docstring :param fiContainer: #TODO: docstring :param timeLimit: #TODO: docstring :param massLimit: #TODO: docstring :param eucLimit: #TODO: docstring :param timeKey: #TODO: docstring :param massKey: #TODO: docstring :param massScalingFactor: #TODO: docstring :param categoryKey: ...
[ "#TODO", ":", "docstring" ]
python
train
Falkonry/falkonry-python-client
falkonryclient/service/http.py
https://github.com/Falkonry/falkonry-python-client/blob/0aeb2b00293ee94944f1634e9667401b03da29c1/falkonryclient/service/http.py#L157-L195
def fpost(self, url, form_data): """ To make a form-data POST request to Falkonry API server :param url: string :param form_data: form-data """ response = None if 'files' in form_data: response = requests.post( self.host + url, ...
[ "def", "fpost", "(", "self", ",", "url", ",", "form_data", ")", ":", "response", "=", "None", "if", "'files'", "in", "form_data", ":", "response", "=", "requests", ".", "post", "(", "self", ".", "host", "+", "url", ",", "data", "=", "form_data", "[",...
To make a form-data POST request to Falkonry API server :param url: string :param form_data: form-data
[ "To", "make", "a", "form", "-", "data", "POST", "request", "to", "Falkonry", "API", "server", ":", "param", "url", ":", "string", ":", "param", "form_data", ":", "form", "-", "data" ]
python
train
sassoo/goldman
goldman/serializers/jsonapi_error.py
https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/jsonapi_error.py#L87-L103
def get_status(self): """ Return a HTTPStatus compliant status attribute Per the JSON API spec errors could have different status codes & a generic one should be chosen in these conditions for the actual HTTP response code. """ codes = [error['status'] for error in self...
[ "def", "get_status", "(", "self", ")", ":", "codes", "=", "[", "error", "[", "'status'", "]", "for", "error", "in", "self", ".", "errors", "]", "same", "=", "all", "(", "code", "==", "codes", "[", "0", "]", "for", "code", "in", "codes", ")", "if"...
Return a HTTPStatus compliant status attribute Per the JSON API spec errors could have different status codes & a generic one should be chosen in these conditions for the actual HTTP response code.
[ "Return", "a", "HTTPStatus", "compliant", "status", "attribute" ]
python
train
saulpw/visidata
visidata/vdtui.py
https://github.com/saulpw/visidata/blob/32771e0cea6c24fc7902683d14558391395c591f/visidata/vdtui.py#L175-L181
def _get(self, k, obj=None): 'Return Option object for k in context of obj. Cache result until any set().' opt = self._cache.get((k, obj), None) if opt is None: opt = self._opts._get(k, obj) self._cache[(k, obj or vd.sheet)] = opt return opt
[ "def", "_get", "(", "self", ",", "k", ",", "obj", "=", "None", ")", ":", "opt", "=", "self", ".", "_cache", ".", "get", "(", "(", "k", ",", "obj", ")", ",", "None", ")", "if", "opt", "is", "None", ":", "opt", "=", "self", ".", "_opts", ".",...
Return Option object for k in context of obj. Cache result until any set().
[ "Return", "Option", "object", "for", "k", "in", "context", "of", "obj", ".", "Cache", "result", "until", "any", "set", "()", "." ]
python
train
openeemeter/eemeter
eemeter/caltrack/usage_per_day.py
https://github.com/openeemeter/eemeter/blob/e03b1cc5f4906e8f4f7fd16183bc037107d1dfa0/eemeter/caltrack/usage_per_day.py#L332-L345
def json(self): """ Return a JSON-serializable representation of this result. The output of this function can be converted to a serialized string with :any:`json.dumps`. """ return { "model_type": self.model_type, "formula": self.formula, "sta...
[ "def", "json", "(", "self", ")", ":", "return", "{", "\"model_type\"", ":", "self", ".", "model_type", ",", "\"formula\"", ":", "self", ".", "formula", ",", "\"status\"", ":", "self", ".", "status", ",", "\"model_params\"", ":", "self", ".", "model_params"...
Return a JSON-serializable representation of this result. The output of this function can be converted to a serialized string with :any:`json.dumps`.
[ "Return", "a", "JSON", "-", "serializable", "representation", "of", "this", "result", "." ]
python
train
rduplain/jeni-python
jeni.py
https://github.com/rduplain/jeni-python/blob/feca12ce5e4f0438ae5d7bec59d61826063594f1/jeni.py#L750-L760
def lookup(cls, basenote): """Look up note in registered annotations, walking class tree.""" # Walk method resolution order, which includes current class. for c in cls.mro(): if 'provider_registry' not in vars(c): # class is a mixin, super to base class, or never regi...
[ "def", "lookup", "(", "cls", ",", "basenote", ")", ":", "# Walk method resolution order, which includes current class.", "for", "c", "in", "cls", ".", "mro", "(", ")", ":", "if", "'provider_registry'", "not", "in", "vars", "(", "c", ")", ":", "# class is a mixin...
Look up note in registered annotations, walking class tree.
[ "Look", "up", "note", "in", "registered", "annotations", "walking", "class", "tree", "." ]
python
train
gem/oq-engine
openquake/commonlib/calc.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/calc.py#L268-L291
def to_array(self, ebruptures): """ Convert a list of ebruptures into an array of dtype RuptureRata.dt """ data = [] for ebr in ebruptures: rup = ebr.rupture self.cmaker.add_rup_params(rup) ruptparams = tuple(getattr(rup, param) for param in se...
[ "def", "to_array", "(", "self", ",", "ebruptures", ")", ":", "data", "=", "[", "]", "for", "ebr", "in", "ebruptures", ":", "rup", "=", "ebr", ".", "rupture", "self", ".", "cmaker", ".", "add_rup_params", "(", "rup", ")", "ruptparams", "=", "tuple", "...
Convert a list of ebruptures into an array of dtype RuptureRata.dt
[ "Convert", "a", "list", "of", "ebruptures", "into", "an", "array", "of", "dtype", "RuptureRata", ".", "dt" ]
python
train
HazyResearch/fonduer
src/fonduer/parser/spacy_parser.py
https://github.com/HazyResearch/fonduer/blob/4520f86a716f03dcca458a9f4bddac75b4e7068f/src/fonduer/parser/spacy_parser.py#L212-L270
def split_sentences(self, text): """ Split input text into sentences that match CoreNLP's default format, but are not yet processed. :param text: The text of the parent paragraph of the sentences :return: """ if self.model.has_pipe("sentence_boundary_detector"):...
[ "def", "split_sentences", "(", "self", ",", "text", ")", ":", "if", "self", ".", "model", ".", "has_pipe", "(", "\"sentence_boundary_detector\"", ")", ":", "self", ".", "model", ".", "remove_pipe", "(", "name", "=", "\"sentence_boundary_detector\"", ")", "if",...
Split input text into sentences that match CoreNLP's default format, but are not yet processed. :param text: The text of the parent paragraph of the sentences :return:
[ "Split", "input", "text", "into", "sentences", "that", "match", "CoreNLP", "s", "default", "format", "but", "are", "not", "yet", "processed", "." ]
python
train
pkgw/pwkit
pwkit/environments/casa/util.py
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/util.py#L108-L163
def datadir(*subdirs): """Get a path within the CASA data directory. subdirs Extra elements to append to the returned path. This function locates the directory where CASA resource data files (tables of time offsets, calibrator models, etc.) are stored. If called with no arguments, it simply ...
[ "def", "datadir", "(", "*", "subdirs", ")", ":", "import", "os", ".", "path", "data", "=", "None", "if", "'CASAPATH'", "in", "os", ".", "environ", ":", "data", "=", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'CASAPATH'", "]", ...
Get a path within the CASA data directory. subdirs Extra elements to append to the returned path. This function locates the directory where CASA resource data files (tables of time offsets, calibrator models, etc.) are stored. If called with no arguments, it simply returns that path. If argument...
[ "Get", "a", "path", "within", "the", "CASA", "data", "directory", "." ]
python
train
facetoe/zenpy
zenpy/lib/api.py
https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/api.py#L1142-L1148
def metrics_incremental(self, start_time): """ Retrieve TicketMetric incremental :param start_time: time to retrieve events from. """ return self._query_zendesk(self.endpoint.metrics.incremental, 'ticket_metric_events', start_time=start_time)
[ "def", "metrics_incremental", "(", "self", ",", "start_time", ")", ":", "return", "self", ".", "_query_zendesk", "(", "self", ".", "endpoint", ".", "metrics", ".", "incremental", ",", "'ticket_metric_events'", ",", "start_time", "=", "start_time", ")" ]
Retrieve TicketMetric incremental :param start_time: time to retrieve events from.
[ "Retrieve", "TicketMetric", "incremental" ]
python
train
asmodehn/filefinder2
filefinder2/_filefinder2.py
https://github.com/asmodehn/filefinder2/blob/3f0b211ce11a34562e2a2160e039ae5290b68d6b/filefinder2/_filefinder2.py#L127-L139
def find_module(cls, fullname, path=None): """find the module on sys.path or 'path' based on sys.path_hooks and sys.path_importer_cache. This method is for python2 only """ spec = cls.find_spec(fullname, path) if spec is None: return None elif spec.loa...
[ "def", "find_module", "(", "cls", ",", "fullname", ",", "path", "=", "None", ")", ":", "spec", "=", "cls", ".", "find_spec", "(", "fullname", ",", "path", ")", "if", "spec", "is", "None", ":", "return", "None", "elif", "spec", ".", "loader", "is", ...
find the module on sys.path or 'path' based on sys.path_hooks and sys.path_importer_cache. This method is for python2 only
[ "find", "the", "module", "on", "sys", ".", "path", "or", "path", "based", "on", "sys", ".", "path_hooks", "and", "sys", ".", "path_importer_cache", ".", "This", "method", "is", "for", "python2", "only" ]
python
train
mdgoldberg/sportsref
sportsref/nba/players.py
https://github.com/mdgoldberg/sportsref/blob/09f11ac856a23c96d666d1d510bb35d6f050b5c3/sportsref/nba/players.py#L142-L157
def _get_stats_table(self, table_id, kind='R', summary=False): """Gets a stats table from the player page; helper function that does the work for per-game, per-100-poss, etc. stats. :table_id: the ID of the HTML table. :kind: specifies regular season, playoffs, or both. One of 'R', 'P',...
[ "def", "_get_stats_table", "(", "self", ",", "table_id", ",", "kind", "=", "'R'", ",", "summary", "=", "False", ")", ":", "doc", "=", "self", ".", "get_main_doc", "(", ")", "table_id", "=", "'table#{}{}'", ".", "format", "(", "'playoffs_'", "if", "kind",...
Gets a stats table from the player page; helper function that does the work for per-game, per-100-poss, etc. stats. :table_id: the ID of the HTML table. :kind: specifies regular season, playoffs, or both. One of 'R', 'P', 'B'. Defaults to 'R'. :returns: A DataFrame of stats.
[ "Gets", "a", "stats", "table", "from", "the", "player", "page", ";", "helper", "function", "that", "does", "the", "work", "for", "per", "-", "game", "per", "-", "100", "-", "poss", "etc", ".", "stats", "." ]
python
test
MuhammedHasan/sklearn_utils
sklearn_utils/noise/noise_preprocessing.py
https://github.com/MuhammedHasan/sklearn_utils/blob/337c3b7a27f4921d12da496f66a2b83ef582b413/sklearn_utils/noise/noise_preprocessing.py#L24-L31
def transform(self, X): ''' :X: numpy ndarray ''' noise = self._noise_func(*self._args, size=X.shape) results = X + noise self.relative_noise_size_ = self.relative_noise_size(X, results) return results
[ "def", "transform", "(", "self", ",", "X", ")", ":", "noise", "=", "self", ".", "_noise_func", "(", "*", "self", ".", "_args", ",", "size", "=", "X", ".", "shape", ")", "results", "=", "X", "+", "noise", "self", ".", "relative_noise_size_", "=", "s...
:X: numpy ndarray
[ ":", "X", ":", "numpy", "ndarray" ]
python
test
click-contrib/sphinx-click
sphinx_click/ext.py
https://github.com/click-contrib/sphinx-click/blob/ec76d15697ec80e51486a6e3daa0aec60b04870f/sphinx_click/ext.py#L175-L189
def _format_subcommand(command): """Format a sub-command of a `click.Command` or `click.Group`.""" yield '.. object:: {}'.format(command.name) # click 7.0 stopped setting short_help by default if CLICK_VERSION < (7, 0): short_help = command.short_help else: short_help = command.get_...
[ "def", "_format_subcommand", "(", "command", ")", ":", "yield", "'.. object:: {}'", ".", "format", "(", "command", ".", "name", ")", "# click 7.0 stopped setting short_help by default", "if", "CLICK_VERSION", "<", "(", "7", ",", "0", ")", ":", "short_help", "=", ...
Format a sub-command of a `click.Command` or `click.Group`.
[ "Format", "a", "sub", "-", "command", "of", "a", "click", ".", "Command", "or", "click", ".", "Group", "." ]
python
train
SeabornGames/RequestClient
seaborn/request_client/connection_basic.py
https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/seaborn/request_client/connection_basic.py#L480-L486
def sub_base_uri(self): """ This will return the sub_base_uri parsed from the base_uri :return: str of the sub_base_uri """ return self._base_uri and \ self._base_uri.split('://')[-1].split('.')[0] \ or self._base_uri
[ "def", "sub_base_uri", "(", "self", ")", ":", "return", "self", ".", "_base_uri", "and", "self", ".", "_base_uri", ".", "split", "(", "'://'", ")", "[", "-", "1", "]", ".", "split", "(", "'.'", ")", "[", "0", "]", "or", "self", ".", "_base_uri" ]
This will return the sub_base_uri parsed from the base_uri :return: str of the sub_base_uri
[ "This", "will", "return", "the", "sub_base_uri", "parsed", "from", "the", "base_uri", ":", "return", ":", "str", "of", "the", "sub_base_uri" ]
python
train
tensorflow/tensor2tensor
tensor2tensor/rl/evaluator.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/rl/evaluator.py#L300-L321
def make_agent_from_hparams( agent_type, base_env, stacked_env, loop_hparams, policy_hparams, planner_hparams, model_dir, policy_dir, sampling_temp, video_writers=() ): """Creates an Agent from hparams.""" def sim_env_kwargs_fn(): return rl.make_simulated_env_kwargs( base_env, loop_hparams, batc...
[ "def", "make_agent_from_hparams", "(", "agent_type", ",", "base_env", ",", "stacked_env", ",", "loop_hparams", ",", "policy_hparams", ",", "planner_hparams", ",", "model_dir", ",", "policy_dir", ",", "sampling_temp", ",", "video_writers", "=", "(", ")", ")", ":", ...
Creates an Agent from hparams.
[ "Creates", "an", "Agent", "from", "hparams", "." ]
python
train
secdev/scapy
scapy/contrib/automotive/someip.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/contrib/automotive/someip.py#L179-L188
def _is_tp(pkt): """Returns true if pkt is using SOMEIP-TP, else returns false.""" tp = [SOMEIP.TYPE_TP_REQUEST, SOMEIP.TYPE_TP_REQUEST_NO_RET, SOMEIP.TYPE_TP_NOTIFICATION, SOMEIP.TYPE_TP_RESPONSE, SOMEIP.TYPE_TP_ERROR] if isinstance(pkt, Packet): return ...
[ "def", "_is_tp", "(", "pkt", ")", ":", "tp", "=", "[", "SOMEIP", ".", "TYPE_TP_REQUEST", ",", "SOMEIP", ".", "TYPE_TP_REQUEST_NO_RET", ",", "SOMEIP", ".", "TYPE_TP_NOTIFICATION", ",", "SOMEIP", ".", "TYPE_TP_RESPONSE", ",", "SOMEIP", ".", "TYPE_TP_ERROR", "]",...
Returns true if pkt is using SOMEIP-TP, else returns false.
[ "Returns", "true", "if", "pkt", "is", "using", "SOMEIP", "-", "TP", "else", "returns", "false", "." ]
python
train
sibirrer/lenstronomy
lenstronomy/LensModel/Optimizer/optimizer.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/Optimizer/optimizer.py#L145-L195
def optimize(self, n_particles=50, n_iterations=250, restart=1): """ the best result of all optimizations will be returned. total number of lens models sovled: n_particles*n_iterations :param n_particles: number of particle swarm particles :param n_iterations: number of particl...
[ "def", "optimize", "(", "self", ",", "n_particles", "=", "50", ",", "n_iterations", "=", "250", ",", "restart", "=", "1", ")", ":", "if", "restart", "<", "0", ":", "raise", "ValueError", "(", "\"parameter 'restart' must be integer of value > 0\"", ")", "# part...
the best result of all optimizations will be returned. total number of lens models sovled: n_particles*n_iterations :param n_particles: number of particle swarm particles :param n_iterations: number of particle swarm iternations :param restart: number of times to execute the optimizatio...
[ "the", "best", "result", "of", "all", "optimizations", "will", "be", "returned", ".", "total", "number", "of", "lens", "models", "sovled", ":", "n_particles", "*", "n_iterations" ]
python
train
PmagPy/PmagPy
programs/magic_gui2.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/programs/magic_gui2.py#L210-L236
def on_change_dir_button(self, event): """ create change directory frame """ currentDirectory = self.WD #os.getcwd() change_dir_dialog = wx.DirDialog(self.panel, "Choose your working directory to create or edit a MagIC contribution:", ...
[ "def", "on_change_dir_button", "(", "self", ",", "event", ")", ":", "currentDirectory", "=", "self", ".", "WD", "#os.getcwd()", "change_dir_dialog", "=", "wx", ".", "DirDialog", "(", "self", ".", "panel", ",", "\"Choose your working directory to create or edit a MagIC...
create change directory frame
[ "create", "change", "directory", "frame" ]
python
train
Kortemme-Lab/klab
klab/general/date_ext.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/general/date_ext.py#L14-L22
def date_to_long_form_string(dt, locale_ = 'en_US.utf8'): '''dt should be a datetime.date object.''' if locale_: old_locale = locale.getlocale() locale.setlocale(locale.LC_ALL, locale_) v = dt.strftime("%A %B %d %Y") if locale_: locale.setlocale(locale.LC_ALL, old_locale) ret...
[ "def", "date_to_long_form_string", "(", "dt", ",", "locale_", "=", "'en_US.utf8'", ")", ":", "if", "locale_", ":", "old_locale", "=", "locale", ".", "getlocale", "(", ")", "locale", ".", "setlocale", "(", "locale", ".", "LC_ALL", ",", "locale_", ")", "v", ...
dt should be a datetime.date object.
[ "dt", "should", "be", "a", "datetime", ".", "date", "object", "." ]
python
train
chemlab/chemlab
chemlab/qc/utils.py
https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/qc/utils.py#L142-L149
def symorth(S): "Symmetric orthogonalization" E,U = np.linalg.eigh(S) n = len(E) Shalf = np.identity(n,'d') for i in range(n): Shalf[i,i] /= np.sqrt(E[i]) return simx(Shalf,U,True)
[ "def", "symorth", "(", "S", ")", ":", "E", ",", "U", "=", "np", ".", "linalg", ".", "eigh", "(", "S", ")", "n", "=", "len", "(", "E", ")", "Shalf", "=", "np", ".", "identity", "(", "n", ",", "'d'", ")", "for", "i", "in", "range", "(", "n"...
Symmetric orthogonalization
[ "Symmetric", "orthogonalization" ]
python
train
PyCQA/pylint
pylint/lint.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/lint.py#L1360-L1392
def preprocess_options(args, search_for): """look for some options (keys of <search_for>) which have to be processed before others values of <search_for> are callback functions to call when the option is found """ i = 0 while i < len(args): arg = args[i] if arg.startswith("-...
[ "def", "preprocess_options", "(", "args", ",", "search_for", ")", ":", "i", "=", "0", "while", "i", "<", "len", "(", "args", ")", ":", "arg", "=", "args", "[", "i", "]", "if", "arg", ".", "startswith", "(", "\"--\"", ")", ":", "try", ":", "option...
look for some options (keys of <search_for>) which have to be processed before others values of <search_for> are callback functions to call when the option is found
[ "look", "for", "some", "options", "(", "keys", "of", "<search_for", ">", ")", "which", "have", "to", "be", "processed", "before", "others" ]
python
test
isogeo/isogeo-api-py-minsdk
isogeo_pysdk/checker.py
https://github.com/isogeo/isogeo-api-py-minsdk/blob/57a604be92c7767b26abd247012cc1a584b386a0/isogeo_pysdk/checker.py#L308-L349
def check_edit_tab(self, tab: str, md_type: str): """Check if asked tab is part of Isogeo web form and reliable with metadata type. :param str tab: tab to check. Must be one one of EDIT_TABS attribute :param str md_type: metadata type. Must be one one of FILTER_TYPES """ ...
[ "def", "check_edit_tab", "(", "self", ",", "tab", ":", "str", ",", "md_type", ":", "str", ")", ":", "# check parameters types", "if", "not", "isinstance", "(", "tab", ",", "str", ")", ":", "raise", "TypeError", "(", "\"'tab' expected a str value.\"", ")", "e...
Check if asked tab is part of Isogeo web form and reliable with metadata type. :param str tab: tab to check. Must be one one of EDIT_TABS attribute :param str md_type: metadata type. Must be one one of FILTER_TYPES
[ "Check", "if", "asked", "tab", "is", "part", "of", "Isogeo", "web", "form", "and", "reliable", "with", "metadata", "type", "." ]
python
train
saltstack/salt
salt/modules/svn.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/svn.py#L76-L130
def info(cwd, targets=None, user=None, username=None, password=None, fmt='str'): ''' Display the Subversion information from the checkout. cwd The path to the Subversion repository targets : None files, directories, and URLs to pass to the c...
[ "def", "info", "(", "cwd", ",", "targets", "=", "None", ",", "user", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ",", "fmt", "=", "'str'", ")", ":", "opts", "=", "list", "(", ")", "if", "fmt", "==", "'xml'", ":", "o...
Display the Subversion information from the checkout. cwd The path to the Subversion repository targets : None files, directories, and URLs to pass to the command as arguments svn uses '.' by default user : None Run svn as a user other than what the minion runs as use...
[ "Display", "the", "Subversion", "information", "from", "the", "checkout", "." ]
python
train
goodmami/penman
penman.py
https://github.com/goodmami/penman/blob/a2563ca16063a7330e2028eb489a99cc8e425c41/penman.py#L691-L704
def edges(self, source=None, relation=None, target=None): """ Return edges filtered by their *source*, *relation*, or *target*. Edges don't include terminal triples (node types or attributes). """ edgematch = lambda e: ( (source is None or source == e.source) and ...
[ "def", "edges", "(", "self", ",", "source", "=", "None", ",", "relation", "=", "None", ",", "target", "=", "None", ")", ":", "edgematch", "=", "lambda", "e", ":", "(", "(", "source", "is", "None", "or", "source", "==", "e", ".", "source", ")", "a...
Return edges filtered by their *source*, *relation*, or *target*. Edges don't include terminal triples (node types or attributes).
[ "Return", "edges", "filtered", "by", "their", "*", "source", "*", "*", "relation", "*", "or", "*", "target", "*", "." ]
python
train
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L3299-L3318
def _load(self, keyframe=True): """Read all remaining pages from file.""" if self._cached: return pages = self.pages if not pages: return if not self._indexed: self._seek(-1) if not self._cache: return fh = self.pare...
[ "def", "_load", "(", "self", ",", "keyframe", "=", "True", ")", ":", "if", "self", ".", "_cached", ":", "return", "pages", "=", "self", ".", "pages", "if", "not", "pages", ":", "return", "if", "not", "self", ".", "_indexed", ":", "self", ".", "_see...
Read all remaining pages from file.
[ "Read", "all", "remaining", "pages", "from", "file", "." ]
python
train
Cologler/fsoopify-python
fsoopify/nodes.py
https://github.com/Cologler/fsoopify-python/blob/83d45f16ae9abdea4fcc829373c32df501487dda/fsoopify/nodes.py#L305-L309
def has_directory(self, name: str): ''' check whether this directory contains the directory. ''' return os.path.isdir(self._path / name)
[ "def", "has_directory", "(", "self", ",", "name", ":", "str", ")", ":", "return", "os", ".", "path", ".", "isdir", "(", "self", ".", "_path", "/", "name", ")" ]
check whether this directory contains the directory.
[ "check", "whether", "this", "directory", "contains", "the", "directory", "." ]
python
train
saltstack/salt
salt/master.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L385-L436
def fill_buckets(self): ''' Get the configured backends and the intervals for any backend which supports them, and set up the update "buckets". There will be one bucket for each thing being updated at a given interval. ''' update_intervals = self.fileserver.update_interva...
[ "def", "fill_buckets", "(", "self", ")", ":", "update_intervals", "=", "self", ".", "fileserver", ".", "update_intervals", "(", ")", "self", ".", "buckets", "=", "{", "}", "for", "backend", "in", "self", ".", "fileserver", ".", "backends", "(", ")", ":",...
Get the configured backends and the intervals for any backend which supports them, and set up the update "buckets". There will be one bucket for each thing being updated at a given interval.
[ "Get", "the", "configured", "backends", "and", "the", "intervals", "for", "any", "backend", "which", "supports", "them", "and", "set", "up", "the", "update", "buckets", ".", "There", "will", "be", "one", "bucket", "for", "each", "thing", "being", "updated", ...
python
train
calmjs/calmjs.parse
src/calmjs/parse/utils.py
https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/utils.py#L60-L70
def normrelpath(base, target): """ This function takes the base and target arguments as paths, and returns an equivalent relative path from base to the target, if both provided paths are absolute. """ if not all(map(isabs, [base, target])): return target return relpath(normpath(tar...
[ "def", "normrelpath", "(", "base", ",", "target", ")", ":", "if", "not", "all", "(", "map", "(", "isabs", ",", "[", "base", ",", "target", "]", ")", ")", ":", "return", "target", "return", "relpath", "(", "normpath", "(", "target", ")", ",", "dirna...
This function takes the base and target arguments as paths, and returns an equivalent relative path from base to the target, if both provided paths are absolute.
[ "This", "function", "takes", "the", "base", "and", "target", "arguments", "as", "paths", "and", "returns", "an", "equivalent", "relative", "path", "from", "base", "to", "the", "target", "if", "both", "provided", "paths", "are", "absolute", "." ]
python
train
zhmcclient/python-zhmcclient
zhmcclient/_utils.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_utils.py#L97-L104
def repr_timestamp(timestamp): """Return a debug representation of an HMC timestamp number.""" if timestamp is None: return 'None' dt = datetime_from_timestamp(timestamp) ret = "%d (%s)" % (timestamp, dt.strftime('%Y-%m-%d %H:%M:%S.%f %Z')) return ret
[ "def", "repr_timestamp", "(", "timestamp", ")", ":", "if", "timestamp", "is", "None", ":", "return", "'None'", "dt", "=", "datetime_from_timestamp", "(", "timestamp", ")", "ret", "=", "\"%d (%s)\"", "%", "(", "timestamp", ",", "dt", ".", "strftime", "(", "...
Return a debug representation of an HMC timestamp number.
[ "Return", "a", "debug", "representation", "of", "an", "HMC", "timestamp", "number", "." ]
python
train
zhmcclient/python-zhmcclient
zhmcclient/_session.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_session.py#L1228-L1296
def wait_for_completion(self, operation_timeout=None): """ Wait for completion of the job, then delete the job on the HMC and return the result of the original asynchronous HMC operation, if it completed successfully. If the job completed in error, an :exc:`~zhmcclient.HTTPError...
[ "def", "wait_for_completion", "(", "self", ",", "operation_timeout", "=", "None", ")", ":", "if", "operation_timeout", "is", "None", ":", "operation_timeout", "=", "self", ".", "session", ".", "retry_timeout_config", ".", "operation_timeout", "if", "operation_timeou...
Wait for completion of the job, then delete the job on the HMC and return the result of the original asynchronous HMC operation, if it completed successfully. If the job completed in error, an :exc:`~zhmcclient.HTTPError` exception is raised. Parameters: operation_ti...
[ "Wait", "for", "completion", "of", "the", "job", "then", "delete", "the", "job", "on", "the", "HMC", "and", "return", "the", "result", "of", "the", "original", "asynchronous", "HMC", "operation", "if", "it", "completed", "successfully", "." ]
python
train