Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
GP_Model.sample_posterior
(self, points, batch_size=1)
Sample functions from gaussian process posterior predictive distribution. Parameters ---------- points : torch.tensor Domain points to be evaluated. batch_size : int Number of samples to draw. Returns ---------- torch.tens...
Sample functions from gaussian process posterior predictive distribution. Parameters ---------- points : torch.tensor Domain points to be evaluated. batch_size : int Number of samples to draw. Returns ---------- torch.tens...
def sample_posterior(self, points, batch_size=1): """Sample functions from gaussian process posterior predictive distribution. Parameters ---------- points : torch.tensor Domain points to be evaluated. batch_size : int Number of samples to draw. ...
[ "def", "sample_posterior", "(", "self", ",", "points", ",", "batch_size", "=", "1", ")", ":", "points", "=", "to_torch", "(", "points", ",", "gpu", "=", "self", ".", "gpu", ")", "# Get into evaluation mode", "self", ".", "model", ".", "eval", "(", ")", ...
[ 204, 4 ]
[ 230, 22 ]
python
en
['en', 'en', 'en']
True
GP_Model.regression
(self, return_data=False, export_path=None, return_scores=False)
Helper method for visualizing the models regression performance. Generates a predicted vs observed plot using the models training data. Parameters ---------- return_data : bool Return predicted responses. export_path : None, str Export SV...
Helper method for visualizing the models regression performance. Generates a predicted vs observed plot using the models training data. Parameters ---------- return_data : bool Return predicted responses. export_path : None, str Export SV...
def regression(self, return_data=False, export_path=None, return_scores=False): """Helper method for visualizing the models regression performance. Generates a predicted vs observed plot using the models training data. Parameters ---------- return_data : bool ...
[ "def", "regression", "(", "self", ",", "return_data", "=", "False", ",", "export_path", "=", "None", ",", "return_scores", "=", "False", ")", ":", "# GPyTorch generates a warning when predicting training data.", "with", "warnings", ".", "catch_warnings", "(", ")", "...
[ 233, 4 ]
[ 273, 52 ]
python
en
['en', 'en', 'en']
True
RF_Model.__init__
(self, X, y, n_jobs=-1, random_state=10, n_estimators=500, max_features='auto', max_depth=None, min_samples_leaf=1, min_samples_split=2, **kwargs)
Parameters ---------- X : list, numpy.array, pandas.DataFrame Domain points to be used for model training. y : list, numpy.array, pandas.DataFrame Response values to be used for model training. n_jobs : int Number of processers to use...
Parameters ---------- X : list, numpy.array, pandas.DataFrame Domain points to be used for model training. y : list, numpy.array, pandas.DataFrame Response values to be used for model training. n_jobs : int Number of processers to use...
def __init__(self, X, y, n_jobs=-1, random_state=10, n_estimators=500, max_features='auto', max_depth=None, min_samples_leaf=1, min_samples_split=2, **kwargs): """ Parameters ---------- X : list, numpy.array, pandas.DataFrame Domain points to be used for mod...
[ "def", "__init__", "(", "self", ",", "X", ",", "y", ",", "n_jobs", "=", "-", "1", ",", "random_state", "=", "10", ",", "n_estimators", "=", "500", ",", "max_features", "=", "'auto'", ",", "max_depth", "=", "None", ",", "min_samples_leaf", "=", "1", "...
[ 283, 4 ]
[ 322, 28 ]
python
en
['en', 'ja', 'th']
False
RF_Model.fit
(self)
Train the frandom forest model.
Train the frandom forest model.
def fit(self): """Train the frandom forest model.""" self.model.fit(self.X, self.y)
[ "def", "fit", "(", "self", ")", ":", "self", ".", "model", ".", "fit", "(", "self", ".", "X", ",", "self", ".", "y", ")" ]
[ 325, 4 ]
[ 328, 38 ]
python
en
['en', 'no', 'en']
True
RF_Model.predict
(self, points)
Mean of the random forest ensemble predictions. Parameters ---------- points : list, numpy.array, pandas.DataFrame Domain points to be evaluated. Returns ---------- numpy.array Predicted response values.
Mean of the random forest ensemble predictions. Parameters ---------- points : list, numpy.array, pandas.DataFrame Domain points to be evaluated. Returns ---------- numpy.array Predicted response values.
def predict(self, points): """Mean of the random forest ensemble predictions. Parameters ---------- points : list, numpy.array, pandas.DataFrame Domain points to be evaluated. Returns ---------- numpy.array Predicted respo...
[ "def", "predict", "(", "self", ",", "points", ")", ":", "# Make sure points in a numpy array", "points", "=", "np", ".", "array", "(", "points", ")", "# Make predicitons", "pred", "=", "self", ".", "model", ".", "predict", "(", "points", ")", "return", "pred...
[ 331, 4 ]
[ 351, 19 ]
python
en
['en', 'en', 'en']
True
RF_Model.regression
(self, return_data=False, export_path=None, return_scores=False)
Helper method for visualizing the models regression performance. Generates a predicted vs observed plot using the models training data. Parameters ---------- return_data : bool Return predicted responses. export_path : None, str Ex...
Helper method for visualizing the models regression performance. Generates a predicted vs observed plot using the models training data. Parameters ---------- return_data : bool Return predicted responses. export_path : None, str Ex...
def regression(self, return_data=False, export_path=None, return_scores=False): """Helper method for visualizing the models regression performance. Generates a predicted vs observed plot using the models training data. Parameters ---------- return_data : ...
[ "def", "regression", "(", "self", ",", "return_data", "=", "False", ",", "export_path", "=", "None", ",", "return_scores", "=", "False", ")", ":", "pred", "=", "self", ".", "predict", "(", "self", ".", "X", ")", "obs", "=", "self", ".", "y", "return"...
[ 354, 4 ]
[ 378, 52 ]
python
en
['en', 'en', 'en']
True
RF_Model.sample_posterior
(self, X, batch_size=1)
Sample weak estimators from the trained random forest model. Parameters ---------- points : numpy.array Domain points to be evaluated. batch_size : int Number of estimators predictions to draw from ensemble. Returns ---------- ...
Sample weak estimators from the trained random forest model. Parameters ---------- points : numpy.array Domain points to be evaluated. batch_size : int Number of estimators predictions to draw from ensemble. Returns ---------- ...
def sample_posterior(self, X, batch_size=1): """Sample weak estimators from the trained random forest model. Parameters ---------- points : numpy.array Domain points to be evaluated. batch_size : int Number of estimators predictions to draw from e...
[ "def", "sample_posterior", "(", "self", ",", "X", ",", "batch_size", "=", "1", ")", ":", "# Make sure points in a numpy array", "X", "=", "np", ".", "array", "(", "X", ")", "n_estimators", "=", "self", ".", "model", ".", "n_estimators", "trees", "=", "np",...
[ 381, 4 ]
[ 410, 32 ]
python
en
['en', 'fy', 'en']
True
RF_Model.variance
(self, points)
Variance of random forest ensemble. Model variance is estimated as the vairance in the individual tree predictions. Parameters ---------- points : numpy.array Domain points to be evaluated. Returns ---------- numpy....
Variance of random forest ensemble. Model variance is estimated as the vairance in the individual tree predictions. Parameters ---------- points : numpy.array Domain points to be evaluated. Returns ---------- numpy....
def variance(self, points): """Variance of random forest ensemble. Model variance is estimated as the vairance in the individual tree predictions. Parameters ---------- points : numpy.array Domain points to be evaluated. Re...
[ "def", "variance", "(", "self", ",", "points", ")", ":", "# Make sure points in a numpy array", "points", "=", "np", ".", "array", "(", "points", ")", "n_estimators", "=", "self", ".", "model", ".", "n_estimators", "samples", "=", "[", "]", "for", "tree", ...
[ 413, 4 ]
[ 442, 18 ]
python
en
['en', 'no', 'en']
True
Bayesian_Linear_Model.__init__
(self, X, y, **kwargs)
Parameters ---------- X : list, numpy.array, pandas.DataFrame Domain points to be used for model training. y : list, numpy.array, pandas.DataFrame Response values to be used for model training.
Parameters ---------- X : list, numpy.array, pandas.DataFrame Domain points to be used for model training. y : list, numpy.array, pandas.DataFrame Response values to be used for model training.
def __init__(self, X, y, **kwargs): """ Parameters ---------- X : list, numpy.array, pandas.DataFrame Domain points to be used for model training. y : list, numpy.array, pandas.DataFrame Response values to be used for model training. """ ...
[ "def", "__init__", "(", "self", ",", "X", ",", "y", ",", "*", "*", "kwargs", ")", ":", "# CV set gamma prior parameters - no GS for now", "self", ".", "alphas", "=", "np", ".", "logspace", "(", "-", "6", ",", "0.5", ",", "7", ")", "# Initialize model", "...
[ 452, 4 ]
[ 470, 28 ]
python
en
['en', 'error', 'th']
False
Bayesian_Linear_Model.fit
(self)
Train the model using grid search CV.
Train the model using grid search CV.
def fit(self): """Train the model using grid search CV.""" parameters = [{'alpha_1': self.alphas, 'alpha_2': self.alphas}] # Set the number of folds if len(self.X) < 5: n_folds = len(self.X) else: n_folds = 5 # Run grid ...
[ "def", "fit", "(", "self", ")", ":", "parameters", "=", "[", "{", "'alpha_1'", ":", "self", ".", "alphas", ",", "'alpha_2'", ":", "self", ".", "alphas", "}", "]", "# Set the number of folds", "if", "len", "(", "self", ".", "X", ")", "<", "5", ":", ...
[ 473, 4 ]
[ 501, 42 ]
python
en
['en', 'en', 'en']
True
Bayesian_Linear_Model.get_scores
(self)
Get grid search cross validation results. Returns ---------- (numpy.array, numpy.array) Average scores and standard deviation of scores for grid.
Get grid search cross validation results. Returns ---------- (numpy.array, numpy.array) Average scores and standard deviation of scores for grid.
def get_scores(self): """Get grid search cross validation results. Returns ---------- (numpy.array, numpy.array) Average scores and standard deviation of scores for grid. """ # Plot results scores = self.grid_search.cv_resul...
[ "def", "get_scores", "(", "self", ")", ":", "# Plot results", "scores", "=", "self", ".", "grid_search", ".", "cv_results_", "[", "'mean_test_score'", "]", "scores_std", "=", "self", ".", "grid_search", ".", "cv_results_", "[", "'std_test_score'", "]", "return",...
[ 503, 4 ]
[ 517, 33 ]
python
en
['sv', 'en', 'en']
True
Bayesian_Linear_Model.predict
(self, points)
Model predictions. Parameters ---------- points : list, numpy.array, pandas.DataFrame Domain points to be evaluated. Returns ---------- numpy.array Predicted response values at points.
Model predictions. Parameters ---------- points : list, numpy.array, pandas.DataFrame Domain points to be evaluated. Returns ---------- numpy.array Predicted response values at points.
def predict(self, points): """Model predictions. Parameters ---------- points : list, numpy.array, pandas.DataFrame Domain points to be evaluated. Returns ---------- numpy.array Predicted response values at points. ...
[ "def", "predict", "(", "self", ",", "points", ")", ":", "# Make sure points in a numpy array", "points", "=", "np", ".", "array", "(", "points", ")", "# Make predicitons", "pred", "=", "self", ".", "model", ".", "predict", "(", "points", ")", "return", "pred...
[ 520, 4 ]
[ 540, 19 ]
python
ca
['ca', 'ca', 'en']
False
Bayesian_Linear_Model.regression
(self, return_data=False, export_path=None, return_scores=False)
Helper method for visualizing the models regression performance. Generates a predicted vs observed plot using the models training data. Parameters ---------- return_data : bool Return predicted responses. export_path : None, str Export SV...
Helper method for visualizing the models regression performance. Generates a predicted vs observed plot using the models training data. Parameters ---------- return_data : bool Return predicted responses. export_path : None, str Export SV...
def regression(self, return_data=False, export_path=None, return_scores=False): """Helper method for visualizing the models regression performance. Generates a predicted vs observed plot using the models training data. Parameters ---------- return_data : bool ...
[ "def", "regression", "(", "self", ",", "return_data", "=", "False", ",", "export_path", "=", "None", ",", "return_scores", "=", "False", ")", ":", "pred", "=", "self", ".", "predict", "(", "self", ".", "X", ")", "obs", "=", "self", ".", "y", "return"...
[ 543, 4 ]
[ 567, 52 ]
python
en
['en', 'en', 'en']
True
Bayesian_Linear_Model.variance
(self, points)
Estimated variance of Bayesian linear model. Parameters ---------- points : numpy.array Domain points to be evaluated. Returns ---------- numpy.array Model variance at points.
Estimated variance of Bayesian linear model. Parameters ---------- points : numpy.array Domain points to be evaluated. Returns ---------- numpy.array Model variance at points.
def variance(self, points): """Estimated variance of Bayesian linear model. Parameters ---------- points : numpy.array Domain points to be evaluated. Returns ---------- numpy.array Model variance at points. """ ...
[ "def", "variance", "(", "self", ",", "points", ")", ":", "# Make sure points in a numpy array", "points", "=", "np", ".", "array", "(", "points", ")", "# Make predicitons", "pred", ",", "std", "=", "self", ".", "model", ".", "predict", "(", "points", ",", ...
[ 570, 4 ]
[ 590, 21 ]
python
en
['en', 'en', 'en']
True
open
(filename)
Load texture from a Quake2 WAL texture file. By default, a Quake2 standard palette is attached to the texture. To override the palette, use the :py:func:`PIL.Image.Image.putpalette()` method. :param filename: WAL file name, or an opened file handle. :returns: An image instance.
Load texture from a Quake2 WAL texture file.
def open(filename): """ Load texture from a Quake2 WAL texture file. By default, a Quake2 standard palette is attached to the texture. To override the palette, use the :py:func:`PIL.Image.Image.putpalette()` method. :param filename: WAL file name, or an opened file handle. :returns: An image i...
[ "def", "open", "(", "filename", ")", ":", "# FIXME: modify to return a WalImageFile instance instead of", "# plain Image object ?", "def", "imopen", "(", "fp", ")", ":", "# read header fields", "header", "=", "fp", ".", "read", "(", "32", "+", "24", "+", "32", "+"...
[ 31, 0 ]
[ 72, 29 ]
python
en
['en', 'error', 'th']
False
send_mail
(subject, message, recipient_list, from_email=None, **kwargs)
Wrapper around Django's EmailMultiAlternatives as done in send_mail(). Custom from_email handling and special Auto-Submitted header.
Wrapper around Django's EmailMultiAlternatives as done in send_mail(). Custom from_email handling and special Auto-Submitted header.
def send_mail(subject, message, recipient_list, from_email=None, **kwargs): """ Wrapper around Django's EmailMultiAlternatives as done in send_mail(). Custom from_email handling and special Auto-Submitted header. """ if not from_email: if hasattr(settings, 'WAGTAILADMIN_NOTIFICATION_FROM_EMA...
[ "def", "send_mail", "(", "subject", ",", "message", ",", "recipient_list", ",", "from_email", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "from_email", ":", "if", "hasattr", "(", "settings", ",", "'WAGTAILADMIN_NOTIFICATION_FROM_EMAIL'", ")", ...
[ 32, 0 ]
[ 61, 22 ]
python
en
['en', 'error', 'th']
False
Notifier.can_handle
(self, instance, **kwargs)
Returns True if the Notifier can handle sending the notification from the instance, otherwise False
Returns True if the Notifier can handle sending the notification from the instance, otherwise False
def can_handle(self, instance, **kwargs): """Returns True if the Notifier can handle sending the notification from the instance, otherwise False""" return isinstance(instance, self.valid_classes)
[ "def", "can_handle", "(", "self", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "return", "isinstance", "(", "instance", ",", "self", ".", "valid_classes", ")" ]
[ 151, 4 ]
[ 153, 55 ]
python
en
['en', 'en', 'en']
True
Notifier.get_valid_recipients
(self, instance, **kwargs)
Returns a set of the final list of recipients for the notification message
Returns a set of the final list of recipients for the notification message
def get_valid_recipients(self, instance, **kwargs): """Returns a set of the final list of recipients for the notification message""" return set()
[ "def", "get_valid_recipients", "(", "self", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "return", "set", "(", ")" ]
[ 155, 4 ]
[ 157, 20 ]
python
en
['en', 'en', 'en']
True
Notifier.get_template_set
(self, instance, **kwargs)
Return a dictionary of template paths for the templates: by default, a text message
Return a dictionary of template paths for the templates: by default, a text message
def get_template_set(self, instance, **kwargs): """Return a dictionary of template paths for the templates: by default, a text message""" template_base = self.get_template_base_prefix(instance) + self.notification template_text = self.template_directory + template_base + '.txt' return ...
[ "def", "get_template_set", "(", "self", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "template_base", "=", "self", ".", "get_template_base_prefix", "(", "instance", ")", "+", "self", ".", "notification", "template_text", "=", "self", ".", "template_dire...
[ 165, 4 ]
[ 173, 9 ]
python
en
['en', 'en', 'en']
True
Notifier.__call__
(self, instance=None, **kwargs)
Send notifications from an instance (intended to be the signal sender), returning True if all sent correctly and False otherwise
Send notifications from an instance (intended to be the signal sender), returning True if all sent correctly and False otherwise
def __call__(self, instance=None, **kwargs): """Send notifications from an instance (intended to be the signal sender), returning True if all sent correctly and False otherwise""" if not self.can_handle(instance, **kwargs): return False recipients = self.get_valid_recipient...
[ "def", "__call__", "(", "self", ",", "instance", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "can_handle", "(", "instance", ",", "*", "*", "kwargs", ")", ":", "return", "False", "recipients", "=", "self", ".", "get_valid...
[ 178, 4 ]
[ 194, 83 ]
python
en
['en', 'en', 'en']
True
EmailNotificationMixin.get_recipient_users
(self, instance, **kwargs)
Gets the ideal set of recipient users, without accounting for notification preferences or missing email addresses
Gets the ideal set of recipient users, without accounting for notification preferences or missing email addresses
def get_recipient_users(self, instance, **kwargs): """Gets the ideal set of recipient users, without accounting for notification preferences or missing email addresses""" return set()
[ "def", "get_recipient_users", "(", "self", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "return", "set", "(", ")" ]
[ 200, 4 ]
[ 203, 20 ]
python
en
['en', 'en', 'en']
True
EmailNotificationMixin.get_valid_recipients
(self, instance, **kwargs)
Filters notification recipients to those allowing the notification type on their UserProfile, and those with an email address
Filters notification recipients to those allowing the notification type on their UserProfile, and those with an email address
def get_valid_recipients(self, instance, **kwargs): """Filters notification recipients to those allowing the notification type on their UserProfile, and those with an email address""" return {recipient for recipient in self.get_recipient_users(instance, **kwargs) if recipient.email and getattr(...
[ "def", "get_valid_recipients", "(", "self", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "return", "{", "recipient", "for", "recipient", "in", "self", ".", "get_recipient_users", "(", "instance", ",", "*", "*", "kwargs", ")", "if", "recipient", ".",...
[ 205, 4 ]
[ 212, 10 ]
python
en
['en', 'en', 'en']
True
EmailNotificationMixin.get_template_set
(self, instance, **kwargs)
Return a dictionary of template paths for the templates for the email subject and the text and html alternatives
Return a dictionary of template paths for the templates for the email subject and the text and html alternatives
def get_template_set(self, instance, **kwargs): """Return a dictionary of template paths for the templates for the email subject and the text and html alternatives""" template_base = self.get_template_base_prefix(instance) + self.notification template_subject = self.template_directory +...
[ "def", "get_template_set", "(", "self", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "template_base", "=", "self", ".", "get_template_base_prefix", "(", "instance", ")", "+", "self", ".", "notification", "template_subject", "=", "self", ".", "template_d...
[ 214, 4 ]
[ 227, 9 ]
python
en
['en', 'en', 'en']
True
EnjoliverConfig.config_override
(self, key: str, default)
Each config attribute pass inside this method to allow override by 1) Environment 2) Yaml And finally use the default passed in argument :param key: :param default: :return:
Each config attribute pass inside this method to allow override by 1) Environment 2) Yaml And finally use the default passed in argument :param key: :param default: :return:
def config_override(self, key: str, default): """ Each config attribute pass inside this method to allow override by 1) Environment 2) Yaml And finally use the default passed in argument :param key: :param default: :return: """ env = "ENJOL...
[ "def", "config_override", "(", "self", ",", "key", ":", "str", ",", "default", ")", ":", "env", "=", "\"ENJOLIVER_%s\"", "%", "key", ".", "upper", "(", ")", "try", ":", "env_var", "=", "os", ".", "environ", "[", "env", "]", "logger", ".", "info", "...
[ 16, 4 ]
[ 39, 26 ]
python
en
['en', 'error', 'th']
False
_get_related_models
(m)
Return all models that have a direct relationship to the given model.
Return all models that have a direct relationship to the given model.
def _get_related_models(m): """ Return all models that have a direct relationship to the given model. """ related_models = [ subclass for subclass in m.__subclasses__() if issubclass(subclass, models.Model) ] related_fields_models = set() for f in m._meta.get_fields(include_p...
[ "def", "_get_related_models", "(", "m", ")", ":", "related_models", "=", "[", "subclass", "for", "subclass", "in", "m", ".", "__subclasses__", "(", ")", "if", "issubclass", "(", "subclass", ",", "models", ".", "Model", ")", "]", "related_fields_models", "=",...
[ 33, 0 ]
[ 51, 25 ]
python
en
['en', 'error', 'th']
False
get_related_models_tuples
(model)
Return a list of typical (app_label, model_name) tuples for all related models for the given model.
Return a list of typical (app_label, model_name) tuples for all related models for the given model.
def get_related_models_tuples(model): """ Return a list of typical (app_label, model_name) tuples for all related models for the given model. """ return { (rel_mod._meta.app_label, rel_mod._meta.model_name) for rel_mod in _get_related_models(model) }
[ "def", "get_related_models_tuples", "(", "model", ")", ":", "return", "{", "(", "rel_mod", ".", "_meta", ".", "app_label", ",", "rel_mod", ".", "_meta", ".", "model_name", ")", "for", "rel_mod", "in", "_get_related_models", "(", "model", ")", "}" ]
[ 54, 0 ]
[ 62, 5 ]
python
en
['en', 'error', 'th']
False
get_related_models_recursive
(model)
Return all models that have a direct or indirect relationship to the given model. Relationships are either defined by explicit relational fields, like ForeignKey, ManyToManyField or OneToOneField, or by inheriting from another model (a superclass is related to its subclasses, but not vice versa). ...
Return all models that have a direct or indirect relationship to the given model.
def get_related_models_recursive(model): """ Return all models that have a direct or indirect relationship to the given model. Relationships are either defined by explicit relational fields, like ForeignKey, ManyToManyField or OneToOneField, or by inheriting from another model (a superclass is ...
[ "def", "get_related_models_recursive", "(", "model", ")", ":", "seen", "=", "set", "(", ")", "queue", "=", "_get_related_models", "(", "model", ")", "for", "rel_mod", "in", "queue", ":", "rel_app_label", ",", "rel_model_name", "=", "rel_mod", ".", "_meta", "...
[ 65, 0 ]
[ 84, 67 ]
python
en
['en', 'error', 'th']
False
ProjectState.clone
(self)
Returns an exact copy of this ProjectState
Returns an exact copy of this ProjectState
def clone(self): "Returns an exact copy of this ProjectState" new_state = ProjectState( models={k: v.clone() for k, v in self.models.items()}, real_apps=self.real_apps, ) if 'apps' in self.__dict__: new_state.apps = self.apps.clone() new_state....
[ "def", "clone", "(", "self", ")", ":", "new_state", "=", "ProjectState", "(", "models", "=", "{", "k", ":", "v", ".", "clone", "(", ")", "for", "k", ",", "v", "in", "self", ".", "models", ".", "items", "(", ")", "}", ",", "real_apps", "=", "sel...
[ 200, 4 ]
[ 209, 24 ]
python
en
['en', 'en', 'en']
True
ProjectState.from_apps
(cls, apps)
Takes in an Apps and returns a ProjectState matching it
Takes in an Apps and returns a ProjectState matching it
def from_apps(cls, apps): "Takes in an Apps and returns a ProjectState matching it" app_models = {} for model in apps.get_models(include_swapped=True): model_state = ModelState.from_model(model) app_models[(model_state.app_label, model_state.name_lower)] = model_state ...
[ "def", "from_apps", "(", "cls", ",", "apps", ")", ":", "app_models", "=", "{", "}", "for", "model", "in", "apps", ".", "get_models", "(", "include_swapped", "=", "True", ")", ":", "model_state", "=", "ModelState", ".", "from_model", "(", "model", ")", ...
[ 225, 4 ]
[ 231, 30 ]
python
en
['en', 'en', 'en']
True
StateApps.clone
(self)
Return a clone of this registry, mainly used by the migration framework.
Return a clone of this registry, mainly used by the migration framework.
def clone(self): """ Return a clone of this registry, mainly used by the migration framework. """ clone = StateApps([], {}) clone.all_models = copy.deepcopy(self.all_models) clone.app_configs = copy.deepcopy(self.app_configs) # Set the pointer to the correct app r...
[ "def", "clone", "(", "self", ")", ":", "clone", "=", "StateApps", "(", "[", "]", ",", "{", "}", ")", "clone", ".", "all_models", "=", "copy", ".", "deepcopy", "(", "self", ".", "all_models", ")", "clone", ".", "app_configs", "=", "copy", ".", "deep...
[ 334, 4 ]
[ 346, 20 ]
python
en
['en', 'error', 'th']
False
ModelState.from_model
(cls, model, exclude_rels=False)
Feed me a model, get a ModelState representing it out.
Feed me a model, get a ModelState representing it out.
def from_model(cls, model, exclude_rels=False): """ Feed me a model, get a ModelState representing it out. """ # Deconstruct the fields fields = [] for field in model._meta.local_fields: if getattr(field, "remote_field", None) and exclude_rels: ...
[ "def", "from_model", "(", "cls", ",", "model", ",", "exclude_rels", "=", "False", ")", ":", "# Deconstruct the fields", "fields", "=", "[", "]", "for", "field", "in", "model", ".", "_meta", ".", "local_fields", ":", "if", "getattr", "(", "field", ",", "\...
[ 418, 4 ]
[ 546, 9 ]
python
en
['en', 'error', 'th']
False
ModelState.construct_managers
(self)
Deep-clone the managers using deconstruction
Deep-clone the managers using deconstruction
def construct_managers(self): "Deep-clone the managers using deconstruction" # Sort all managers by their creation counter sorted_managers = sorted(self.managers, key=lambda v: v[1].creation_counter) for mgr_name, manager in sorted_managers: mgr_name = force_text(mgr_name) ...
[ "def", "construct_managers", "(", "self", ")", ":", "# Sort all managers by their creation counter", "sorted_managers", "=", "sorted", "(", "self", ".", "managers", ",", "key", "=", "lambda", "v", ":", "v", "[", "1", "]", ".", "creation_counter", ")", "for", "...
[ 565, 4 ]
[ 577, 62 ]
python
en
['en', 'en', 'en']
True
ModelState.clone
(self)
Returns an exact copy of this ModelState
Returns an exact copy of this ModelState
def clone(self): "Returns an exact copy of this ModelState" return self.__class__( app_label=self.app_label, name=self.name, fields=list(self.fields), options=dict(self.options), bases=self.bases, managers=list(self.managers), ...
[ "def", "clone", "(", "self", ")", ":", "return", "self", ".", "__class__", "(", "app_label", "=", "self", ".", "app_label", ",", "name", "=", "self", ".", "name", ",", "fields", "=", "list", "(", "self", ".", "fields", ")", ",", "options", "=", "di...
[ 579, 4 ]
[ 588, 9 ]
python
en
['en', 'en', 'en']
True
ModelState.render
(self, apps)
Creates a Model object from our current state into the given apps
Creates a Model object from our current state into the given apps
def render(self, apps): "Creates a Model object from our current state into the given apps" # First, make a Meta object meta_contents = {'app_label': self.app_label, "apps": apps} meta_contents.update(self.options) meta = type(str("Meta"), tuple(), meta_contents) # Then, ...
[ "def", "render", "(", "self", ",", "apps", ")", ":", "# First, make a Meta object", "meta_contents", "=", "{", "'app_label'", ":", "self", ".", "app_label", ",", "\"apps\"", ":", "apps", "}", "meta_contents", ".", "update", "(", "self", ".", "options", ")", ...
[ 590, 4 ]
[ 622, 13 ]
python
en
['en', 'en', 'en']
True
check_flags
(flags: List[str], expected: Set[str])
The has_alert_word flag can be ignored for most tests.
The has_alert_word flag can be ignored for most tests.
def check_flags(flags: List[str], expected: Set[str]) -> None: """ The has_alert_word flag can be ignored for most tests. """ assert "has_alert_word" not in expected flag_set = set(flags) flag_set.discard("has_alert_word") if flag_set != expected: raise AssertionError(f"expected flag...
[ "def", "check_flags", "(", "flags", ":", "List", "[", "str", "]", ",", "expected", ":", "Set", "[", "str", "]", ")", "->", "None", ":", "assert", "\"has_alert_word\"", "not", "in", "expected", "flag_set", "=", "set", "(", "flags", ")", "flag_set", ".",...
[ 32, 0 ]
[ 40, 90 ]
python
en
['en', 'error', 'th']
False
MessageAccessTests.test_change_star
(self)
You can set a message as starred/un-starred through POST /json/messages/flags.
You can set a message as starred/un-starred through POST /json/messages/flags.
def test_change_star(self) -> None: """ You can set a message as starred/un-starred through POST /json/messages/flags. """ self.login("hamlet") message_ids = [ self.send_personal_message( self.example_user("hamlet"), self.example_user("hamlet")...
[ "def", "test_change_star", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "message_ids", "=", "[", "self", ".", "send_personal_message", "(", "self", ".", "example_user", "(", "\"hamlet\"", ")", ",", "self", ".", "exampl...
[ 1033, 4 ]
[ 1061, 48 ]
python
en
['en', 'error', 'th']
False
MessageAccessTests.test_change_star_public_stream_historical
(self)
You can set a message as starred/un-starred through POST /json/messages/flags.
You can set a message as starred/un-starred through POST /json/messages/flags.
def test_change_star_public_stream_historical(self) -> None: """ You can set a message as starred/un-starred through POST /json/messages/flags. """ stream_name = "new_stream" self.subscribe(self.example_user("hamlet"), stream_name) self.login("hamlet") mes...
[ "def", "test_change_star_public_stream_historical", "(", "self", ")", "->", "None", ":", "stream_name", "=", "\"new_stream\"", "self", ".", "subscribe", "(", "self", ".", "example_user", "(", "\"hamlet\"", ")", ",", "stream_name", ")", "self", ".", "login", "(",...
[ 1063, 4 ]
[ 1132, 60 ]
python
en
['en', 'error', 'th']
False
MessageAccessTests.test_change_star_private_message_security
(self)
You can set a message as starred/un-starred through POST /json/messages/flags.
You can set a message as starred/un-starred through POST /json/messages/flags.
def test_change_star_private_message_security(self) -> None: """ You can set a message as starred/un-starred through POST /json/messages/flags. """ self.login("hamlet") message_ids = [ self.send_personal_message( self.example_user("hamlet"), ...
[ "def", "test_change_star_private_message_security", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "message_ids", "=", "[", "self", ".", "send_personal_message", "(", "self", ".", "example_user", "(", "\"hamlet\"", ")", ",", ...
[ 1134, 4 ]
[ 1151, 60 ]
python
en
['en', 'error', 'th']
False
MessageAccessTests.test_new_message
(self)
New messages aren't starred.
New messages aren't starred.
def test_new_message(self) -> None: """ New messages aren't starred. """ sender = self.example_user("hamlet") self.login_user(sender) content = "Test message for star" self.send_stream_message(sender, "Verona", content=content) sent_message = ( ...
[ "def", "test_new_message", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "self", ".", "login_user", "(", "sender", ")", "content", "=", "\"Test message for star\"", "self", ".", "send_stream_message", ...
[ 1191, 4 ]
[ 1208, 52 ]
python
en
['en', 'error', 'th']
False
PersonalMessagesFlagTest.test_is_private_flag_not_leaked
(self)
Make sure `is_private` flag is not leaked to the API.
Make sure `is_private` flag is not leaked to the API.
def test_is_private_flag_not_leaked(self) -> None: """ Make sure `is_private` flag is not leaked to the API. """ self.login("hamlet") self.send_personal_message( self.example_user("hamlet"), self.example_user("cordelia"), "test" ) for msg in self.get_...
[ "def", "test_is_private_flag_not_leaked", "(", "self", ")", "->", "None", ":", "self", ".", "login", "(", "\"hamlet\"", ")", "self", ".", "send_personal_message", "(", "self", ".", "example_user", "(", "\"hamlet\"", ")", ",", "self", ".", "example_user", "(", ...
[ 1375, 4 ]
[ 1385, 56 ]
python
en
['en', 'error', 'th']
False
TestSubmitToWorkflow.test_submit_for_approval_creates_states
(self)
Test that WorkflowState and TaskState objects are correctly created when a Page is submitted for approval
Test that WorkflowState and TaskState objects are correctly created when a Page is submitted for approval
def test_submit_for_approval_creates_states(self): """Test that WorkflowState and TaskState objects are correctly created when a Page is submitted for approval""" self.submit() workflow_state = self.page.current_workflow_state self.assertEqual(type(workflow_state), WorkflowState) ...
[ "def", "test_submit_for_approval_creates_states", "(", "self", ")", ":", "self", ".", "submit", "(", ")", "workflow_state", "=", "self", ".", "page", ".", "current_workflow_state", "self", ".", "assertEqual", "(", "type", "(", "workflow_state", ")", ",", "Workfl...
[ 753, 4 ]
[ 769, 74 ]
python
en
['en', 'en', 'en']
True
TestNotificationPreferences.test_submitted_email_notifications_sent
(self)
Test that 'submitted' notifications for WorkflowState and TaskState are both sent correctly
Test that 'submitted' notifications for WorkflowState and TaskState are both sent correctly
def test_submitted_email_notifications_sent(self): """Test that 'submitted' notifications for WorkflowState and TaskState are both sent correctly""" self.login(self.submitter) self.submit() self.assertEqual(len(mail.outbox), 4) task_submission_emails = [email for email in mail....
[ "def", "test_submitted_email_notifications_sent", "(", "self", ")", ":", "self", ".", "login", "(", "self", ".", "submitter", ")", "self", ".", "submit", "(", ")", "self", ".", "assertEqual", "(", "len", "(", "mail", ".", "outbox", ")", ",", "4", ")", ...
[ 1270, 4 ]
[ 1298, 85 ]
python
en
['en', 'en', 'en']
True
TestNotificationPreferences.test_submitted_email_notifications_superuser_settings
(self)
Test that 'submitted' notifications for WorkflowState and TaskState are not sent to superusers if `WAGTAILADMIN_NOTIFICATION_INCLUDE_SUPERUSERS=False`
Test that 'submitted' notifications for WorkflowState and TaskState are not sent to superusers if `WAGTAILADMIN_NOTIFICATION_INCLUDE_SUPERUSERS=False`
def test_submitted_email_notifications_superuser_settings(self): """Test that 'submitted' notifications for WorkflowState and TaskState are not sent to superusers if `WAGTAILADMIN_NOTIFICATION_INCLUDE_SUPERUSERS=False`""" self.login(self.submitter) self.submit() task_submission_...
[ "def", "test_submitted_email_notifications_superuser_settings", "(", "self", ")", ":", "self", ".", "login", "(", "self", ".", "submitter", ")", "self", ".", "submit", "(", ")", "task_submission_emails", "=", "[", "email", "for", "email", "in", "mail", ".", "o...
[ 1301, 4 ]
[ 1316, 85 ]
python
en
['en', 'en', 'en']
True
TestDisableViews.test_disable_workflow
(self)
Test that deactivating a workflow sets it to inactive and cancels in progress states
Test that deactivating a workflow sets it to inactive and cancels in progress states
def test_disable_workflow(self): """Test that deactivating a workflow sets it to inactive and cancels in progress states""" self.login(self.submitter) self.submit() self.login(self.superuser) self.approve() response = self.client.post(reverse('wagtailadmin_workflows:disa...
[ "def", "test_disable_workflow", "(", "self", ")", ":", "self", ".", "login", "(", "self", ".", "submitter", ")", "self", ".", "submit", "(", ")", "self", ".", "login", "(", "self", ".", "superuser", ")", "self", ".", "approve", "(", ")", "response", ...
[ 1465, 4 ]
[ 1480, 138 ]
python
en
['en', 'en', 'en']
True
TestDisableViews.test_disable_task
(self)
Test that deactivating a task sets it to inactive and cancels in progress states
Test that deactivating a task sets it to inactive and cancels in progress states
def test_disable_task(self): """Test that deactivating a task sets it to inactive and cancels in progress states""" self.login(self.submitter) self.submit() self.login(self.superuser) response = self.client.post(reverse('wagtailadmin_workflows:disable_task', args=(self.task_1.pk...
[ "def", "test_disable_task", "(", "self", ")", ":", "self", ".", "login", "(", "self", ".", "submitter", ")", "self", ".", "submit", "(", ")", "self", ".", "login", "(", "self", ".", "superuser", ")", "response", "=", "self", ".", "client", ".", "post...
[ 1482, 4 ]
[ 1497, 104 ]
python
en
['en', 'en', 'en']
True
BaseSetting.base_queryset
(cls)
Returns a queryset of objects of this type to use as a base for calling get_or_create() on. You can use the `select_related` attribute on your class to specify a list of foreign key field names, which the method will attempt to select additional related-object data for ...
Returns a queryset of objects of this type to use as a base for calling get_or_create() on.
def base_queryset(cls): """ Returns a queryset of objects of this type to use as a base for calling get_or_create() on. You can use the `select_related` attribute on your class to specify a list of foreign key field names, which the method will attempt to select addition...
[ "def", "base_queryset", "(", "cls", ")", ":", "queryset", "=", "cls", ".", "objects", ".", "all", "(", ")", "if", "cls", ".", "select_related", "is", "not", "None", ":", "queryset", "=", "queryset", ".", "select_related", "(", "*", "cls", ".", "select_...
[ 28, 4 ]
[ 44, 23 ]
python
en
['en', 'error', 'th']
False
BaseSetting.for_site
(cls, site)
Get or create an instance of this setting for the site.
Get or create an instance of this setting for the site.
def for_site(cls, site): """ Get or create an instance of this setting for the site. """ queryset = cls.base_queryset() instance, created = queryset.get_or_create(site=site) return instance
[ "def", "for_site", "(", "cls", ",", "site", ")", ":", "queryset", "=", "cls", ".", "base_queryset", "(", ")", "instance", ",", "created", "=", "queryset", ".", "get_or_create", "(", "site", "=", "site", ")", "return", "instance" ]
[ 47, 4 ]
[ 53, 23 ]
python
en
['en', 'error', 'th']
False
BaseSetting.for_request
(cls, request)
Get or create an instance of this model for the request, and cache the result on the request for faster repeat access.
Get or create an instance of this model for the request, and cache the result on the request for faster repeat access.
def for_request(cls, request): """ Get or create an instance of this model for the request, and cache the result on the request for faster repeat access. """ attr_name = cls.get_cache_attr_name() if hasattr(request, attr_name): return getattr(request, attr_nam...
[ "def", "for_request", "(", "cls", ",", "request", ")", ":", "attr_name", "=", "cls", ".", "get_cache_attr_name", "(", ")", "if", "hasattr", "(", "request", ",", "attr_name", ")", ":", "return", "getattr", "(", "request", ",", "attr_name", ")", "site", "=...
[ 56, 4 ]
[ 69, 28 ]
python
en
['en', 'error', 'th']
False
BaseSetting.get_cache_attr_name
(cls)
Returns the name of the attribute that should be used to store a reference to the fetched/created object on a request.
Returns the name of the attribute that should be used to store a reference to the fetched/created object on a request.
def get_cache_attr_name(cls): """ Returns the name of the attribute that should be used to store a reference to the fetched/created object on a request. """ return "_{}.{}".format( cls._meta.app_label, cls._meta.model_name ).lower()
[ "def", "get_cache_attr_name", "(", "cls", ")", ":", "return", "\"_{}.{}\"", ".", "format", "(", "cls", ".", "_meta", ".", "app_label", ",", "cls", ".", "_meta", ".", "model_name", ")", ".", "lower", "(", ")" ]
[ 72, 4 ]
[ 79, 17 ]
python
en
['en', 'error', 'th']
False
BaseSetting.get_page_url
(self, attribute_name, request=None)
Returns the URL of a page referenced by a foreign key (or other attribute) matching the name ``attribute_name``. If the field value is null, or links to something other than a ``Page`` object, an empty string is returned. The result is also cached per-object to facilitate ...
Returns the URL of a page referenced by a foreign key (or other attribute) matching the name ``attribute_name``. If the field value is null, or links to something other than a ``Page`` object, an empty string is returned. The result is also cached per-object to facilitate ...
def get_page_url(self, attribute_name, request=None): """ Returns the URL of a page referenced by a foreign key (or other attribute) matching the name ``attribute_name``. If the field value is null, or links to something other than a ``Page`` object, an empty string is returned. ...
[ "def", "get_page_url", "(", "self", ",", "attribute_name", ",", "request", "=", "None", ")", ":", "if", "attribute_name", "in", "self", ".", "_page_url_cache", ":", "return", "self", ".", "_page_url_cache", "[", "attribute_name", "]", "if", "not", "hasattr", ...
[ 89, 4 ]
[ 118, 18 ]
python
en
['en', 'error', 'th']
False
test_get_roles_list_admin
(organization, get, admin)
Admin can see list of all roles
Admin can see list of all roles
def test_get_roles_list_admin(organization, get, admin): 'Admin can see list of all roles' url = reverse('api:role_list') response = get(url, admin) assert response.status_code == 200 roles = response.data assert roles['count'] > 0
[ "def", "test_get_roles_list_admin", "(", "organization", ",", "get", ",", "admin", ")", ":", "url", "=", "reverse", "(", "'api:role_list'", ")", "response", "=", "get", "(", "url", ",", "admin", ")", "assert", "response", ".", "status_code", "==", "200", "...
[ 19, 0 ]
[ 25, 29 ]
python
en
['en', 'en', 'en']
True
test_get_roles_list_user
(organization, inventory, team, get, user)
Users can see all roles they have access to, but not all roles
Users can see all roles they have access to, but not all roles
def test_get_roles_list_user(organization, inventory, team, get, user): 'Users can see all roles they have access to, but not all roles' this_user = user('user-test_get_roles_list_user') organization.member_role.members.add(this_user) custom_role = Role.objects.create(role_field='custom_role-test_get_ro...
[ "def", "test_get_roles_list_user", "(", "organization", ",", "inventory", ",", "team", ",", "get", ",", "user", ")", ":", "this_user", "=", "user", "(", "'user-test_get_roles_list_user'", ")", "organization", ".", "member_role", ".", "members", ".", "add", "(", ...
[ 29, 0 ]
[ 54, 47 ]
python
en
['en', 'en', 'en']
True
test_cant_create_role
(post, admin)
Ensure we can't create new roles through the api
Ensure we can't create new roles through the api
def test_cant_create_role(post, admin): "Ensure we can't create new roles through the api" # Some day we might want to do this, but until that is speced out, lets # ensure we don't slip up and allow this implicitly through some helper or # another response = post(reverse('api:role_list'), {'name': '...
[ "def", "test_cant_create_role", "(", "post", ",", "admin", ")", ":", "# Some day we might want to do this, but until that is speced out, lets", "# ensure we don't slip up and allow this implicitly through some helper or", "# another", "response", "=", "post", "(", "reverse", "(", "...
[ 83, 0 ]
[ 89, 38 ]
python
en
['en', 'en', 'en']
True
test_cant_delete_role
(delete, admin, inventory)
Ensure we can't delete roles through the api
Ensure we can't delete roles through the api
def test_cant_delete_role(delete, admin, inventory): "Ensure we can't delete roles through the api" # Some day we might want to do this, but until that is speced out, lets # ensure we don't slip up and allow this implicitly through some helper or # another response = delete(reverse('api:role_detail'...
[ "def", "test_cant_delete_role", "(", "delete", ",", "admin", ",", "inventory", ")", ":", "# Some day we might want to do this, but until that is speced out, lets", "# ensure we don't slip up and allow this implicitly through some helper or", "# another", "response", "=", "delete", "(...
[ 93, 0 ]
[ 99, 38 ]
python
en
['en', 'en', 'en']
True
test_user_view_other_user_roles
(organization, inventory, team, get, alice, bob)
Users can see roles for other users, but only the roles that that user has access to see as well
Users can see roles for other users, but only the roles that that user has access to see as well
def test_user_view_other_user_roles(organization, inventory, team, get, alice, bob): 'Users can see roles for other users, but only the roles that that user has access to see as well' organization.member_role.members.add(alice) organization.admin_role.members.add(bob) organization.member_role.members.ad...
[ "def", "test_user_view_other_user_roles", "(", "organization", ",", "inventory", ",", "team", ",", "get", ",", "alice", ",", "bob", ")", ":", "organization", ".", "member_role", ".", "members", ".", "add", "(", "alice", ")", "organization", ".", "admin_role", ...
[ 117, 0 ]
[ 159, 43 ]
python
en
['en', 'en', 'en']
True
test_org_admin_add_user_to_job_template
(post, organization, check_jobtemplate, user)
Tests that a user with permissions to assign/revoke membership to a particular role can do so
Tests that a user with permissions to assign/revoke membership to a particular role can do so
def test_org_admin_add_user_to_job_template(post, organization, check_jobtemplate, user): 'Tests that a user with permissions to assign/revoke membership to a particular role can do so' org_admin = user('org-admin') joe = user('joe') organization.admin_role.members.add(org_admin) assert org_admin i...
[ "def", "test_org_admin_add_user_to_job_template", "(", "post", ",", "organization", ",", "check_jobtemplate", ",", "user", ")", ":", "org_admin", "=", "user", "(", "'org-admin'", ")", "joe", "=", "user", "(", "'joe'", ")", "organization", ".", "admin_role", ".",...
[ 303, 0 ]
[ 313, 48 ]
python
en
['en', 'en', 'en']
True
test_org_admin_remove_user_from_job_template
(post, organization, check_jobtemplate, user)
Tests that a user with permissions to assign/revoke membership to a particular role can do so
Tests that a user with permissions to assign/revoke membership to a particular role can do so
def test_org_admin_remove_user_from_job_template(post, organization, check_jobtemplate, user): 'Tests that a user with permissions to assign/revoke membership to a particular role can do so' org_admin = user('org-admin') joe = user('joe') organization.admin_role.members.add(org_admin) check_jobtempl...
[ "def", "test_org_admin_remove_user_from_job_template", "(", "post", ",", "organization", ",", "check_jobtemplate", ",", "user", ")", ":", "org_admin", "=", "user", "(", "'org-admin'", ")", "joe", "=", "user", "(", "'joe'", ")", "organization", ".", "admin_role", ...
[ 317, 0 ]
[ 328, 52 ]
python
en
['en', 'en', 'en']
True
test_user_fail_to_add_user_to_job_template
(post, organization, check_jobtemplate, user)
Tests that a user without permissions to assign/revoke membership to a particular role cannot do so
Tests that a user without permissions to assign/revoke membership to a particular role cannot do so
def test_user_fail_to_add_user_to_job_template(post, organization, check_jobtemplate, user): 'Tests that a user without permissions to assign/revoke membership to a particular role cannot do so' rando = user('rando') joe = user('joe') assert rando not in check_jobtemplate.admin_role assert joe not ...
[ "def", "test_user_fail_to_add_user_to_job_template", "(", "post", ",", "organization", ",", "check_jobtemplate", ",", "user", ")", ":", "rando", "=", "user", "(", "'rando'", ")", "joe", "=", "user", "(", "'joe'", ")", "assert", "rando", "not", "in", "check_job...
[ 332, 0 ]
[ 344, 52 ]
python
en
['en', 'en', 'en']
True
test_user_fail_to_remove_user_to_job_template
(post, organization, check_jobtemplate, user)
Tests that a user without permissions to assign/revoke membership to a particular role cannot do so
Tests that a user without permissions to assign/revoke membership to a particular role cannot do so
def test_user_fail_to_remove_user_to_job_template(post, organization, check_jobtemplate, user): 'Tests that a user without permissions to assign/revoke membership to a particular role cannot do so' rando = user('rando') joe = user('joe') check_jobtemplate.execute_role.members.add(joe) assert rando ...
[ "def", "test_user_fail_to_remove_user_to_job_template", "(", "post", ",", "organization", ",", "check_jobtemplate", ",", "user", ")", ":", "rando", "=", "user", "(", "'rando'", ")", "joe", "=", "user", "(", "'joe'", ")", "check_jobtemplate", ".", "execute_role", ...
[ 348, 0 ]
[ 361, 48 ]
python
en
['en', 'en', 'en']
True
trim_docstring
(docstring)
Uniformly trim leading/trailing whitespace from docstrings. Based on https://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation
Uniformly trim leading/trailing whitespace from docstrings.
def trim_docstring(docstring): """ Uniformly trim leading/trailing whitespace from docstrings. Based on https://www.python.org/dev/peps/pep-0257/#handling-docstring-indentation """ if not docstring or not docstring.strip(): return '' # Convert tabs to spaces and split into lines lin...
[ "def", "trim_docstring", "(", "docstring", ")", ":", "if", "not", "docstring", "or", "not", "docstring", ".", "strip", "(", ")", ":", "return", "''", "# Convert tabs to spaces and split into lines", "lines", "=", "docstring", ".", "expandtabs", "(", ")", ".", ...
[ 20, 0 ]
[ 32, 37 ]
python
en
['en', 'error', 'th']
False
parse_docstring
(docstring)
Parse out the parts of a docstring. Return (title, body, metadata).
Parse out the parts of a docstring. Return (title, body, metadata).
def parse_docstring(docstring): """ Parse out the parts of a docstring. Return (title, body, metadata). """ docstring = trim_docstring(docstring) parts = re.split(r'\n{2,}', docstring) title = parts[0] if len(parts) == 1: body = '' metadata = {} else: parser = He...
[ "def", "parse_docstring", "(", "docstring", ")", ":", "docstring", "=", "trim_docstring", "(", "docstring", ")", "parts", "=", "re", ".", "split", "(", "r'\\n{2,}'", ",", "docstring", ")", "title", "=", "parts", "[", "0", "]", "if", "len", "(", "parts", ...
[ 35, 0 ]
[ 58, 32 ]
python
en
['en', 'error', 'th']
False
parse_rst
(text, default_reference_context, thing_being_parsed=None)
Convert the string from reST to an XHTML fragment.
Convert the string from reST to an XHTML fragment.
def parse_rst(text, default_reference_context, thing_being_parsed=None): """ Convert the string from reST to an XHTML fragment. """ overrides = { 'doctitle_xform': True, 'initial_header_level': 3, "default_reference_context": default_reference_context, "link_base": revers...
[ "def", "parse_rst", "(", "text", ",", "default_reference_context", ",", "thing_being_parsed", "=", "None", ")", ":", "overrides", "=", "{", "'doctitle_xform'", ":", "True", ",", "'initial_header_level'", ":", "3", ",", "\"default_reference_context\"", ":", "default_...
[ 61, 0 ]
[ 89, 39 ]
python
en
['en', 'error', 'th']
False
replace_named_groups
(pattern)
r""" Find named groups in `pattern` and replace them with the group name. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^<a>/b/(\w+)$ 2. ^(?P<a>\w+)/b/(?P<c>\w+)/$ ==> ^<a>/b/<c>/$
r""" Find named groups in `pattern` and replace them with the group name. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^<a>/b/(\w+)$ 2. ^(?P<a>\w+)/b/(?P<c>\w+)/$ ==> ^<a>/b/<c>/$
def replace_named_groups(pattern): r""" Find named groups in `pattern` and replace them with the group name. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^<a>/b/(\w+)$ 2. ^(?P<a>\w+)/b/(?P<c>\w+)/$ ==> ^<a>/b/<c>/$ """ named_group_indices = [ (m.start(0), m.end(0), m.group(1)) for m in name...
[ "def", "replace_named_groups", "(", "pattern", ")", ":", "named_group_indices", "=", "[", "(", "m", ".", "start", "(", "0", ")", ",", "m", ".", "end", "(", "0", ")", ",", "m", ".", "group", "(", "1", ")", ")", "for", "m", "in", "named_group_matcher...
[ 152, 0 ]
[ 186, 18 ]
python
cy
['en', 'cy', 'hi']
False
replace_unnamed_groups
(pattern)
r""" Find unnamed groups in `pattern` and replace them with '<var>'. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^(?P<a>\w+)/b/<var>$ 2. ^(?P<a>\w+)/b/((x|y)\w+)$ ==> ^(?P<a>\w+)/b/<var>$
r""" Find unnamed groups in `pattern` and replace them with '<var>'. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^(?P<a>\w+)/b/<var>$ 2. ^(?P<a>\w+)/b/((x|y)\w+)$ ==> ^(?P<a>\w+)/b/<var>$
def replace_unnamed_groups(pattern): r""" Find unnamed groups in `pattern` and replace them with '<var>'. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^(?P<a>\w+)/b/<var>$ 2. ^(?P<a>\w+)/b/((x|y)\w+)$ ==> ^(?P<a>\w+)/b/<var>$ """ unnamed_group_indices = [m.start(0) for m in unnamed_group_matcher.finditer(p...
[ "def", "replace_unnamed_groups", "(", "pattern", ")", ":", "unnamed_group_indices", "=", "[", "m", ".", "start", "(", "0", ")", "for", "m", "in", "unnamed_group_matcher", ".", "finditer", "(", "pattern", ")", "]", "# Indices of the start of unnamed capture groups.",...
[ 189, 0 ]
[ 236, 22 ]
python
cy
['en', 'cy', 'hi']
False
touch
(path)
create an empty file, or append :param path: the path of the file to create.
create an empty file, or append :param path: the path of the file to create.
def touch(path): """ create an empty file, or append :param path: the path of the file to create. """ with open(path, 'a') as f: f.close()
[ "def", "touch", "(", "path", ")", ":", "with", "open", "(", "path", ",", "'a'", ")", "as", "f", ":", "f", ".", "close", "(", ")" ]
[ 21, 0 ]
[ 27, 17 ]
python
en
['en', 'error', 'th']
False
GestureHistoryManager.add_recognizer_result
(self, result, *l)
The result object is a ProgressTracker with additional data; in main.py it is tagged with the original GestureContainer that was analyzed (._gesture_obj)
The result object is a ProgressTracker with additional data; in main.py it is tagged with the original GestureContainer that was analyzed (._gesture_obj)
def add_recognizer_result(self, result, *l): '''The result object is a ProgressTracker with additional data; in main.py it is tagged with the original GestureContainer that was analyzed (._gesture_obj)''' # Create a GestureVisualizer that draws the gesture on canvas visualizer =...
[ "def", "add_recognizer_result", "(", "self", ",", "result", ",", "*", "l", ")", ":", "# Create a GestureVisualizer that draws the gesture on canvas", "visualizer", "=", "GestureVisualizer", "(", "result", ".", "_gesture_obj", ",", "size_hint", "=", "(", "None", ",", ...
[ 120, 4 ]
[ 139, 48 ]
python
en
['en', 'en', 'en']
True
Label.silent_delete
(self)
Label pages do not support DELETE requests. Here, we override the base page object silent_delete method to account for this.
Label pages do not support DELETE requests. Here, we override the base page object silent_delete method to account for this.
def silent_delete(self): """Label pages do not support DELETE requests. Here, we override the base page object silent_delete method to account for this. """ pass
[ "def", "silent_delete", "(", "self", ")", ":", "pass" ]
[ 13, 4 ]
[ 17, 12 ]
python
en
['en', 'en', 'en']
True
ImageData.__init__
(self, data, beam, wcs, margin=0, radius=0, back_size_x=32, back_size_y=32, residuals=True )
Sets up an ImageData object. *Args:* - data (2D numpy.ndarray): actual image data - wcs (utility.coordinates.wcs): world coordinate system specification - beam (3-tuple): beam shape specification as (semimajor, semiminor, theta)
Sets up an ImageData object.
def __init__(self, data, beam, wcs, margin=0, radius=0, back_size_x=32, back_size_y=32, residuals=True ): """Sets up an ImageData object. *Args:* - data (2D numpy.ndarray): actual image data - wcs (utility.coordinates.wcs): world coordinate system sp...
[ "def", "__init__", "(", "self", ",", "data", ",", "beam", ",", "wcs", ",", "margin", "=", "0", ",", "radius", "=", "0", ",", "back_size_x", "=", "32", ",", "back_size_y", "=", "32", ",", "residuals", "=", "True", ")", ":", "# Do data, wcs and beam need...
[ 41, 4 ]
[ 71, 34 ]
python
en
['en', 'en', 'en']
True
ImageData._grids
(self)
Gridded RMS and background data for interpolating
Gridded RMS and background data for interpolating
def _grids(self): """Gridded RMS and background data for interpolating""" return self.__grids()
[ "def", "_grids", "(", "self", ")", ":", "return", "self", ".", "__grids", "(", ")" ]
[ 89, 4 ]
[ 91, 29 ]
python
en
['en', 'en', 'en']
True
ImageData._backmap
(self)
Background map
Background map
def _backmap(self): """Background map""" if not hasattr(self, "_user_backmap"): return self._interpolate(self.grids['bg']) else: return self._user_backmap
[ "def", "_backmap", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"_user_backmap\"", ")", ":", "return", "self", ".", "_interpolate", "(", "self", ".", "grids", "[", "'bg'", "]", ")", "else", ":", "return", "self", ".", "_user_backm...
[ 95, 4 ]
[ 100, 37 ]
python
en
['de', 'en', 'en']
False
ImageData._get_data
(self)
Masked image data
Masked image data
def _get_data(self): """Masked image data""" # We will ignore all the data which is masked for the rest of the # sourcefinding process. We build up the mask by stacking ("or-ing # together") a number of different effects: # # * A margin from the edge of the image; ...
[ "def", "_get_data", "(", "self", ")", ":", "# We will ignore all the data which is masked for the rest of the", "# sourcefinding process. We build up the mask by stacking (\"or-ing", "# together\") a number of different effects:", "#", "# * A margin from the edge of the image;", "# * Any data ...
[ 124, 4 ]
[ 142, 54 ]
python
en
['en', 'zu', 'en']
True
ImageData._get_data_bgsubbed
(self)
Background subtracted masked image data
Background subtracted masked image data
def _get_data_bgsubbed(self): """Background subtracted masked image data""" return self.data - self.backmap
[ "def", "_get_data_bgsubbed", "(", "self", ")", ":", "return", "self", ".", "data", "-", "self", ".", "backmap" ]
[ 146, 4 ]
[ 148, 39 ]
python
en
['en', 'en', 'en']
True
ImageData.xdim
(self)
X pixel dimension of (unmasked) data
X pixel dimension of (unmasked) data
def xdim(self): """X pixel dimension of (unmasked) data""" return self.rawdata.shape[0]
[ "def", "xdim", "(", "self", ")", ":", "return", "self", ".", "rawdata", ".", "shape", "[", "0", "]" ]
[ 153, 4 ]
[ 155, 36 ]
python
en
['en', 'en', 'en']
True
ImageData.ydim
(self)
Y pixel dimension of (unmasked) data
Y pixel dimension of (unmasked) data
def ydim(self): """Y pixel dimension of (unmasked) data""" return self.rawdata.shape[1]
[ "def", "ydim", "(", "self", ")", ":", "return", "self", ".", "rawdata", ".", "shape", "[", "1", "]" ]
[ 158, 4 ]
[ 160, 36 ]
python
en
['en', 'da', 'en']
True
ImageData.pixmax
(self)
Maximum pixel value (pre-background subtraction)
Maximum pixel value (pre-background subtraction)
def pixmax(self): """Maximum pixel value (pre-background subtraction)""" return self.data.max()
[ "def", "pixmax", "(", "self", ")", ":", "return", "self", ".", "data", ".", "max", "(", ")" ]
[ 163, 4 ]
[ 165, 30 ]
python
de
['de', 'fr', 'ur']
False
ImageData.pixmin
(self)
Minimum pixel value (pre-background subtraction)
Minimum pixel value (pre-background subtraction)
def pixmin(self): """Minimum pixel value (pre-background subtraction)""" return self.data.min()
[ "def", "pixmin", "(", "self", ")", ":", "return", "self", ".", "data", ".", "min", "(", ")" ]
[ 168, 4 ]
[ 170, 30 ]
python
de
['de', 'fr', 'en']
False
ImageData.clearcache
(self)
Zap any calculated data stored in this object. Clear the background and rms maps, labels, clip, and any locally held data. All of these can be reconstructed from the data accessor. Note that this *must* be run to pick up any new settings.
Zap any calculated data stored in this object.
def clearcache(self): """Zap any calculated data stored in this object. Clear the background and rms maps, labels, clip, and any locally held data. All of these can be reconstructed from the data accessor. Note that this *must* be run to pick up any new settings. """ se...
[ "def", "clearcache", "(", "self", ")", ":", "self", ".", "labels", ".", "clear", "(", ")", "self", ".", "clip", ".", "clear", "(", ")", "del", "(", "self", ".", "backmap", ")", "del", "(", "self", ".", "rmsmap", ")", "del", "(", "self", ".", "d...
[ 172, 4 ]
[ 190, 47 ]
python
en
['en', 'en', 'en']
True
ImageData.__grids
(self)
Calculate background and RMS grids of this image. These grids can be interpolated up to make maps of the original image dimensions: see _interpolate(). This is called automatically when ImageData.backmap, ImageData.rmsmap or ImageData.fdrmap is first accessed.
Calculate background and RMS grids of this image.
def __grids(self): """Calculate background and RMS grids of this image. These grids can be interpolated up to make maps of the original image dimensions: see _interpolate(). This is called automatically when ImageData.backmap, ImageData.rmsmap or ImageData.fdrmap is first acces...
[ "def", "__grids", "(", "self", ")", ":", "# We set up a dedicated logging subchannel, as the sigmaclip loop", "# logging is very chatty:", "sigmaclip_logger", "=", "logging", ".", "getLogger", "(", "__name__", "+", "'.sigmaclip'", ")", "# there's no point in working with the whol...
[ 203, 4 ]
[ 268, 45 ]
python
en
['en', 'en', 'en']
True
ImageData._interpolate
(self, grid, roundup=False)
Interpolate a grid to produce a map of the dimensions of the image. Args: grid (numpy.ma.MaskedArray) Kwargs: roundup (bool) Returns: (numpy.ma.MaskedArray) Used to transform the RMS, background or FDR grids produced by L{_grids...
Interpolate a grid to produce a map of the dimensions of the image.
def _interpolate(self, grid, roundup=False): """ Interpolate a grid to produce a map of the dimensions of the image. Args: grid (numpy.ma.MaskedArray) Kwargs: roundup (bool) Returns: (numpy.ma.MaskedArray) Used to transform the R...
[ "def", "_interpolate", "(", "self", ",", "grid", ",", "roundup", "=", "False", ")", ":", "# there's no point in working with the whole of the data array if it's", "# masked.", "useful_chunk", "=", "ndimage", ".", "find_objects", "(", "numpy", ".", "where", "(", "self"...
[ 270, 4 ]
[ 342, 21 ]
python
en
['en', 'error', 'th']
False
ImageData.extract
(self, det, anl, noisemap=None, bgmap=None, labelled_data=None, labels=None, deblend_nthresh=0, force_beam=False)
Kick off conventional (ie, RMS island finding) source extraction. Kwargs: det (float): detection threshold, as a multiple of the RMS noise. At least one pixel in a source must exceed this for it to be regarded as significant. anl (float): analy...
Kick off conventional (ie, RMS island finding) source extraction.
def extract(self, det, anl, noisemap=None, bgmap=None, labelled_data=None, labels=None, deblend_nthresh=0, force_beam=False): """ Kick off conventional (ie, RMS island finding) source extraction. Kwargs: det (float): detection threshold, as a multiple of the RMS ...
[ "def", "extract", "(", "self", ",", "det", ",", "anl", ",", "noisemap", "=", "None", ",", "bgmap", "=", "None", ",", "labelled_data", "=", "None", ",", "labels", "=", "None", ",", "deblend_nthresh", "=", "0", ",", "force_beam", "=", "False", ")", ":"...
[ 353, 4 ]
[ 416, 9 ]
python
en
['en', 'error', 'th']
False
ImageData.reverse_se
(self, det)
Run source extraction on the negative of this image. Obviously, there should be no sources in the negative image, so this tells you about the false positive rate. We need to clear cached data -- backgroung map, cached clips, etc -- before & after doing this, as they'll interfere with t...
Run source extraction on the negative of this image.
def reverse_se(self, det): """Run source extraction on the negative of this image. Obviously, there should be no sources in the negative image, so this tells you about the false positive rate. We need to clear cached data -- backgroung map, cached clips, etc -- before & after d...
[ "def", "reverse_se", "(", "self", ",", "det", ")", ":", "self", ".", "labels", ".", "clear", "(", ")", "self", ".", "clip", ".", "clear", "(", ")", "self", ".", "data_bgsubbed", "*=", "-", "1", "results", "=", "self", ".", "extract", "(", "det", ...
[ 418, 4 ]
[ 436, 22 ]
python
en
['en', 'en', 'en']
True
ImageData.fd_extract
(self, alpha, anl=None, noisemap=None, bgmap=None, deblend_nthresh=0, force_beam=False )
False Detection Rate based source extraction. The FDR procedure guarantees that <FDR> < alpha. See `Hopkins et al., AJ, 123, 1086 (2002) <http://adsabs.harvard.edu/abs/2002AJ....123.1086H>`_.
False Detection Rate based source extraction. The FDR procedure guarantees that <FDR> < alpha.
def fd_extract(self, alpha, anl=None, noisemap=None, bgmap=None, deblend_nthresh=0, force_beam=False ): """False Detection Rate based source extraction. The FDR procedure guarantees that <FDR> < alpha. See `Hopkins et al., AJ, 123, 1086 (2002) <http://adsabs.harva...
[ "def", "fd_extract", "(", "self", ",", "alpha", ",", "anl", "=", "None", ",", "noisemap", "=", "None", ",", "bgmap", "=", "None", ",", "deblend_nthresh", "=", "0", ",", "force_beam", "=", "False", ")", ":", "# The correlation length in config.py is used not on...
[ 438, 4 ]
[ 500, 54 ]
python
en
['en', 'en', 'en']
True
ImageData.flux_at_pixel
(self, x, y, numpix=1)
Return the background-subtracted flux at a certain position in the map
Return the background-subtracted flux at a certain position in the map
def flux_at_pixel(self, x, y, numpix=1): """Return the background-subtracted flux at a certain position in the map""" # numpix is the number of pixels to look around the target. # e.g. numpix = 1 means a total of 9 pixels, 1 in each direction. return self.data_bgsubbed[y-numpix:...
[ "def", "flux_at_pixel", "(", "self", ",", "x", ",", "y", ",", "numpix", "=", "1", ")", ":", "# numpix is the number of pixels to look around the target.", "# e.g. numpix = 1 means a total of 9 pixels, 1 in each direction.", "return", "self", ".", "data_bgsubbed", "[", "y", ...
[ 502, 4 ]
[ 509, 60 ]
python
en
['en', 'en', 'en']
True
ImageData.box_slice_about_pixel
(x, y, box_radius)
Returns a slice centred about (x,y), of width = 2*int(box_radius) + 1
Returns a slice centred about (x,y), of width = 2*int(box_radius) + 1
def box_slice_about_pixel(x, y, box_radius): """ Returns a slice centred about (x,y), of width = 2*int(box_radius) + 1 """ ibr = int(box_radius) x = int(x) y = int(y) return (slice(x - ibr, x + ibr + 1), slice(y - ibr, y + ibr + 1))
[ "def", "box_slice_about_pixel", "(", "x", ",", "y", ",", "box_radius", ")", ":", "ibr", "=", "int", "(", "box_radius", ")", "x", "=", "int", "(", "x", ")", "y", "=", "int", "(", "y", ")", "return", "(", "slice", "(", "x", "-", "ibr", ",", "x", ...
[ 512, 4 ]
[ 520, 44 ]
python
en
['en', 'error', 'th']
False
ImageData.fit_to_point
(self, x, y, boxsize, threshold, fixed)
Fit an elliptical Gaussian to a specified point on the image. The fit is carried on a square section of the image, of length *boxsize* & centred at pixel coordinates *x*, *y*. Any data below *threshold* * rmsmap is not used for fitting. If *fixed* is set to ``position``, then the pixel ...
Fit an elliptical Gaussian to a specified point on the image.
def fit_to_point(self, x, y, boxsize, threshold, fixed): """Fit an elliptical Gaussian to a specified point on the image. The fit is carried on a square section of the image, of length *boxsize* & centred at pixel coordinates *x*, *y*. Any data below *threshold* * rmsmap is not used for...
[ "def", "fit_to_point", "(", "self", ",", "x", ",", "y", ",", "boxsize", ",", "threshold", ",", "fixed", ")", ":", "logger", ".", "debug", "(", "\"Force-fitting pixel location ({},{})\"", ".", "format", "(", "x", ",", "y", ")", ")", "# First, check that x and...
[ 522, 4 ]
[ 641, 51 ]
python
en
['en', 'en', 'en']
True
ImageData.fit_fixed_positions
(self, positions, boxsize, threshold=None, fixed='position+shape', ids=None)
Convenience function to fit a list of sources at the given positions This function wraps around fit_to_point(). Args: positions (tuple): list of (RA, Dec) tuples. Positions to be fit, in decimal degrees. boxsize: See :py:func:`fit_to_point` ...
Convenience function to fit a list of sources at the given positions
def fit_fixed_positions(self, positions, boxsize, threshold=None, fixed='position+shape', ids=None): """ Convenience function to fit a list of sources at the given positions This function wraps around fit_to_point(). Args: ...
[ "def", "fit_fixed_positions", "(", "self", ",", "positions", ",", "boxsize", ",", "threshold", "=", "None", ",", "fixed", "=", "'position+shape'", ",", "ids", "=", "None", ")", ":", "if", "ids", "is", "not", "None", ":", "assert", "len", "(", "ids", ")...
[ 643, 4 ]
[ 712, 30 ]
python
en
['en', 'error', 'th']
False
ImageData.label_islands
(self, detectionthresholdmap, analysisthresholdmap)
Return a lablled array of pixels for fitting. Args: detectionthresholdmap (numpy.ndarray): analysisthresholdmap (numpy.ndarray): Returns: list of valid islands (list of int) labelled islands (numpy.ndarray)
Return a lablled array of pixels for fitting.
def label_islands(self, detectionthresholdmap, analysisthresholdmap): """ Return a lablled array of pixels for fitting. Args: detectionthresholdmap (numpy.ndarray): analysisthresholdmap (numpy.ndarray): Returns: list of valid islands (list of int)...
[ "def", "label_islands", "(", "self", ",", "detectionthresholdmap", ",", "analysisthresholdmap", ")", ":", "# If there is no usable data, we return an empty set of islands.", "if", "not", "len", "(", "self", ".", "rmsmap", ".", "compressed", "(", ")", ")", ":", "loggin...
[ 714, 4 ]
[ 793, 50 ]
python
en
['en', 'error', 'th']
False
ImageData._pyse
( self, detectionthresholdmap, analysisthresholdmap, deblend_nthresh, force_beam, labelled_data=None, labels=[] )
Run Python-based source extraction on this image. Args: detectionthresholdmap (numpy.ndarray): analysisthresholdmap (numpy.ndarray): deblend_nthresh (int): number of subthresholds for deblending. 0 disables. force_beam (bool): force a...
Run Python-based source extraction on this image.
def _pyse( self, detectionthresholdmap, analysisthresholdmap, deblend_nthresh, force_beam, labelled_data=None, labels=[] ): """ Run Python-based source extraction on this image. Args: detectionthresholdmap (numpy.ndarray): analysisthresholdmap (nump...
[ "def", "_pyse", "(", "self", ",", "detectionthresholdmap", ",", "analysisthresholdmap", ",", "deblend_nthresh", ",", "force_beam", ",", "labelled_data", "=", "None", ",", "labels", "=", "[", "]", ")", ":", "# Map our chunks onto a list of islands.", "island_list", "...
[ 796, 4 ]
[ 950, 71 ]
python
en
['en', 'error', 'th']
False
EngineModule.prepare
(self)
Preparation stage, at which configuration is being read, configs and tools being prepared. All long preparations and checks should be made here, to make `startup` stage as fast as possible.
Preparation stage, at which configuration is being read, configs and tools being prepared. All long preparations and checks should be made here, to make `startup` stage as fast as possible.
def prepare(self): """ Preparation stage, at which configuration is being read, configs and tools being prepared. All long preparations and checks should be made here, to make `startup` stage as fast as possible. """ pass
[ "def", "prepare", "(", "self", ")", ":", "pass" ]
[ 49, 4 ]
[ 55, 12 ]
python
en
['en', 'error', 'th']
False
EngineModule.startup
(self)
Startup should be as fast as possible. Launch background processes, do some API calls for initiation of actual work. Consider making all checks and preparations on `prepare` stage.
Startup should be as fast as possible. Launch background processes, do some API calls for initiation of actual work. Consider making all checks and preparations on `prepare` stage.
def startup(self): """ Startup should be as fast as possible. Launch background processes, do some API calls for initiation of actual work. Consider making all checks and preparations on `prepare` stage. """ pass
[ "def", "startup", "(", "self", ")", ":", "pass" ]
[ 57, 4 ]
[ 63, 12 ]
python
en
['en', 'error', 'th']
False
EngineModule.check
(self)
Check if work should be finished :rtype: bool :return: True if should be finished
Check if work should be finished
def check(self): """ Check if work should be finished :rtype: bool :return: True if should be finished """ return False
[ "def", "check", "(", "self", ")", ":", "return", "False" ]
[ 65, 4 ]
[ 72, 20 ]
python
en
['en', 'error', 'th']
False
EngineModule.shutdown
(self)
Stop all processes that were started in `startup` stage. Should also be as fast as possible, deferring all long operations to `post_process` stage.
Stop all processes that were started in `startup` stage. Should also be as fast as possible, deferring all long operations to `post_process` stage.
def shutdown(self): """ Stop all processes that were started in `startup` stage. Should also be as fast as possible, deferring all long operations to `post_process` stage. """ pass
[ "def", "shutdown", "(", "self", ")", ":", "pass" ]
[ 74, 4 ]
[ 80, 12 ]
python
en
['en', 'error', 'th']
False
EngineModule.post_process
(self)
Do all possibly long analysis and processing on run results
Do all possibly long analysis and processing on run results
def post_process(self): """ Do all possibly long analysis and processing on run results """ pass
[ "def", "post_process", "(", "self", ")", ":", "pass" ]
[ 82, 4 ]
[ 86, 12 ]
python
en
['en', 'error', 'th']
False
EngineModule._should_run
(self)
Returns True if provisioning matches run-at
Returns True if provisioning matches run-at
def _should_run(self): """ Returns True if provisioning matches run-at """ prov = self.engine.config.get(Provisioning.PROV) runat = self.parameters.get("run-at", None) if runat is not None and prov != runat: self.log.debug("Should not run because of non-matchi...
[ "def", "_should_run", "(", "self", ")", ":", "prov", "=", "self", ".", "engine", ".", "config", ".", "get", "(", "Provisioning", ".", "PROV", ")", "runat", "=", "self", ".", "parameters", ".", "get", "(", "\"run-at\"", ",", "None", ")", "if", "runat"...
[ 88, 4 ]
[ 97, 19 ]
python
en
['en', 'error', 'th']
False
Provisioning.prepare
(self)
Preparation in provisioning begins with reading executions list and instantiating ScenarioExecutor classes for them
Preparation in provisioning begins with reading executions list and instantiating ScenarioExecutor classes for them
def prepare(self): """ Preparation in provisioning begins with reading executions list and instantiating ScenarioExecutor classes for them """ super(Provisioning, self).prepare() exc = TaurusConfigError("No 'execution' is configured. Did you forget to pass config files?"...
[ "def", "prepare", "(", "self", ")", ":", "super", "(", "Provisioning", ",", "self", ")", ".", "prepare", "(", ")", "exc", "=", "TaurusConfigError", "(", "\"No 'execution' is configured. Did you forget to pass config files?\"", ")", "executions", "=", "self", ".", ...
[ 117, 4 ]
[ 133, 43 ]
python
en
['en', 'error', 'th']
False
ScenarioExecutor.get_script_path
(self, required=False, scenario=None)
:type required: bool :type scenario: Scenario
:type required: bool :type scenario: Scenario
def get_script_path(self, required=False, scenario=None): """ :type required: bool :type scenario: Scenario """ if scenario is None: scenario = self.get_scenario() if required: exc = TaurusConfigError("You must provide script for %s" % self) ...
[ "def", "get_script_path", "(", "self", ",", "required", "=", "False", ",", "scenario", "=", "None", ")", ":", "if", "scenario", "is", "None", ":", "scenario", "=", "self", ".", "get_scenario", "(", ")", "if", "required", ":", "exc", "=", "TaurusConfigErr...
[ 211, 4 ]
[ 229, 21 ]
python
en
['en', 'error', 'th']
False
ScenarioExecutor.get_scenario
(self, name=None)
Returns scenario dict, extract if scenario is inlined :return: DictOfDicts
Returns scenario dict, extract if scenario is inlined
def get_scenario(self, name=None): """ Returns scenario dict, extract if scenario is inlined :return: DictOfDicts """ if name is None and self._cached_scenario is not None: return self._cached_scenario scenarios = self.engine.config.get("scenarios", force_se...
[ "def", "get_scenario", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", "and", "self", ".", "_cached_scenario", "is", "not", "None", ":", "return", "self", ".", "_cached_scenario", "scenarios", "=", "self", ".", "engine", ".",...
[ 231, 4 ]
[ 264, 27 ]
python
en
['en', 'error', 'th']
False
ScenarioExecutor.get_load
(self)
Helper method to read load specification
Helper method to read load specification
def get_load(self): """ Helper method to read load specification """ def eval_int(value): try: return int(value) except (ValueError, TypeError): return value def eval_float(value): try: return i...
[ "def", "get_load", "(", "self", ")", ":", "def", "eval_int", "(", "value", ")", ":", "try", ":", "return", "int", "(", "value", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "return", "value", "def", "eval_float", "(", "value", ")", "...
[ 355, 4 ]
[ 409, 83 ]
python
en
['en', 'error', 'th']
False
parse_signature
(signature)
Breaks 'func(address)(uint256)' into ['func', '(address)', '(uint256)']
Breaks 'func(address)(uint256)' into ['func', '(address)', '(uint256)']
def parse_signature(signature): """ Breaks 'func(address)(uint256)' into ['func', '(address)', '(uint256)'] """ parts = [] stack = [] start = 0 for end, letter in enumerate(signature): if letter == '(': stack.append(letter) if not parts: parts....
[ "def", "parse_signature", "(", "signature", ")", ":", "parts", "=", "[", "]", "stack", "=", "[", "]", "start", "=", "0", "for", "end", ",", "letter", "in", "enumerate", "(", "signature", ")", ":", "if", "letter", "==", "'('", ":", "stack", ".", "ap...
[ 4, 0 ]
[ 22, 16 ]
python
en
['en', 'error', 'th']
False
LutBuilder._string_permute
(self, pattern, permutation)
string_permute takes a pattern and a permutation and returns the string permuted according to the permutation list.
string_permute takes a pattern and a permutation and returns the string permuted according to the permutation list.
def _string_permute(self, pattern, permutation): """string_permute takes a pattern and a permutation and returns the string permuted according to the permutation list. """ assert len(permutation) == 9 return "".join(pattern[p] for p in permutation)
[ "def", "_string_permute", "(", "self", ",", "pattern", ",", "permutation", ")", ":", "assert", "len", "(", "permutation", ")", "==", "9", "return", "\"\"", ".", "join", "(", "pattern", "[", "p", "]", "for", "p", "in", "permutation", ")" ]
[ 98, 4 ]
[ 103, 55 ]
python
en
['en', 'en', 'en']
True