id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
228,200
SheffieldML/GPyOpt
GPyOpt/interface/driver.py
BODriver._get_acq_evaluator
def _get_acq_evaluator(self, acq): """ Imports the evaluator """ from ..core.evaluators import select_evaluator from copy import deepcopy eval_args = deepcopy(self.config['acquisition']['evaluator']) del eval_args['type'] return select_evaluator(self.conf...
python
def _get_acq_evaluator(self, acq): """ Imports the evaluator """ from ..core.evaluators import select_evaluator from copy import deepcopy eval_args = deepcopy(self.config['acquisition']['evaluator']) del eval_args['type'] return select_evaluator(self.conf...
[ "def", "_get_acq_evaluator", "(", "self", ",", "acq", ")", ":", "from", ".", ".", "core", ".", "evaluators", "import", "select_evaluator", "from", "copy", "import", "deepcopy", "eval_args", "=", "deepcopy", "(", "self", ".", "config", "[", "'acquisition'", "...
Imports the evaluator
[ "Imports", "the", "evaluator" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L73-L82
228,201
SheffieldML/GPyOpt
GPyOpt/interface/driver.py
BODriver._check_stop
def _check_stop(self, iters, elapsed_time, converged): """ Defines the stopping criterion. """ r_c = self.config['resources'] stop = False if converged==0: stop=True if r_c['maximum-iterations'] !='NA' and iters>= r_c['maximum-iterations']: ...
python
def _check_stop(self, iters, elapsed_time, converged): """ Defines the stopping criterion. """ r_c = self.config['resources'] stop = False if converged==0: stop=True if r_c['maximum-iterations'] !='NA' and iters>= r_c['maximum-iterations']: ...
[ "def", "_check_stop", "(", "self", ",", "iters", ",", "elapsed_time", ",", "converged", ")", ":", "r_c", "=", "self", ".", "config", "[", "'resources'", "]", "stop", "=", "False", "if", "converged", "==", "0", ":", "stop", "=", "True", "if", "r_c", "...
Defines the stopping criterion.
[ "Defines", "the", "stopping", "criterion", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L84-L98
228,202
SheffieldML/GPyOpt
GPyOpt/interface/driver.py
BODriver.run
def run(self): """ Runs the optimization using the previously loaded elements. """ space = self._get_space() obj_func = self._get_obj(space) model = self._get_model() acq = self._get_acquisition(model, space) acq_eval = self._get_acq_evaluator(acq) ...
python
def run(self): """ Runs the optimization using the previously loaded elements. """ space = self._get_space() obj_func = self._get_obj(space) model = self._get_model() acq = self._get_acquisition(model, space) acq_eval = self._get_acq_evaluator(acq) ...
[ "def", "run", "(", "self", ")", ":", "space", "=", "self", ".", "_get_space", "(", ")", "obj_func", "=", "self", ".", "_get_obj", "(", "space", ")", "model", "=", "self", ".", "_get_model", "(", ")", "acq", "=", "self", ".", "_get_acquisition", "(", ...
Runs the optimization using the previously loaded elements.
[ "Runs", "the", "optimization", "using", "the", "previously", "loaded", "elements", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/driver.py#L100-L119
228,203
SheffieldML/GPyOpt
GPyOpt/optimization/optimizer.py
choose_optimizer
def choose_optimizer(optimizer_name, bounds): """ Selects the type of local optimizer """ if optimizer_name == 'lbfgs': optimizer = OptLbfgs(bounds) elif optimizer_name == 'DIRECT': optimizer = OptDirect(bounds) elif optimizer_name == 'CMA': ...
python
def choose_optimizer(optimizer_name, bounds): """ Selects the type of local optimizer """ if optimizer_name == 'lbfgs': optimizer = OptLbfgs(bounds) elif optimizer_name == 'DIRECT': optimizer = OptDirect(bounds) elif optimizer_name == 'CMA': ...
[ "def", "choose_optimizer", "(", "optimizer_name", ",", "bounds", ")", ":", "if", "optimizer_name", "==", "'lbfgs'", ":", "optimizer", "=", "OptLbfgs", "(", "bounds", ")", "elif", "optimizer_name", "==", "'DIRECT'", ":", "optimizer", "=", "OptDirect", "(", "bou...
Selects the type of local optimizer
[ "Selects", "the", "type", "of", "local", "optimizer" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/optimization/optimizer.py#L238-L253
228,204
SheffieldML/GPyOpt
GPyOpt/util/arguments_manager.py
ArgumentsManager.evaluator_creator
def evaluator_creator(self, evaluator_type, acquisition, batch_size, model_type, model, space, acquisition_optimizer): """ Acquisition chooser from the available options. Guide the optimization through sequential or parallel evalutions of the objective. """ acquisition_transformation = s...
python
def evaluator_creator(self, evaluator_type, acquisition, batch_size, model_type, model, space, acquisition_optimizer): """ Acquisition chooser from the available options. Guide the optimization through sequential or parallel evalutions of the objective. """ acquisition_transformation = s...
[ "def", "evaluator_creator", "(", "self", ",", "evaluator_type", ",", "acquisition", ",", "batch_size", ",", "model_type", ",", "model", ",", "space", ",", "acquisition_optimizer", ")", ":", "acquisition_transformation", "=", "self", ".", "kwargs", ".", "get", "(...
Acquisition chooser from the available options. Guide the optimization through sequential or parallel evalutions of the objective.
[ "Acquisition", "chooser", "from", "the", "available", "options", ".", "Guide", "the", "optimization", "through", "sequential", "or", "parallel", "evalutions", "of", "the", "objective", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/util/arguments_manager.py#L17-L38
228,205
SheffieldML/GPyOpt
GPyOpt/acquisitions/LCB.py
AcquisitionLCB._compute_acq
def _compute_acq(self, x): """ Computes the GP-Lower Confidence Bound """ m, s = self.model.predict(x) f_acqu = -m + self.exploration_weight * s return f_acqu
python
def _compute_acq(self, x): """ Computes the GP-Lower Confidence Bound """ m, s = self.model.predict(x) f_acqu = -m + self.exploration_weight * s return f_acqu
[ "def", "_compute_acq", "(", "self", ",", "x", ")", ":", "m", ",", "s", "=", "self", ".", "model", ".", "predict", "(", "x", ")", "f_acqu", "=", "-", "m", "+", "self", ".", "exploration_weight", "*", "s", "return", "f_acqu" ]
Computes the GP-Lower Confidence Bound
[ "Computes", "the", "GP", "-", "Lower", "Confidence", "Bound" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LCB.py#L31-L37
228,206
SheffieldML/GPyOpt
GPyOpt/acquisitions/LCB.py
AcquisitionLCB._compute_acq_withGradients
def _compute_acq_withGradients(self, x): """ Computes the GP-Lower Confidence Bound and its derivative """ m, s, dmdx, dsdx = self.model.predict_withGradients(x) f_acqu = -m + self.exploration_weight * s df_acqu = -dmdx + self.exploration_weight * dsdx ret...
python
def _compute_acq_withGradients(self, x): """ Computes the GP-Lower Confidence Bound and its derivative """ m, s, dmdx, dsdx = self.model.predict_withGradients(x) f_acqu = -m + self.exploration_weight * s df_acqu = -dmdx + self.exploration_weight * dsdx ret...
[ "def", "_compute_acq_withGradients", "(", "self", ",", "x", ")", ":", "m", ",", "s", ",", "dmdx", ",", "dsdx", "=", "self", ".", "model", ".", "predict_withGradients", "(", "x", ")", "f_acqu", "=", "-", "m", "+", "self", ".", "exploration_weight", "*",...
Computes the GP-Lower Confidence Bound and its derivative
[ "Computes", "the", "GP", "-", "Lower", "Confidence", "Bound", "and", "its", "derivative" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LCB.py#L39-L46
228,207
SheffieldML/GPyOpt
GPyOpt/core/task/variables.py
create_variable
def create_variable(descriptor): """ Creates a variable from a dictionary descriptor """ if descriptor['type'] == 'continuous': return ContinuousVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', 1)) elif descriptor['type'] == 'bandit': return BanditV...
python
def create_variable(descriptor): """ Creates a variable from a dictionary descriptor """ if descriptor['type'] == 'continuous': return ContinuousVariable(descriptor['name'], descriptor['domain'], descriptor.get('dimensionality', 1)) elif descriptor['type'] == 'bandit': return BanditV...
[ "def", "create_variable", "(", "descriptor", ")", ":", "if", "descriptor", "[", "'type'", "]", "==", "'continuous'", ":", "return", "ContinuousVariable", "(", "descriptor", "[", "'name'", "]", ",", "descriptor", "[", "'domain'", "]", ",", "descriptor", ".", ...
Creates a variable from a dictionary descriptor
[ "Creates", "a", "variable", "from", "a", "dictionary", "descriptor" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L230-L243
228,208
SheffieldML/GPyOpt
GPyOpt/core/task/variables.py
Variable.expand
def expand(self): """ Builds a list of single dimensional variables representing current variable. Examples: For single dimensional variable, it is returned as is discrete of (0,2,4) -> discrete of (0,2,4) For multi dimensional variable, a list of variables is returned, ...
python
def expand(self): """ Builds a list of single dimensional variables representing current variable. Examples: For single dimensional variable, it is returned as is discrete of (0,2,4) -> discrete of (0,2,4) For multi dimensional variable, a list of variables is returned, ...
[ "def", "expand", "(", "self", ")", ":", "expanded_variables", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "dimensionality", ")", ":", "one_d_variable", "=", "deepcopy", "(", "self", ")", "one_d_variable", ".", "dimensionality", "=", "1", ...
Builds a list of single dimensional variables representing current variable. Examples: For single dimensional variable, it is returned as is discrete of (0,2,4) -> discrete of (0,2,4) For multi dimensional variable, a list of variables is returned, each representing a single dimension ...
[ "Builds", "a", "list", "of", "single", "dimensional", "variables", "representing", "current", "variable", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L16-L36
228,209
SheffieldML/GPyOpt
GPyOpt/core/task/variables.py
ContinuousVariable.round
def round(self, value_array): """ If value falls within bounds, just return it otherwise return min or max, whichever is closer to the value Assumes an 1d array with a single element as an input. """ min_value = self.domain[0] max_value = self.domain[1] ...
python
def round(self, value_array): """ If value falls within bounds, just return it otherwise return min or max, whichever is closer to the value Assumes an 1d array with a single element as an input. """ min_value = self.domain[0] max_value = self.domain[1] ...
[ "def", "round", "(", "self", ",", "value_array", ")", ":", "min_value", "=", "self", ".", "domain", "[", "0", "]", "max_value", "=", "self", ".", "domain", "[", "1", "]", "rounded_value", "=", "value_array", "[", "0", "]", "if", "rounded_value", "<", ...
If value falls within bounds, just return it otherwise return min or max, whichever is closer to the value Assumes an 1d array with a single element as an input.
[ "If", "value", "falls", "within", "bounds", "just", "return", "it", "otherwise", "return", "min", "or", "max", "whichever", "is", "closer", "to", "the", "value", "Assumes", "an", "1d", "array", "with", "a", "single", "element", "as", "an", "input", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L100-L116
228,210
SheffieldML/GPyOpt
GPyOpt/core/task/variables.py
BanditVariable.round
def round(self, value_array): """ Rounds a bandit variable by selecting the closest point in the domain Closest here is defined by euclidian distance Assumes an 1d array of the same length as the single variable value """ distances = np.linalg.norm(np.array(self.domain) -...
python
def round(self, value_array): """ Rounds a bandit variable by selecting the closest point in the domain Closest here is defined by euclidian distance Assumes an 1d array of the same length as the single variable value """ distances = np.linalg.norm(np.array(self.domain) -...
[ "def", "round", "(", "self", ",", "value_array", ")", ":", "distances", "=", "np", ".", "linalg", ".", "norm", "(", "np", ".", "array", "(", "self", ".", "domain", ")", "-", "value_array", ",", "axis", "=", "1", ")", "idx", "=", "np", ".", "argmi...
Rounds a bandit variable by selecting the closest point in the domain Closest here is defined by euclidian distance Assumes an 1d array of the same length as the single variable value
[ "Rounds", "a", "bandit", "variable", "by", "selecting", "the", "closest", "point", "in", "the", "domain", "Closest", "here", "is", "defined", "by", "euclidian", "distance", "Assumes", "an", "1d", "array", "of", "the", "same", "length", "as", "the", "single",...
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L151-L159
228,211
SheffieldML/GPyOpt
GPyOpt/core/task/variables.py
DiscreteVariable.round
def round(self, value_array): """ Rounds a discrete variable by selecting the closest point in the domain Assumes an 1d array with a single element as an input. """ value = value_array[0] rounded_value = self.domain[0] for domain_value in self.domain: ...
python
def round(self, value_array): """ Rounds a discrete variable by selecting the closest point in the domain Assumes an 1d array with a single element as an input. """ value = value_array[0] rounded_value = self.domain[0] for domain_value in self.domain: ...
[ "def", "round", "(", "self", ",", "value_array", ")", ":", "value", "=", "value_array", "[", "0", "]", "rounded_value", "=", "self", ".", "domain", "[", "0", "]", "for", "domain_value", "in", "self", ".", "domain", ":", "if", "np", ".", "abs", "(", ...
Rounds a discrete variable by selecting the closest point in the domain Assumes an 1d array with a single element as an input.
[ "Rounds", "a", "discrete", "variable", "by", "selecting", "the", "closest", "point", "in", "the", "domain", "Assumes", "an", "1d", "array", "with", "a", "single", "element", "as", "an", "input", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/variables.py#L175-L187
228,212
SheffieldML/GPyOpt
GPyOpt/optimization/acquisition_optimizer.py
AcquisitionOptimizer.optimize
def optimize(self, f=None, df=None, f_df=None, duplicate_manager=None): """ Optimizes the input function. :param f: function to optimize. :param df: gradient of the function to optimize. :param f_df: returns both the function to optimize and its gradient. """ se...
python
def optimize(self, f=None, df=None, f_df=None, duplicate_manager=None): """ Optimizes the input function. :param f: function to optimize. :param df: gradient of the function to optimize. :param f_df: returns both the function to optimize and its gradient. """ se...
[ "def", "optimize", "(", "self", ",", "f", "=", "None", ",", "df", "=", "None", ",", "f_df", "=", "None", ",", "duplicate_manager", "=", "None", ")", ":", "self", ".", "f", "=", "f", "self", ".", "df", "=", "df", "self", ".", "f_df", "=", "f_df"...
Optimizes the input function. :param f: function to optimize. :param df: gradient of the function to optimize. :param f_df: returns both the function to optimize and its gradient.
[ "Optimizes", "the", "input", "function", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/optimization/acquisition_optimizer.py#L46-L77
228,213
SheffieldML/GPyOpt
GPyOpt/core/task/objective.py
SingleObjective.evaluate
def evaluate(self, x): """ Performs the evaluation of the objective at x. """ if self.n_procs == 1: f_evals, cost_evals = self._eval_func(x) else: try: f_evals, cost_evals = self._syncronous_batch_evaluation(x) except: ...
python
def evaluate(self, x): """ Performs the evaluation of the objective at x. """ if self.n_procs == 1: f_evals, cost_evals = self._eval_func(x) else: try: f_evals, cost_evals = self._syncronous_batch_evaluation(x) except: ...
[ "def", "evaluate", "(", "self", ",", "x", ")", ":", "if", "self", ".", "n_procs", "==", "1", ":", "f_evals", ",", "cost_evals", "=", "self", ".", "_eval_func", "(", "x", ")", "else", ":", "try", ":", "f_evals", ",", "cost_evals", "=", "self", ".", ...
Performs the evaluation of the objective at x.
[ "Performs", "the", "evaluation", "of", "the", "objective", "at", "x", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/objective.py#L44-L61
228,214
SheffieldML/GPyOpt
GPyOpt/core/task/objective.py
SingleObjective._syncronous_batch_evaluation
def _syncronous_batch_evaluation(self,x): """ Evaluates the function a x, where x can be a single location or a batch. The evaluation is performed in parallel according to the number of accessible cores. """ from multiprocessing import Process, Pipe # --- parallel evalua...
python
def _syncronous_batch_evaluation(self,x): """ Evaluates the function a x, where x can be a single location or a batch. The evaluation is performed in parallel according to the number of accessible cores. """ from multiprocessing import Process, Pipe # --- parallel evalua...
[ "def", "_syncronous_batch_evaluation", "(", "self", ",", "x", ")", ":", "from", "multiprocessing", "import", "Process", ",", "Pipe", "# --- parallel evaluation of the function", "divided_samples", "=", "[", "x", "[", "i", ":", ":", "self", ".", "n_procs", "]", "...
Evaluates the function a x, where x can be a single location or a batch. The evaluation is performed in parallel according to the number of accessible cores.
[ "Evaluates", "the", "function", "a", "x", "where", "x", "can", "be", "a", "single", "location", "or", "a", "batch", ".", "The", "evaluation", "is", "performed", "in", "parallel", "according", "to", "the", "number", "of", "accessible", "cores", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/objective.py#L80-L101
228,215
SheffieldML/GPyOpt
GPyOpt/core/evaluators/sequential.py
Sequential.compute_batch
def compute_batch(self, duplicate_manager=None,context_manager=None): """ Selects the new location to evaluate the objective. """ x, _ = self.acquisition.optimize(duplicate_manager=duplicate_manager) return x
python
def compute_batch(self, duplicate_manager=None,context_manager=None): """ Selects the new location to evaluate the objective. """ x, _ = self.acquisition.optimize(duplicate_manager=duplicate_manager) return x
[ "def", "compute_batch", "(", "self", ",", "duplicate_manager", "=", "None", ",", "context_manager", "=", "None", ")", ":", "x", ",", "_", "=", "self", ".", "acquisition", ".", "optimize", "(", "duplicate_manager", "=", "duplicate_manager", ")", "return", "x"...
Selects the new location to evaluate the objective.
[ "Selects", "the", "new", "location", "to", "evaluate", "the", "objective", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/evaluators/sequential.py#L18-L23
228,216
SheffieldML/GPyOpt
GPyOpt/acquisitions/LCB_mcmc.py
AcquisitionLCB_MCMC._compute_acq
def _compute_acq(self,x): """ Integrated GP-Lower Confidence Bound """ means, stds = self.model.predict(x) f_acqu = 0 for m,s in zip(means, stds): f_acqu += -m + self.exploration_weight * s return f_acqu/(len(means))
python
def _compute_acq(self,x): """ Integrated GP-Lower Confidence Bound """ means, stds = self.model.predict(x) f_acqu = 0 for m,s in zip(means, stds): f_acqu += -m + self.exploration_weight * s return f_acqu/(len(means))
[ "def", "_compute_acq", "(", "self", ",", "x", ")", ":", "means", ",", "stds", "=", "self", ".", "model", ".", "predict", "(", "x", ")", "f_acqu", "=", "0", "for", "m", ",", "s", "in", "zip", "(", "means", ",", "stds", ")", ":", "f_acqu", "+=", ...
Integrated GP-Lower Confidence Bound
[ "Integrated", "GP", "-", "Lower", "Confidence", "Bound" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LCB_mcmc.py#L26-L34
228,217
SheffieldML/GPyOpt
GPyOpt/acquisitions/LCB_mcmc.py
AcquisitionLCB_MCMC._compute_acq_withGradients
def _compute_acq_withGradients(self, x): """ Integrated GP-Lower Confidence Bound and its derivative """ means, stds, dmdxs, dsdxs = self.model.predict_withGradients(x) f_acqu = None df_acqu = None for m, s, dmdx, dsdx in zip(means, stds, dmdxs, dsdxs): ...
python
def _compute_acq_withGradients(self, x): """ Integrated GP-Lower Confidence Bound and its derivative """ means, stds, dmdxs, dsdxs = self.model.predict_withGradients(x) f_acqu = None df_acqu = None for m, s, dmdx, dsdx in zip(means, stds, dmdxs, dsdxs): ...
[ "def", "_compute_acq_withGradients", "(", "self", ",", "x", ")", ":", "means", ",", "stds", ",", "dmdxs", ",", "dsdxs", "=", "self", ".", "model", ".", "predict_withGradients", "(", "x", ")", "f_acqu", "=", "None", "df_acqu", "=", "None", "for", "m", "...
Integrated GP-Lower Confidence Bound and its derivative
[ "Integrated", "GP", "-", "Lower", "Confidence", "Bound", "and", "its", "derivative" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/LCB_mcmc.py#L36-L52
228,218
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space._expand_config_space
def _expand_config_space(self): """ Expands the config input space into a list of diccionaries, one for each variable_dic in which the dimensionality is always one. Example: It would transform config_space =[ {'name': 'var_1', 'type': 'continuous', 'domain':(-1,1), 'dimensionali...
python
def _expand_config_space(self): """ Expands the config input space into a list of diccionaries, one for each variable_dic in which the dimensionality is always one. Example: It would transform config_space =[ {'name': 'var_1', 'type': 'continuous', 'domain':(-1,1), 'dimensionali...
[ "def", "_expand_config_space", "(", "self", ")", ":", "self", ".", "config_space_expanded", "=", "[", "]", "for", "variable", "in", "self", ".", "config_space", ":", "variable_dic", "=", "variable", ".", "copy", "(", ")", "if", "'dimensionality'", "in", "var...
Expands the config input space into a list of diccionaries, one for each variable_dic in which the dimensionality is always one. Example: It would transform config_space =[ {'name': 'var_1', 'type': 'continuous', 'domain':(-1,1), 'dimensionality':1}, {'name': 'var_2', 't...
[ "Expands", "the", "config", "input", "space", "into", "a", "list", "of", "diccionaries", "one", "for", "each", "variable_dic", "in", "which", "the", "dimensionality", "is", "always", "one", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L101-L131
228,219
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space._create_variables_dic
def _create_variables_dic(self): """ Returns the variable by passing its name """ self.name_to_variable = {} for variable in self.space_expanded: self.name_to_variable[variable.name] = variable
python
def _create_variables_dic(self): """ Returns the variable by passing its name """ self.name_to_variable = {} for variable in self.space_expanded: self.name_to_variable[variable.name] = variable
[ "def", "_create_variables_dic", "(", "self", ")", ":", "self", ".", "name_to_variable", "=", "{", "}", "for", "variable", "in", "self", ".", "space_expanded", ":", "self", ".", "name_to_variable", "[", "variable", ".", "name", "]", "=", "variable" ]
Returns the variable by passing its name
[ "Returns", "the", "variable", "by", "passing", "its", "name" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L162-L168
228,220
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space._translate_space
def _translate_space(self, space): """ Translates a list of dictionaries into internal list of variables """ self.space = [] self.dimensionality = 0 self.has_types = d = {t: False for t in self.supported_types} for i, d in enumerate(space): descriptor...
python
def _translate_space(self, space): """ Translates a list of dictionaries into internal list of variables """ self.space = [] self.dimensionality = 0 self.has_types = d = {t: False for t in self.supported_types} for i, d in enumerate(space): descriptor...
[ "def", "_translate_space", "(", "self", ",", "space", ")", ":", "self", ".", "space", "=", "[", "]", "self", ".", "dimensionality", "=", "0", "self", ".", "has_types", "=", "d", "=", "{", "t", ":", "False", "for", "t", "in", "self", ".", "supported...
Translates a list of dictionaries into internal list of variables
[ "Translates", "a", "list", "of", "dictionaries", "into", "internal", "list", "of", "variables" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L170-L191
228,221
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space._expand_space
def _expand_space(self): """ Creates an internal list where the variables with dimensionality larger than one are expanded. This list is the one that is used internally to do the optimization. """ ## --- Expand the config space self._expand_config_space() ## ---...
python
def _expand_space(self): """ Creates an internal list where the variables with dimensionality larger than one are expanded. This list is the one that is used internally to do the optimization. """ ## --- Expand the config space self._expand_config_space() ## ---...
[ "def", "_expand_space", "(", "self", ")", ":", "## --- Expand the config space", "self", ".", "_expand_config_space", "(", ")", "## --- Expand the space", "self", ".", "space_expanded", "=", "[", "]", "for", "variable", "in", "self", ".", "space", ":", "self", "...
Creates an internal list where the variables with dimensionality larger than one are expanded. This list is the one that is used internally to do the optimization.
[ "Creates", "an", "internal", "list", "where", "the", "variables", "with", "dimensionality", "larger", "than", "one", "are", "expanded", ".", "This", "list", "is", "the", "one", "that", "is", "used", "internally", "to", "do", "the", "optimization", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L193-L205
228,222
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.objective_to_model
def objective_to_model(self, x_objective): ''' This function serves as interface between objective input vectors and model input vectors''' x_model = [] for k in range(self.objective_dimensionality): variable = self.space_expanded[k] new_entry = variable.objecti...
python
def objective_to_model(self, x_objective): ''' This function serves as interface between objective input vectors and model input vectors''' x_model = [] for k in range(self.objective_dimensionality): variable = self.space_expanded[k] new_entry = variable.objecti...
[ "def", "objective_to_model", "(", "self", ",", "x_objective", ")", ":", "x_model", "=", "[", "]", "for", "k", "in", "range", "(", "self", ".", "objective_dimensionality", ")", ":", "variable", "=", "self", ".", "space_expanded", "[", "k", "]", "new_entry",...
This function serves as interface between objective input vectors and model input vectors
[ "This", "function", "serves", "as", "interface", "between", "objective", "input", "vectors", "and", "model", "input", "vectors" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L207-L218
228,223
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.model_to_objective
def model_to_objective(self, x_model): ''' This function serves as interface between model input vectors and objective input vectors ''' idx_model = 0 x_objective = [] for idx_obj in range(self.objective_dimensionality): variable = self.space_expanded[idx...
python
def model_to_objective(self, x_model): ''' This function serves as interface between model input vectors and objective input vectors ''' idx_model = 0 x_objective = [] for idx_obj in range(self.objective_dimensionality): variable = self.space_expanded[idx...
[ "def", "model_to_objective", "(", "self", ",", "x_model", ")", ":", "idx_model", "=", "0", "x_objective", "=", "[", "]", "for", "idx_obj", "in", "range", "(", "self", ".", "objective_dimensionality", ")", ":", "variable", "=", "self", ".", "space_expanded", ...
This function serves as interface between model input vectors and objective input vectors
[ "This", "function", "serves", "as", "interface", "between", "model", "input", "vectors", "and", "objective", "input", "vectors" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L238-L251
228,224
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.get_subspace
def get_subspace(self, dims): ''' Extracts subspace from the reference of a list of variables in the inputs of the model. ''' subspace = [] k = 0 for variable in self.space_expanded: if k in dims: subspace.append(variable) k...
python
def get_subspace(self, dims): ''' Extracts subspace from the reference of a list of variables in the inputs of the model. ''' subspace = [] k = 0 for variable in self.space_expanded: if k in dims: subspace.append(variable) k...
[ "def", "get_subspace", "(", "self", ",", "dims", ")", ":", "subspace", "=", "[", "]", "k", "=", "0", "for", "variable", "in", "self", ".", "space_expanded", ":", "if", "k", "in", "dims", ":", "subspace", ".", "append", "(", "variable", ")", "k", "+...
Extracts subspace from the reference of a list of variables in the inputs of the model.
[ "Extracts", "subspace", "from", "the", "reference", "of", "a", "list", "of", "variables", "in", "the", "inputs", "of", "the", "model", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L283-L294
228,225
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.indicator_constraints
def indicator_constraints(self,x): """ Returns array of ones and zeros indicating if x is within the constraints """ x = np.atleast_2d(x) I_x = np.ones((x.shape[0],1)) if self.constraints is not None: for d in self.constraints: try: ...
python
def indicator_constraints(self,x): """ Returns array of ones and zeros indicating if x is within the constraints """ x = np.atleast_2d(x) I_x = np.ones((x.shape[0],1)) if self.constraints is not None: for d in self.constraints: try: ...
[ "def", "indicator_constraints", "(", "self", ",", "x", ")", ":", "x", "=", "np", ".", "atleast_2d", "(", "x", ")", "I_x", "=", "np", ".", "ones", "(", "(", "x", ".", "shape", "[", "0", "]", ",", "1", ")", ")", "if", "self", ".", "constraints", ...
Returns array of ones and zeros indicating if x is within the constraints
[ "Returns", "array", "of", "ones", "and", "zeros", "indicating", "if", "x", "is", "within", "the", "constraints" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L297-L312
228,226
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.input_dim
def input_dim(self): """ Extracts the input dimension of the domain. """ n_cont = len(self.get_continuous_dims()) n_disc = len(self.get_discrete_dims()) return n_cont + n_disc
python
def input_dim(self): """ Extracts the input dimension of the domain. """ n_cont = len(self.get_continuous_dims()) n_disc = len(self.get_discrete_dims()) return n_cont + n_disc
[ "def", "input_dim", "(", "self", ")", ":", "n_cont", "=", "len", "(", "self", ".", "get_continuous_dims", "(", ")", ")", "n_disc", "=", "len", "(", "self", ".", "get_discrete_dims", "(", ")", ")", "return", "n_cont", "+", "n_disc" ]
Extracts the input dimension of the domain.
[ "Extracts", "the", "input", "dimension", "of", "the", "domain", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L314-L320
228,227
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.round_optimum
def round_optimum(self, x): """ Rounds some value x to a feasible value in the design space. x is expected to be a vector or an array with a single row """ x = np.array(x) if not ((x.ndim == 1) or (x.ndim == 2 and x.shape[0] == 1)): raise ValueError("Unexpecte...
python
def round_optimum(self, x): """ Rounds some value x to a feasible value in the design space. x is expected to be a vector or an array with a single row """ x = np.array(x) if not ((x.ndim == 1) or (x.ndim == 2 and x.shape[0] == 1)): raise ValueError("Unexpecte...
[ "def", "round_optimum", "(", "self", ",", "x", ")", ":", "x", "=", "np", ".", "array", "(", "x", ")", "if", "not", "(", "(", "x", ".", "ndim", "==", "1", ")", "or", "(", "x", ".", "ndim", "==", "2", "and", "x", ".", "shape", "[", "0", "]"...
Rounds some value x to a feasible value in the design space. x is expected to be a vector or an array with a single row
[ "Rounds", "some", "value", "x", "to", "a", "feasible", "value", "in", "the", "design", "space", ".", "x", "is", "expected", "to", "be", "a", "vector", "or", "an", "array", "with", "a", "single", "row" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L322-L343
228,228
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.get_continuous_bounds
def get_continuous_bounds(self): """ Extracts the bounds of the continuous variables. """ bounds = [] for d in self.space: if d.type == 'continuous': bounds.extend([d.domain]*d.dimensionality) return bounds
python
def get_continuous_bounds(self): """ Extracts the bounds of the continuous variables. """ bounds = [] for d in self.space: if d.type == 'continuous': bounds.extend([d.domain]*d.dimensionality) return bounds
[ "def", "get_continuous_bounds", "(", "self", ")", ":", "bounds", "=", "[", "]", "for", "d", "in", "self", ".", "space", ":", "if", "d", ".", "type", "==", "'continuous'", ":", "bounds", ".", "extend", "(", "[", "d", ".", "domain", "]", "*", "d", ...
Extracts the bounds of the continuous variables.
[ "Extracts", "the", "bounds", "of", "the", "continuous", "variables", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L353-L361
228,229
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.get_continuous_dims
def get_continuous_dims(self): """ Returns the dimension of the continuous components of the domain. """ continuous_dims = [] for i in range(self.dimensionality): if self.space_expanded[i].type == 'continuous': continuous_dims += [i] return con...
python
def get_continuous_dims(self): """ Returns the dimension of the continuous components of the domain. """ continuous_dims = [] for i in range(self.dimensionality): if self.space_expanded[i].type == 'continuous': continuous_dims += [i] return con...
[ "def", "get_continuous_dims", "(", "self", ")", ":", "continuous_dims", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "dimensionality", ")", ":", "if", "self", ".", "space_expanded", "[", "i", "]", ".", "type", "==", "'continuous'", ":", ...
Returns the dimension of the continuous components of the domain.
[ "Returns", "the", "dimension", "of", "the", "continuous", "components", "of", "the", "domain", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L364-L372
228,230
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.get_discrete_grid
def get_discrete_grid(self): """ Computes a Numpy array with the grid of points that results after crossing the possible outputs of the discrete variables """ sets_grid = [] for d in self.space: if d.type == 'discrete': sets_grid.extend([d.doma...
python
def get_discrete_grid(self): """ Computes a Numpy array with the grid of points that results after crossing the possible outputs of the discrete variables """ sets_grid = [] for d in self.space: if d.type == 'discrete': sets_grid.extend([d.doma...
[ "def", "get_discrete_grid", "(", "self", ")", ":", "sets_grid", "=", "[", "]", "for", "d", "in", "self", ".", "space", ":", "if", "d", ".", "type", "==", "'discrete'", ":", "sets_grid", ".", "extend", "(", "[", "d", ".", "domain", "]", "*", "d", ...
Computes a Numpy array with the grid of points that results after crossing the possible outputs of the discrete variables
[ "Computes", "a", "Numpy", "array", "with", "the", "grid", "of", "points", "that", "results", "after", "crossing", "the", "possible", "outputs", "of", "the", "discrete", "variables" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L387-L396
228,231
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.get_discrete_dims
def get_discrete_dims(self): """ Returns the dimension of the discrete components of the domain. """ discrete_dims = [] for i in range(self.dimensionality): if self.space_expanded[i].type == 'discrete': discrete_dims += [i] return discrete_dims
python
def get_discrete_dims(self): """ Returns the dimension of the discrete components of the domain. """ discrete_dims = [] for i in range(self.dimensionality): if self.space_expanded[i].type == 'discrete': discrete_dims += [i] return discrete_dims
[ "def", "get_discrete_dims", "(", "self", ")", ":", "discrete_dims", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "dimensionality", ")", ":", "if", "self", ".", "space_expanded", "[", "i", "]", ".", "type", "==", "'discrete'", ":", "discr...
Returns the dimension of the discrete components of the domain.
[ "Returns", "the", "dimension", "of", "the", "discrete", "components", "of", "the", "domain", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L399-L407
228,232
SheffieldML/GPyOpt
GPyOpt/core/task/space.py
Design_space.get_bandit
def get_bandit(self): """ Extracts the arms of the bandit if any. """ arms_bandit = [] for d in self.space: if d.type == 'bandit': arms_bandit += tuple(map(tuple, d.domain)) return np.asarray(arms_bandit)
python
def get_bandit(self): """ Extracts the arms of the bandit if any. """ arms_bandit = [] for d in self.space: if d.type == 'bandit': arms_bandit += tuple(map(tuple, d.domain)) return np.asarray(arms_bandit)
[ "def", "get_bandit", "(", "self", ")", ":", "arms_bandit", "=", "[", "]", "for", "d", "in", "self", ".", "space", ":", "if", "d", ".", "type", "==", "'bandit'", ":", "arms_bandit", "+=", "tuple", "(", "map", "(", "tuple", ",", "d", ".", "domain", ...
Extracts the arms of the bandit if any.
[ "Extracts", "the", "arms", "of", "the", "bandit", "if", "any", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/task/space.py#L422-L430
228,233
SheffieldML/GPyOpt
GPyOpt/models/rfmodel.py
RFModel.predict
def predict(self, X): """ Predictions with the model. Returns posterior means and standard deviations at X. """ X = np.atleast_2d(X) m = np.empty(shape=(0,1)) s = np.empty(shape=(0,1)) for k in range(X.shape[0]): preds = [] for pred in sel...
python
def predict(self, X): """ Predictions with the model. Returns posterior means and standard deviations at X. """ X = np.atleast_2d(X) m = np.empty(shape=(0,1)) s = np.empty(shape=(0,1)) for k in range(X.shape[0]): preds = [] for pred in sel...
[ "def", "predict", "(", "self", ",", "X", ")", ":", "X", "=", "np", ".", "atleast_2d", "(", "X", ")", "m", "=", "np", ".", "empty", "(", "shape", "=", "(", "0", ",", "1", ")", ")", "s", "=", "np", ".", "empty", "(", "shape", "=", "(", "0",...
Predictions with the model. Returns posterior means and standard deviations at X.
[ "Predictions", "with", "the", "model", ".", "Returns", "posterior", "means", "and", "standard", "deviations", "at", "X", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/rfmodel.py#L79-L93
228,234
SheffieldML/GPyOpt
GPyOpt/acquisitions/MPI_mcmc.py
AcquisitionMPI_MCMC._compute_acq
def _compute_acq(self,x): """ Integrated Expected Improvement """ means, stds = self.model.predict(x) fmins = self.model.get_fmin() f_acqu = 0 for m,s,fmin in zip(means, stds, fmins): _, Phi, _ = get_quantiles(self.jitter, fmin, m, s) f_acq...
python
def _compute_acq(self,x): """ Integrated Expected Improvement """ means, stds = self.model.predict(x) fmins = self.model.get_fmin() f_acqu = 0 for m,s,fmin in zip(means, stds, fmins): _, Phi, _ = get_quantiles(self.jitter, fmin, m, s) f_acq...
[ "def", "_compute_acq", "(", "self", ",", "x", ")", ":", "means", ",", "stds", "=", "self", ".", "model", ".", "predict", "(", "x", ")", "fmins", "=", "self", ".", "model", ".", "get_fmin", "(", ")", "f_acqu", "=", "0", "for", "m", ",", "s", ","...
Integrated Expected Improvement
[ "Integrated", "Expected", "Improvement" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/MPI_mcmc.py#L29-L39
228,235
SheffieldML/GPyOpt
GPyOpt/acquisitions/MPI_mcmc.py
AcquisitionMPI_MCMC._compute_acq_withGradients
def _compute_acq_withGradients(self, x): """ Integrated Expected Improvement and its derivative """ means, stds, dmdxs, dsdxs = self.model.predict_withGradients(x) fmins = self.model.get_fmin() f_acqu = None df_acqu = None for m, s, fmin, dmdx, dsdx in zip...
python
def _compute_acq_withGradients(self, x): """ Integrated Expected Improvement and its derivative """ means, stds, dmdxs, dsdxs = self.model.predict_withGradients(x) fmins = self.model.get_fmin() f_acqu = None df_acqu = None for m, s, fmin, dmdx, dsdx in zip...
[ "def", "_compute_acq_withGradients", "(", "self", ",", "x", ")", ":", "means", ",", "stds", ",", "dmdxs", ",", "dsdxs", "=", "self", ".", "model", ".", "predict_withGradients", "(", "x", ")", "fmins", "=", "self", ".", "model", ".", "get_fmin", "(", ")...
Integrated Expected Improvement and its derivative
[ "Integrated", "Expected", "Improvement", "and", "its", "derivative" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/MPI_mcmc.py#L41-L59
228,236
SheffieldML/GPyOpt
GPyOpt/plotting/plots_bo.py
plot_convergence
def plot_convergence(Xdata,best_Y, filename = None): ''' Plots to evaluate the convergence of standard Bayesian optimization algorithms ''' n = Xdata.shape[0] aux = (Xdata[1:n,:]-Xdata[0:n-1,:])**2 distances = np.sqrt(aux.sum(axis=1)) ## Distances between consecutive x's plt.figure(figs...
python
def plot_convergence(Xdata,best_Y, filename = None): ''' Plots to evaluate the convergence of standard Bayesian optimization algorithms ''' n = Xdata.shape[0] aux = (Xdata[1:n,:]-Xdata[0:n-1,:])**2 distances = np.sqrt(aux.sum(axis=1)) ## Distances between consecutive x's plt.figure(figs...
[ "def", "plot_convergence", "(", "Xdata", ",", "best_Y", ",", "filename", "=", "None", ")", ":", "n", "=", "Xdata", ".", "shape", "[", "0", "]", "aux", "=", "(", "Xdata", "[", "1", ":", "n", ",", ":", "]", "-", "Xdata", "[", "0", ":", "n", "-"...
Plots to evaluate the convergence of standard Bayesian optimization algorithms
[ "Plots", "to", "evaluate", "the", "convergence", "of", "standard", "Bayesian", "optimization", "algorithms" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/plotting/plots_bo.py#L122-L150
228,237
SheffieldML/GPyOpt
GPyOpt/core/evaluators/batch_local_penalization.py
LocalPenalization.compute_batch
def compute_batch(self, duplicate_manager=None, context_manager=None): """ Computes the elements of the batch sequentially by penalizing the acquisition. """ from ...acquisitions import AcquisitionLP assert isinstance(self.acquisition, AcquisitionLP) self.acquisition.upd...
python
def compute_batch(self, duplicate_manager=None, context_manager=None): """ Computes the elements of the batch sequentially by penalizing the acquisition. """ from ...acquisitions import AcquisitionLP assert isinstance(self.acquisition, AcquisitionLP) self.acquisition.upd...
[ "def", "compute_batch", "(", "self", ",", "duplicate_manager", "=", "None", ",", "context_manager", "=", "None", ")", ":", "from", ".", ".", ".", "acquisitions", "import", "AcquisitionLP", "assert", "isinstance", "(", "self", ".", "acquisition", ",", "Acquisit...
Computes the elements of the batch sequentially by penalizing the acquisition.
[ "Computes", "the", "elements", "of", "the", "batch", "sequentially", "by", "penalizing", "the", "acquisition", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/evaluators/batch_local_penalization.py#L22-L49
228,238
SheffieldML/GPyOpt
manual/notebooks_check.py
check_notebooks_for_errors
def check_notebooks_for_errors(notebooks_directory): ''' Evaluates all notebooks in given directory and prints errors, if any ''' print("Checking notebooks in directory {} for errors".format(notebooks_directory)) failed_notebooks_count = 0 for file in os.listdir(notebooks_directory): if file.en...
python
def check_notebooks_for_errors(notebooks_directory): ''' Evaluates all notebooks in given directory and prints errors, if any ''' print("Checking notebooks in directory {} for errors".format(notebooks_directory)) failed_notebooks_count = 0 for file in os.listdir(notebooks_directory): if file.en...
[ "def", "check_notebooks_for_errors", "(", "notebooks_directory", ")", ":", "print", "(", "\"Checking notebooks in directory {} for errors\"", ".", "format", "(", "notebooks_directory", ")", ")", "failed_notebooks_count", "=", "0", "for", "file", "in", "os", ".", "listdi...
Evaluates all notebooks in given directory and prints errors, if any
[ "Evaluates", "all", "notebooks", "in", "given", "directory", "and", "prints", "errors", "if", "any" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/manual/notebooks_check.py#L8-L24
228,239
SheffieldML/GPyOpt
GPyOpt/models/gpmodel.py
GPModel.predict
def predict(self, X, with_noise=True): """ Predictions with the model. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given. Parameters: X (np.ndarray) - points to run the prediction for. with_noise (bool)...
python
def predict(self, X, with_noise=True): """ Predictions with the model. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given. Parameters: X (np.ndarray) - points to run the prediction for. with_noise (bool)...
[ "def", "predict", "(", "self", ",", "X", ",", "with_noise", "=", "True", ")", ":", "m", ",", "v", "=", "self", ".", "_predict", "(", "X", ",", "False", ",", "with_noise", ")", "# We can take the square root because v is just a diagonal matrix of variances", "ret...
Predictions with the model. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given. Parameters: X (np.ndarray) - points to run the prediction for. with_noise (bool) - whether to add noise to the prediction. Default is True.
[ "Predictions", "with", "the", "model", ".", "Returns", "posterior", "means", "and", "standard", "deviations", "at", "X", ".", "Note", "that", "this", "is", "different", "in", "GPy", "where", "the", "variances", "are", "given", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L100-L110
228,240
SheffieldML/GPyOpt
GPyOpt/models/gpmodel.py
GPModel.predict_covariance
def predict_covariance(self, X, with_noise=True): """ Predicts the covariance matric for points in X. Parameters: X (np.ndarray) - points to run the prediction for. with_noise (bool) - whether to add noise to the prediction. Default is True. """ _, v = se...
python
def predict_covariance(self, X, with_noise=True): """ Predicts the covariance matric for points in X. Parameters: X (np.ndarray) - points to run the prediction for. with_noise (bool) - whether to add noise to the prediction. Default is True. """ _, v = se...
[ "def", "predict_covariance", "(", "self", ",", "X", ",", "with_noise", "=", "True", ")", ":", "_", ",", "v", "=", "self", ".", "_predict", "(", "X", ",", "True", ",", "with_noise", ")", "return", "v" ]
Predicts the covariance matric for points in X. Parameters: X (np.ndarray) - points to run the prediction for. with_noise (bool) - whether to add noise to the prediction. Default is True.
[ "Predicts", "the", "covariance", "matric", "for", "points", "in", "X", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L112-L121
228,241
SheffieldML/GPyOpt
GPyOpt/models/gpmodel.py
GPModel.predict_withGradients
def predict_withGradients(self, X): """ Returns the mean, standard deviation, mean gradient and standard deviation gradient at X. """ if X.ndim==1: X = X[None,:] m, v = self.model.predict(X) v = np.clip(v, 1e-10, np.inf) dmdx, dvdx = self.model.predictive_gradient...
python
def predict_withGradients(self, X): """ Returns the mean, standard deviation, mean gradient and standard deviation gradient at X. """ if X.ndim==1: X = X[None,:] m, v = self.model.predict(X) v = np.clip(v, 1e-10, np.inf) dmdx, dvdx = self.model.predictive_gradient...
[ "def", "predict_withGradients", "(", "self", ",", "X", ")", ":", "if", "X", ".", "ndim", "==", "1", ":", "X", "=", "X", "[", "None", ",", ":", "]", "m", ",", "v", "=", "self", ".", "model", ".", "predict", "(", "X", ")", "v", "=", "np", "."...
Returns the mean, standard deviation, mean gradient and standard deviation gradient at X.
[ "Returns", "the", "mean", "standard", "deviation", "mean", "gradient", "and", "standard", "deviation", "gradient", "at", "X", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L129-L140
228,242
SheffieldML/GPyOpt
GPyOpt/models/gpmodel.py
GPModel_MCMC.predict
def predict(self, X): """ Predictions with the model for all the MCMC samples. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given. """ if X.ndim==1: X = X[None,:] ps = self.model.param_array.copy() means...
python
def predict(self, X): """ Predictions with the model for all the MCMC samples. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given. """ if X.ndim==1: X = X[None,:] ps = self.model.param_array.copy() means...
[ "def", "predict", "(", "self", ",", "X", ")", ":", "if", "X", ".", "ndim", "==", "1", ":", "X", "=", "X", "[", "None", ",", ":", "]", "ps", "=", "self", ".", "model", ".", "param_array", ".", "copy", "(", ")", "means", "=", "[", "]", "stds"...
Predictions with the model for all the MCMC samples. Returns posterior means and standard deviations at X. Note that this is different in GPy where the variances are given.
[ "Predictions", "with", "the", "model", "for", "all", "the", "MCMC", "samples", ".", "Returns", "posterior", "means", "and", "standard", "deviations", "at", "X", ".", "Note", "that", "this", "is", "different", "in", "GPy", "where", "the", "variances", "are", ...
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L255-L275
228,243
SheffieldML/GPyOpt
GPyOpt/models/gpmodel.py
GPModel_MCMC.get_fmin
def get_fmin(self): """ Returns the location where the posterior mean is takes its minimal value. """ ps = self.model.param_array.copy() fmins = [] for s in self.hmc_samples: if self.model._fixes_ is None: self.model[:] = s else: ...
python
def get_fmin(self): """ Returns the location where the posterior mean is takes its minimal value. """ ps = self.model.param_array.copy() fmins = [] for s in self.hmc_samples: if self.model._fixes_ is None: self.model[:] = s else: ...
[ "def", "get_fmin", "(", "self", ")", ":", "ps", "=", "self", ".", "model", ".", "param_array", ".", "copy", "(", ")", "fmins", "=", "[", "]", "for", "s", "in", "self", ".", "hmc_samples", ":", "if", "self", ".", "model", ".", "_fixes_", "is", "No...
Returns the location where the posterior mean is takes its minimal value.
[ "Returns", "the", "location", "where", "the", "posterior", "mean", "is", "takes", "its", "minimal", "value", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L277-L293
228,244
SheffieldML/GPyOpt
GPyOpt/models/gpmodel.py
GPModel_MCMC.predict_withGradients
def predict_withGradients(self, X): """ Returns the mean, standard deviation, mean gradient and standard deviation gradient at X for all the MCMC samples. """ if X.ndim==1: X = X[None,:] ps = self.model.param_array.copy() means = [] stds = [] dmdxs = [] ...
python
def predict_withGradients(self, X): """ Returns the mean, standard deviation, mean gradient and standard deviation gradient at X for all the MCMC samples. """ if X.ndim==1: X = X[None,:] ps = self.model.param_array.copy() means = [] stds = [] dmdxs = [] ...
[ "def", "predict_withGradients", "(", "self", ",", "X", ")", ":", "if", "X", ".", "ndim", "==", "1", ":", "X", "=", "X", "[", "None", ",", ":", "]", "ps", "=", "self", ".", "model", ".", "param_array", ".", "copy", "(", ")", "means", "=", "[", ...
Returns the mean, standard deviation, mean gradient and standard deviation gradient at X for all the MCMC samples.
[ "Returns", "the", "mean", "standard", "deviation", "mean", "gradient", "and", "standard", "deviation", "gradient", "at", "X", "for", "all", "the", "MCMC", "samples", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L295-L322
228,245
SheffieldML/GPyOpt
GPyOpt/interface/func_loader.py
load_objective
def load_objective(config): """ Loads the objective function from a .json file. """ assert 'prjpath' in config assert 'main-file' in config, "The problem file ('main-file') is missing!" os.chdir(config['prjpath']) if config['language'].lower()=='python': assert config['main-fil...
python
def load_objective(config): """ Loads the objective function from a .json file. """ assert 'prjpath' in config assert 'main-file' in config, "The problem file ('main-file') is missing!" os.chdir(config['prjpath']) if config['language'].lower()=='python': assert config['main-fil...
[ "def", "load_objective", "(", "config", ")", ":", "assert", "'prjpath'", "in", "config", "assert", "'main-file'", "in", "config", ",", "\"The problem file ('main-file') is missing!\"", "os", ".", "chdir", "(", "config", "[", "'prjpath'", "]", ")", "if", "config", ...
Loads the objective function from a .json file.
[ "Loads", "the", "objective", "function", "from", "a", ".", "json", "file", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/func_loader.py#L7-L21
228,246
SheffieldML/GPyOpt
GPyOpt/acquisitions/EI.py
AcquisitionEI._compute_acq
def _compute_acq(self, x): """ Computes the Expected Improvement per unit of cost """ m, s = self.model.predict(x) fmin = self.model.get_fmin() phi, Phi, u = get_quantiles(self.jitter, fmin, m, s) f_acqu = s * (u * Phi + phi) return f_acqu
python
def _compute_acq(self, x): """ Computes the Expected Improvement per unit of cost """ m, s = self.model.predict(x) fmin = self.model.get_fmin() phi, Phi, u = get_quantiles(self.jitter, fmin, m, s) f_acqu = s * (u * Phi + phi) return f_acqu
[ "def", "_compute_acq", "(", "self", ",", "x", ")", ":", "m", ",", "s", "=", "self", ".", "model", ".", "predict", "(", "x", ")", "fmin", "=", "self", ".", "model", ".", "get_fmin", "(", ")", "phi", ",", "Phi", ",", "u", "=", "get_quantiles", "(...
Computes the Expected Improvement per unit of cost
[ "Computes", "the", "Expected", "Improvement", "per", "unit", "of", "cost" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/acquisitions/EI.py#L32-L40
228,247
SheffieldML/GPyOpt
GPyOpt/interface/config_parser.py
update_config
def update_config(config_new, config_default): ''' Updates the loaded method configuration with default values. ''' if any([isinstance(v, dict) for v in list(config_new.values())]): for k,v in list(config_new.items()): if isinstance(v,dict) and k in config_default: u...
python
def update_config(config_new, config_default): ''' Updates the loaded method configuration with default values. ''' if any([isinstance(v, dict) for v in list(config_new.values())]): for k,v in list(config_new.items()): if isinstance(v,dict) and k in config_default: u...
[ "def", "update_config", "(", "config_new", ",", "config_default", ")", ":", "if", "any", "(", "[", "isinstance", "(", "v", ",", "dict", ")", "for", "v", "in", "list", "(", "config_new", ".", "values", "(", ")", ")", "]", ")", ":", "for", "k", ",", ...
Updates the loaded method configuration with default values.
[ "Updates", "the", "loaded", "method", "configuration", "with", "default", "values", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/config_parser.py#L62-L75
228,248
SheffieldML/GPyOpt
GPyOpt/interface/config_parser.py
parser
def parser(input_file_path='config.json'): ''' Parser for the .json file containing the configuration of the method. ''' # --- Read .json file try: with open(input_file_path, 'r') as config_file: config_new = json.load(config_file) config_file.close() except: ...
python
def parser(input_file_path='config.json'): ''' Parser for the .json file containing the configuration of the method. ''' # --- Read .json file try: with open(input_file_path, 'r') as config_file: config_new = json.load(config_file) config_file.close() except: ...
[ "def", "parser", "(", "input_file_path", "=", "'config.json'", ")", ":", "# --- Read .json file", "try", ":", "with", "open", "(", "input_file_path", ",", "'r'", ")", "as", "config_file", ":", "config_new", "=", "json", ".", "load", "(", "config_file", ")", ...
Parser for the .json file containing the configuration of the method.
[ "Parser", "for", "the", ".", "json", "file", "containing", "the", "configuration", "of", "the", "method", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/interface/config_parser.py#L78-L94
228,249
SheffieldML/GPyOpt
GPyOpt/util/mcmc_sampler.py
AffineInvariantEnsembleSampler.get_samples
def get_samples(self, n_samples, log_p_function, burn_in_steps=50): """ Generates samples. Parameters: n_samples - number of samples to generate log_p_function - a function that returns log density for a specific sample burn_in_steps - number of burn-in steps...
python
def get_samples(self, n_samples, log_p_function, burn_in_steps=50): """ Generates samples. Parameters: n_samples - number of samples to generate log_p_function - a function that returns log density for a specific sample burn_in_steps - number of burn-in steps...
[ "def", "get_samples", "(", "self", ",", "n_samples", ",", "log_p_function", ",", "burn_in_steps", "=", "50", ")", ":", "restarts", "=", "initial_design", "(", "'random'", ",", "self", ".", "space", ",", "n_samples", ")", "sampler", "=", "emcee", ".", "Ense...
Generates samples. Parameters: n_samples - number of samples to generate log_p_function - a function that returns log density for a specific sample burn_in_steps - number of burn-in steps for sampling Returns a tuple of two array: (samples, log_p_function values for...
[ "Generates", "samples", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/util/mcmc_sampler.py#L39-L59
228,250
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO.suggest_next_locations
def suggest_next_locations(self, context = None, pending_X = None, ignored_X = None): """ Run a single optimization step and return the next locations to evaluate the objective. Number of suggested locations equals to batch_size. :param context: fixes specified variables to a particular...
python
def suggest_next_locations(self, context = None, pending_X = None, ignored_X = None): """ Run a single optimization step and return the next locations to evaluate the objective. Number of suggested locations equals to batch_size. :param context: fixes specified variables to a particular...
[ "def", "suggest_next_locations", "(", "self", ",", "context", "=", "None", ",", "pending_X", "=", "None", ",", "ignored_X", "=", "None", ")", ":", "self", ".", "model_parameters_iterations", "=", "None", "self", ".", "num_acquisitions", "=", "0", "self", "."...
Run a single optimization step and return the next locations to evaluate the objective. Number of suggested locations equals to batch_size. :param context: fixes specified variables to a particular context (values) for the optimization run (default, None). :param pending_X: matrix of input conf...
[ "Run", "a", "single", "optimization", "step", "and", "return", "the", "next", "locations", "to", "evaluate", "the", "objective", ".", "Number", "of", "suggested", "locations", "equals", "to", "batch_size", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L55-L71
228,251
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO._print_convergence
def _print_convergence(self): """ Prints the reason why the optimization stopped. """ if self.verbosity: if (self.num_acquisitions == self.max_iter) and (not self.initial_iter): print(' ** Maximum number of iterations reached **') return 1 ...
python
def _print_convergence(self): """ Prints the reason why the optimization stopped. """ if self.verbosity: if (self.num_acquisitions == self.max_iter) and (not self.initial_iter): print(' ** Maximum number of iterations reached **') return 1 ...
[ "def", "_print_convergence", "(", "self", ")", ":", "if", "self", ".", "verbosity", ":", "if", "(", "self", ".", "num_acquisitions", "==", "self", ".", "max_iter", ")", "and", "(", "not", "self", ".", "initial_iter", ")", ":", "print", "(", "' ** Maxim...
Prints the reason why the optimization stopped.
[ "Prints", "the", "reason", "why", "the", "optimization", "stopped", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L172-L190
228,252
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO.evaluate_objective
def evaluate_objective(self): """ Evaluates the objective """ self.Y_new, cost_new = self.objective.evaluate(self.suggested_sample) self.cost.update_cost_model(self.suggested_sample, cost_new) self.Y = np.vstack((self.Y,self.Y_new))
python
def evaluate_objective(self): """ Evaluates the objective """ self.Y_new, cost_new = self.objective.evaluate(self.suggested_sample) self.cost.update_cost_model(self.suggested_sample, cost_new) self.Y = np.vstack((self.Y,self.Y_new))
[ "def", "evaluate_objective", "(", "self", ")", ":", "self", ".", "Y_new", ",", "cost_new", "=", "self", ".", "objective", ".", "evaluate", "(", "self", ".", "suggested_sample", ")", "self", ".", "cost", ".", "update_cost_model", "(", "self", ".", "suggeste...
Evaluates the objective
[ "Evaluates", "the", "objective" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L193-L199
228,253
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO._compute_results
def _compute_results(self): """ Computes the optimum and its value. """ self.Y_best = best_value(self.Y) self.x_opt = self.X[np.argmin(self.Y),:] self.fx_opt = np.min(self.Y)
python
def _compute_results(self): """ Computes the optimum and its value. """ self.Y_best = best_value(self.Y) self.x_opt = self.X[np.argmin(self.Y),:] self.fx_opt = np.min(self.Y)
[ "def", "_compute_results", "(", "self", ")", ":", "self", ".", "Y_best", "=", "best_value", "(", "self", ".", "Y", ")", "self", ".", "x_opt", "=", "self", ".", "X", "[", "np", ".", "argmin", "(", "self", ".", "Y", ")", ",", ":", "]", "self", "....
Computes the optimum and its value.
[ "Computes", "the", "optimum", "and", "its", "value", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L201-L207
228,254
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO._distance_last_evaluations
def _distance_last_evaluations(self): """ Computes the distance between the last two evaluations. """ if self.X.shape[0] < 2: # less than 2 evaluations return np.inf return np.sqrt(np.sum((self.X[-1, :] - self.X[-2, :]) ** 2))
python
def _distance_last_evaluations(self): """ Computes the distance between the last two evaluations. """ if self.X.shape[0] < 2: # less than 2 evaluations return np.inf return np.sqrt(np.sum((self.X[-1, :] - self.X[-2, :]) ** 2))
[ "def", "_distance_last_evaluations", "(", "self", ")", ":", "if", "self", ".", "X", ".", "shape", "[", "0", "]", "<", "2", ":", "# less than 2 evaluations", "return", "np", ".", "inf", "return", "np", ".", "sqrt", "(", "np", ".", "sum", "(", "(", "se...
Computes the distance between the last two evaluations.
[ "Computes", "the", "distance", "between", "the", "last", "two", "evaluations", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L209-L216
228,255
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO.save_evaluations
def save_evaluations(self, evaluations_file = None): """ Saves evaluations at each iteration of the optimization :param evaluations_file: name of the file in which the results are saved. """ iterations = np.array(range(1, self.Y.shape[0] + 1))[:, None] results = np.hsta...
python
def save_evaluations(self, evaluations_file = None): """ Saves evaluations at each iteration of the optimization :param evaluations_file: name of the file in which the results are saved. """ iterations = np.array(range(1, self.Y.shape[0] + 1))[:, None] results = np.hsta...
[ "def", "save_evaluations", "(", "self", ",", "evaluations_file", "=", "None", ")", ":", "iterations", "=", "np", ".", "array", "(", "range", "(", "1", ",", "self", ".", "Y", ".", "shape", "[", "0", "]", "+", "1", ")", ")", "[", ":", ",", "None", ...
Saves evaluations at each iteration of the optimization :param evaluations_file: name of the file in which the results are saved.
[ "Saves", "evaluations", "at", "each", "iteration", "of", "the", "optimization" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L367-L378
228,256
SheffieldML/GPyOpt
GPyOpt/core/bo.py
BO.save_models
def save_models(self, models_file): """ Saves model parameters at each iteration of the optimization :param models_file: name of the file or a file buffer, in which the results are saved. """ if self.model_parameters_iterations is None: raise ValueError("No iteration...
python
def save_models(self, models_file): """ Saves model parameters at each iteration of the optimization :param models_file: name of the file or a file buffer, in which the results are saved. """ if self.model_parameters_iterations is None: raise ValueError("No iteration...
[ "def", "save_models", "(", "self", ",", "models_file", ")", ":", "if", "self", ".", "model_parameters_iterations", "is", "None", ":", "raise", "ValueError", "(", "\"No iterations have been carried out yet and hence no iterations of the BO can be saved\"", ")", "iterations", ...
Saves model parameters at each iteration of the optimization :param models_file: name of the file or a file buffer, in which the results are saved.
[ "Saves", "model", "parameters", "at", "each", "iteration", "of", "the", "optimization" ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/core/bo.py#L380-L394
228,257
SheffieldML/GPyOpt
GPyOpt/methods/bayesian_optimization.py
BayesianOptimization._init_design_chooser
def _init_design_chooser(self): """ Initializes the choice of X and Y based on the selected initial design and number of points selected. """ # If objective function was not provided, we require some initial sample data if self.f is None and (self.X is None or self.Y is None): ...
python
def _init_design_chooser(self): """ Initializes the choice of X and Y based on the selected initial design and number of points selected. """ # If objective function was not provided, we require some initial sample data if self.f is None and (self.X is None or self.Y is None): ...
[ "def", "_init_design_chooser", "(", "self", ")", ":", "# If objective function was not provided, we require some initial sample data", "if", "self", ".", "f", "is", "None", "and", "(", "self", ".", "X", "is", "None", "or", "self", ".", "Y", "is", "None", ")", ":...
Initializes the choice of X and Y based on the selected initial design and number of points selected.
[ "Initializes", "the", "choice", "of", "X", "and", "Y", "based", "on", "the", "selected", "initial", "design", "and", "number", "of", "points", "selected", "." ]
255539dc5927819ca701e44fe3d76cd4864222fa
https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/methods/bayesian_optimization.py#L183-L198
228,258
coleifer/huey
huey/api.py
crontab
def crontab(minute='*', hour='*', day='*', month='*', day_of_week='*'): """ Convert a "crontab"-style set of parameters into a test function that will return True when the given datetime matches the parameters set forth in the crontab. For day-of-week, 0=Sunday and 6=Saturday. Acceptable input...
python
def crontab(minute='*', hour='*', day='*', month='*', day_of_week='*'): """ Convert a "crontab"-style set of parameters into a test function that will return True when the given datetime matches the parameters set forth in the crontab. For day-of-week, 0=Sunday and 6=Saturday. Acceptable input...
[ "def", "crontab", "(", "minute", "=", "'*'", ",", "hour", "=", "'*'", ",", "day", "=", "'*'", ",", "month", "=", "'*'", ",", "day_of_week", "=", "'*'", ")", ":", "validation", "=", "(", "(", "'m'", ",", "month", ",", "range", "(", "1", ",", "13...
Convert a "crontab"-style set of parameters into a test function that will return True when the given datetime matches the parameters set forth in the crontab. For day-of-week, 0=Sunday and 6=Saturday. Acceptable inputs: * = every distinct value */n = run every "n" times, i.e. hours='*/4' == 0...
[ "Convert", "a", "crontab", "-", "style", "set", "of", "parameters", "into", "a", "test", "function", "that", "will", "return", "True", "when", "the", "given", "datetime", "matches", "the", "parameters", "set", "forth", "in", "the", "crontab", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/api.py#L913-L990
228,259
coleifer/huey
huey/storage.py
BaseStorage.put_if_empty
def put_if_empty(self, key, value): """ Atomically write data only if the key is not already set. :param bytes key: Key to check/set. :param bytes value: Arbitrary data. :return: Boolean whether key/value was set. """ if self.has_data_for_key(key): re...
python
def put_if_empty(self, key, value): """ Atomically write data only if the key is not already set. :param bytes key: Key to check/set. :param bytes value: Arbitrary data. :return: Boolean whether key/value was set. """ if self.has_data_for_key(key): re...
[ "def", "put_if_empty", "(", "self", ",", "key", ",", "value", ")", ":", "if", "self", ".", "has_data_for_key", "(", "key", ")", ":", "return", "False", "self", ".", "put_data", "(", "key", ",", "value", ")", "return", "True" ]
Atomically write data only if the key is not already set. :param bytes key: Key to check/set. :param bytes value: Arbitrary data. :return: Boolean whether key/value was set.
[ "Atomically", "write", "data", "only", "if", "the", "key", "is", "not", "already", "set", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/storage.py#L190-L201
228,260
coleifer/huey
huey/utils.py
make_naive
def make_naive(dt): """ Makes an aware datetime.datetime naive in local time zone. """ tt = dt.utctimetuple() ts = calendar.timegm(tt) local_tt = time.localtime(ts) return datetime.datetime(*local_tt[:6])
python
def make_naive(dt): """ Makes an aware datetime.datetime naive in local time zone. """ tt = dt.utctimetuple() ts = calendar.timegm(tt) local_tt = time.localtime(ts) return datetime.datetime(*local_tt[:6])
[ "def", "make_naive", "(", "dt", ")", ":", "tt", "=", "dt", ".", "utctimetuple", "(", ")", "ts", "=", "calendar", ".", "timegm", "(", "tt", ")", "local_tt", "=", "time", ".", "localtime", "(", "ts", ")", "return", "datetime", ".", "datetime", "(", "...
Makes an aware datetime.datetime naive in local time zone.
[ "Makes", "an", "aware", "datetime", ".", "datetime", "naive", "in", "local", "time", "zone", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/utils.py#L48-L55
228,261
coleifer/huey
huey/consumer.py
BaseProcess.sleep_for_interval
def sleep_for_interval(self, start_ts, nseconds): """ Sleep for a given interval with respect to the start timestamp. So, if the start timestamp is 1337 and nseconds is 10, the method will actually sleep for nseconds - (current_timestamp - start_timestamp). So if the current tim...
python
def sleep_for_interval(self, start_ts, nseconds): """ Sleep for a given interval with respect to the start timestamp. So, if the start timestamp is 1337 and nseconds is 10, the method will actually sleep for nseconds - (current_timestamp - start_timestamp). So if the current tim...
[ "def", "sleep_for_interval", "(", "self", ",", "start_ts", ",", "nseconds", ")", ":", "sleep_time", "=", "nseconds", "-", "(", "time", ".", "time", "(", ")", "-", "start_ts", ")", "if", "sleep_time", "<=", "0", ":", "return", "self", ".", "_logger", "....
Sleep for a given interval with respect to the start timestamp. So, if the start timestamp is 1337 and nseconds is 10, the method will actually sleep for nseconds - (current_timestamp - start_timestamp). So if the current timestamp is 1340, we'll only sleep for 7 seconds (the goal being...
[ "Sleep", "for", "a", "given", "interval", "with", "respect", "to", "the", "start", "timestamp", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/consumer.py#L39-L56
228,262
coleifer/huey
huey/consumer.py
Consumer.start
def start(self): """ Start all consumer processes and register signal handlers. """ if self.huey.immediate: raise ConfigurationError( 'Consumer cannot be run with Huey instances where immediate ' 'is enabled. Please check your configuration and...
python
def start(self): """ Start all consumer processes and register signal handlers. """ if self.huey.immediate: raise ConfigurationError( 'Consumer cannot be run with Huey instances where immediate ' 'is enabled. Please check your configuration and...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "huey", ".", "immediate", ":", "raise", "ConfigurationError", "(", "'Consumer cannot be run with Huey instances where immediate '", "'is enabled. Please check your configuration and ensure that '", "'\"huey.immediate = Fal...
Start all consumer processes and register signal handlers.
[ "Start", "all", "consumer", "processes", "and", "register", "signal", "handlers", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/consumer.py#L344-L383
228,263
coleifer/huey
huey/consumer.py
Consumer.stop
def stop(self, graceful=False): """ Set the stop-flag. If `graceful=True`, this method blocks until the workers to finish executing any tasks they might be currently working on. """ self.stop_flag.set() if graceful: self._logger.info('Shutting down gr...
python
def stop(self, graceful=False): """ Set the stop-flag. If `graceful=True`, this method blocks until the workers to finish executing any tasks they might be currently working on. """ self.stop_flag.set() if graceful: self._logger.info('Shutting down gr...
[ "def", "stop", "(", "self", ",", "graceful", "=", "False", ")", ":", "self", ".", "stop_flag", ".", "set", "(", ")", "if", "graceful", ":", "self", ".", "_logger", ".", "info", "(", "'Shutting down gracefully...'", ")", "try", ":", "for", "_", ",", "...
Set the stop-flag. If `graceful=True`, this method blocks until the workers to finish executing any tasks they might be currently working on.
[ "Set", "the", "stop", "-", "flag", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/consumer.py#L385-L403
228,264
coleifer/huey
huey/consumer.py
Consumer.run
def run(self): """ Run the consumer. """ self.start() timeout = self._stop_flag_timeout health_check_ts = time.time() while True: try: self.stop_flag.wait(timeout=timeout) except KeyboardInterrupt: self._log...
python
def run(self): """ Run the consumer. """ self.start() timeout = self._stop_flag_timeout health_check_ts = time.time() while True: try: self.stop_flag.wait(timeout=timeout) except KeyboardInterrupt: self._log...
[ "def", "run", "(", "self", ")", ":", "self", ".", "start", "(", ")", "timeout", "=", "self", ".", "_stop_flag_timeout", "health_check_ts", "=", "time", ".", "time", "(", ")", "while", "True", ":", "try", ":", "self", ".", "stop_flag", ".", "wait", "(...
Run the consumer.
[ "Run", "the", "consumer", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/consumer.py#L405-L440
228,265
coleifer/huey
huey/consumer.py
Consumer.check_worker_health
def check_worker_health(self): """ Check the health of the worker processes. Workers that have died will be replaced with new workers. """ self._logger.debug('Checking worker health.') workers = [] restart_occurred = False for i, (worker, worker_t) in enum...
python
def check_worker_health(self): """ Check the health of the worker processes. Workers that have died will be replaced with new workers. """ self._logger.debug('Checking worker health.') workers = [] restart_occurred = False for i, (worker, worker_t) in enum...
[ "def", "check_worker_health", "(", "self", ")", ":", "self", ".", "_logger", ".", "debug", "(", "'Checking worker health.'", ")", "workers", "=", "[", "]", "restart_occurred", "=", "False", "for", "i", ",", "(", "worker", ",", "worker_t", ")", "in", "enume...
Check the health of the worker processes. Workers that have died will be replaced with new workers.
[ "Check", "the", "health", "of", "the", "worker", "processes", ".", "Workers", "that", "have", "died", "will", "be", "replaced", "with", "new", "workers", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/consumer.py#L442-L472
228,266
coleifer/huey
huey/contrib/djhuey/__init__.py
close_db
def close_db(fn): """Decorator to be used with tasks that may operate on the database.""" @wraps(fn) def inner(*args, **kwargs): try: return fn(*args, **kwargs) finally: if not HUEY.immediate: close_old_connections() return inner
python
def close_db(fn): """Decorator to be used with tasks that may operate on the database.""" @wraps(fn) def inner(*args, **kwargs): try: return fn(*args, **kwargs) finally: if not HUEY.immediate: close_old_connections() return inner
[ "def", "close_db", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "fn", "(", "*", "args", ",", "*", "*", "kwargs", ")", "finally", ":", "if", "not"...
Decorator to be used with tasks that may operate on the database.
[ "Decorator", "to", "be", "used", "with", "tasks", "that", "may", "operate", "on", "the", "database", "." ]
416e8da1ca18442c08431a91bce373de7d2d200f
https://github.com/coleifer/huey/blob/416e8da1ca18442c08431a91bce373de7d2d200f/huey/contrib/djhuey/__init__.py#L123-L132
228,267
johnwheeler/flask-ask
samples/purchase/model.py
Product.list
def list(self): """ return list of purchasable and not entitled products""" mylist = [] for prod in self.product_list: if self.purchasable(prod) and not self.entitled(prod): mylist.append(prod) return mylist
python
def list(self): """ return list of purchasable and not entitled products""" mylist = [] for prod in self.product_list: if self.purchasable(prod) and not self.entitled(prod): mylist.append(prod) return mylist
[ "def", "list", "(", "self", ")", ":", "mylist", "=", "[", "]", "for", "prod", "in", "self", ".", "product_list", ":", "if", "self", ".", "purchasable", "(", "prod", ")", "and", "not", "self", ".", "entitled", "(", "prod", ")", ":", "mylist", ".", ...
return list of purchasable and not entitled products
[ "return", "list", "of", "purchasable", "and", "not", "entitled", "products" ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/samples/purchase/model.py#L51-L57
228,268
johnwheeler/flask-ask
samples/tidepooler/tidepooler.py
_find_tide_info
def _find_tide_info(predictions): """ Algorithm to find the 2 high tides for the day, the first of which is smaller and occurs mid-day, the second of which is larger and typically in the evening. """ last_prediction = None first_high_tide = None second_high_tide = None low_tide = None...
python
def _find_tide_info(predictions): """ Algorithm to find the 2 high tides for the day, the first of which is smaller and occurs mid-day, the second of which is larger and typically in the evening. """ last_prediction = None first_high_tide = None second_high_tide = None low_tide = None...
[ "def", "_find_tide_info", "(", "predictions", ")", ":", "last_prediction", "=", "None", "first_high_tide", "=", "None", "second_high_tide", "=", "None", "low_tide", "=", "None", "first_tide_done", "=", "False", "for", "prediction", "in", "predictions", ":", "if", ...
Algorithm to find the 2 high tides for the day, the first of which is smaller and occurs mid-day, the second of which is larger and typically in the evening.
[ "Algorithm", "to", "find", "the", "2", "high", "tides", "for", "the", "day", "the", "first", "of", "which", "is", "smaller", "and", "occurs", "mid", "-", "day", "the", "second", "of", "which", "is", "larger", "and", "typically", "in", "the", "evening", ...
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/samples/tidepooler/tidepooler.py#L252-L290
228,269
johnwheeler/flask-ask
flask_ask/models.py
audio.enqueue
def enqueue(self, stream_url, offset=0, opaque_token=None): """Adds stream to the queue. Does not impact the currently playing stream.""" directive = self._play_directive('ENQUEUE') audio_item = self._audio_item(stream_url=stream_url, offset=offset, ...
python
def enqueue(self, stream_url, offset=0, opaque_token=None): """Adds stream to the queue. Does not impact the currently playing stream.""" directive = self._play_directive('ENQUEUE') audio_item = self._audio_item(stream_url=stream_url, offset=offset, ...
[ "def", "enqueue", "(", "self", ",", "stream_url", ",", "offset", "=", "0", ",", "opaque_token", "=", "None", ")", ":", "directive", "=", "self", ".", "_play_directive", "(", "'ENQUEUE'", ")", "audio_item", "=", "self", ".", "_audio_item", "(", "stream_url"...
Adds stream to the queue. Does not impact the currently playing stream.
[ "Adds", "stream", "to", "the", "queue", ".", "Does", "not", "impact", "the", "currently", "playing", "stream", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/models.py#L364-L375
228,270
johnwheeler/flask-ask
flask_ask/models.py
audio.play_next
def play_next(self, stream_url=None, offset=0, opaque_token=None): """Replace all streams in the queue but does not impact the currently playing stream.""" directive = self._play_directive('REPLACE_ENQUEUED') directive['audioItem'] = self._audio_item(stream_url=stream_url, offset=offset, opaque...
python
def play_next(self, stream_url=None, offset=0, opaque_token=None): """Replace all streams in the queue but does not impact the currently playing stream.""" directive = self._play_directive('REPLACE_ENQUEUED') directive['audioItem'] = self._audio_item(stream_url=stream_url, offset=offset, opaque...
[ "def", "play_next", "(", "self", ",", "stream_url", "=", "None", ",", "offset", "=", "0", ",", "opaque_token", "=", "None", ")", ":", "directive", "=", "self", ".", "_play_directive", "(", "'REPLACE_ENQUEUED'", ")", "directive", "[", "'audioItem'", "]", "=...
Replace all streams in the queue but does not impact the currently playing stream.
[ "Replace", "all", "streams", "in", "the", "queue", "but", "does", "not", "impact", "the", "currently", "playing", "stream", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/models.py#L377-L383
228,271
johnwheeler/flask-ask
flask_ask/models.py
audio.resume
def resume(self): """Sends Play Directive to resume playback at the paused offset""" directive = self._play_directive('REPLACE_ALL') directive['audioItem'] = self._audio_item() self._response['directives'].append(directive) return self
python
def resume(self): """Sends Play Directive to resume playback at the paused offset""" directive = self._play_directive('REPLACE_ALL') directive['audioItem'] = self._audio_item() self._response['directives'].append(directive) return self
[ "def", "resume", "(", "self", ")", ":", "directive", "=", "self", ".", "_play_directive", "(", "'REPLACE_ALL'", ")", "directive", "[", "'audioItem'", "]", "=", "self", ".", "_audio_item", "(", ")", "self", ".", "_response", "[", "'directives'", "]", ".", ...
Sends Play Directive to resume playback at the paused offset
[ "Sends", "Play", "Directive", "to", "resume", "playback", "at", "the", "paused", "offset" ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/models.py#L385-L390
228,272
johnwheeler/flask-ask
flask_ask/models.py
audio._audio_item
def _audio_item(self, stream_url=None, offset=0, push_buffer=True, opaque_token=None): """Builds an AudioPlayer Directive's audioItem and updates current_stream""" audio_item = {'stream': {}} stream = audio_item['stream'] # existing stream if not stream_url: # stream...
python
def _audio_item(self, stream_url=None, offset=0, push_buffer=True, opaque_token=None): """Builds an AudioPlayer Directive's audioItem and updates current_stream""" audio_item = {'stream': {}} stream = audio_item['stream'] # existing stream if not stream_url: # stream...
[ "def", "_audio_item", "(", "self", ",", "stream_url", "=", "None", ",", "offset", "=", "0", ",", "push_buffer", "=", "True", ",", "opaque_token", "=", "None", ")", ":", "audio_item", "=", "{", "'stream'", ":", "{", "}", "}", "stream", "=", "audio_item"...
Builds an AudioPlayer Directive's audioItem and updates current_stream
[ "Builds", "an", "AudioPlayer", "Directive", "s", "audioItem", "and", "updates", "current_stream" ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/models.py#L398-L418
228,273
johnwheeler/flask-ask
flask_ask/models.py
audio.clear_queue
def clear_queue(self, stop=False): """Clears queued streams and optionally stops current stream. Keyword Arguments: stop {bool} set True to stop current current stream and clear queued streams. set False to clear queued streams and allow current stream to finish ...
python
def clear_queue(self, stop=False): """Clears queued streams and optionally stops current stream. Keyword Arguments: stop {bool} set True to stop current current stream and clear queued streams. set False to clear queued streams and allow current stream to finish ...
[ "def", "clear_queue", "(", "self", ",", "stop", "=", "False", ")", ":", "directive", "=", "{", "}", "directive", "[", "'type'", "]", "=", "'AudioPlayer.ClearQueue'", "if", "stop", ":", "directive", "[", "'clearBehavior'", "]", "=", "'CLEAR_ALL'", "else", "...
Clears queued streams and optionally stops current stream. Keyword Arguments: stop {bool} set True to stop current current stream and clear queued streams. set False to clear queued streams and allow current stream to finish default: {False}
[ "Clears", "queued", "streams", "and", "optionally", "stops", "current", "stream", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/models.py#L425-L442
228,274
johnwheeler/flask-ask
flask_ask/core.py
find_ask
def find_ask(): """ Find our instance of Ask, navigating Local's and possible blueprints. Note: This only supports returning a reference to the first instance of Ask found. """ if hasattr(current_app, 'ask'): return getattr(current_app, 'ask') else: if hasattr(current_app, '...
python
def find_ask(): """ Find our instance of Ask, navigating Local's and possible blueprints. Note: This only supports returning a reference to the first instance of Ask found. """ if hasattr(current_app, 'ask'): return getattr(current_app, 'ask') else: if hasattr(current_app, '...
[ "def", "find_ask", "(", ")", ":", "if", "hasattr", "(", "current_app", ",", "'ask'", ")", ":", "return", "getattr", "(", "current_app", ",", "'ask'", ")", "else", ":", "if", "hasattr", "(", "current_app", ",", "'blueprints'", ")", ":", "blueprints", "=",...
Find our instance of Ask, navigating Local's and possible blueprints. Note: This only supports returning a reference to the first instance of Ask found.
[ "Find", "our", "instance", "of", "Ask", "navigating", "Local", "s", "and", "possible", "blueprints", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L21-L35
228,275
johnwheeler/flask-ask
flask_ask/core.py
Ask.init_app
def init_app(self, app, path='templates.yaml'): """Initializes Ask app by setting configuration variables, loading templates, and maps Ask route to a flask view. The Ask instance is given the following configuration variables by calling on Flask's configuration: `ASK_APPLICATION_ID`: ...
python
def init_app(self, app, path='templates.yaml'): """Initializes Ask app by setting configuration variables, loading templates, and maps Ask route to a flask view. The Ask instance is given the following configuration variables by calling on Flask's configuration: `ASK_APPLICATION_ID`: ...
[ "def", "init_app", "(", "self", ",", "app", ",", "path", "=", "'templates.yaml'", ")", ":", "if", "self", ".", "_route", "is", "None", ":", "raise", "TypeError", "(", "\"route is a required argument when app is not None\"", ")", "self", ".", "app", "=", "app",...
Initializes Ask app by setting configuration variables, loading templates, and maps Ask route to a flask view. The Ask instance is given the following configuration variables by calling on Flask's configuration: `ASK_APPLICATION_ID`: Turn on application ID verification by setting this var...
[ "Initializes", "Ask", "app", "by", "setting", "configuration", "variables", "loading", "templates", "and", "maps", "Ask", "route", "to", "a", "flask", "view", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L101-L142
228,276
johnwheeler/flask-ask
flask_ask/core.py
Ask.launch
def launch(self, f): """Decorator maps a view function as the endpoint for an Alexa LaunchRequest and starts the skill. @ask.launch def launched(): return question('Welcome to Foo') The wrapped function is registered as the launch view function and renders the response ...
python
def launch(self, f): """Decorator maps a view function as the endpoint for an Alexa LaunchRequest and starts the skill. @ask.launch def launched(): return question('Welcome to Foo') The wrapped function is registered as the launch view function and renders the response ...
[ "def", "launch", "(", "self", ",", "f", ")", ":", "self", ".", "_launch_view_func", "=", "f", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "self", ".", "_flask_view_func", "(", "*", "args", ",", ...
Decorator maps a view function as the endpoint for an Alexa LaunchRequest and starts the skill. @ask.launch def launched(): return question('Welcome to Foo') The wrapped function is registered as the launch view function and renders the response for requests to the Launch U...
[ "Decorator", "maps", "a", "view", "function", "as", "the", "endpoint", "for", "an", "Alexa", "LaunchRequest", "and", "starts", "the", "skill", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L192-L212
228,277
johnwheeler/flask-ask
flask_ask/core.py
Ask.session_ended
def session_ended(self, f): """Decorator routes Alexa SessionEndedRequest to the wrapped view function to end the skill. @ask.session_ended def session_ended(): return "{}", 200 The wrapped function is registered as the session_ended view function and renders the re...
python
def session_ended(self, f): """Decorator routes Alexa SessionEndedRequest to the wrapped view function to end the skill. @ask.session_ended def session_ended(): return "{}", 200 The wrapped function is registered as the session_ended view function and renders the re...
[ "def", "session_ended", "(", "self", ",", "f", ")", ":", "self", ".", "_session_ended_view_func", "=", "f", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "self", ".", "_flask_view_func", "(", "*", "...
Decorator routes Alexa SessionEndedRequest to the wrapped view function to end the skill. @ask.session_ended def session_ended(): return "{}", 200 The wrapped function is registered as the session_ended view function and renders the response for requests to the end of the s...
[ "Decorator", "routes", "Alexa", "SessionEndedRequest", "to", "the", "wrapped", "view", "function", "to", "end", "the", "skill", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L214-L232
228,278
johnwheeler/flask-ask
flask_ask/core.py
Ask.intent
def intent(self, intent_name, mapping={}, convert={}, default={}): """Decorator routes an Alexa IntentRequest and provides the slot parameters to the wrapped function. Functions decorated as an intent are registered as the view function for the Intent's URL, and provide the backend responses to...
python
def intent(self, intent_name, mapping={}, convert={}, default={}): """Decorator routes an Alexa IntentRequest and provides the slot parameters to the wrapped function. Functions decorated as an intent are registered as the view function for the Intent's URL, and provide the backend responses to...
[ "def", "intent", "(", "self", ",", "intent_name", ",", "mapping", "=", "{", "}", ",", "convert", "=", "{", "}", ",", "default", "=", "{", "}", ")", ":", "def", "decorator", "(", "f", ")", ":", "self", ".", "_intent_view_funcs", "[", "intent_name", ...
Decorator routes an Alexa IntentRequest and provides the slot parameters to the wrapped function. Functions decorated as an intent are registered as the view function for the Intent's URL, and provide the backend responses to give your Skill its functionality. @ask.intent('WeatherIntent', mapp...
[ "Decorator", "routes", "an", "Alexa", "IntentRequest", "and", "provides", "the", "slot", "parameters", "to", "the", "wrapped", "function", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L234-L268
228,279
johnwheeler/flask-ask
flask_ask/core.py
Ask.default_intent
def default_intent(self, f): """Decorator routes any Alexa IntentRequest that is not matched by any existing @ask.intent routing.""" self._default_intent_view_func = f @wraps(f) def wrapper(*args, **kw): self._flask_view_func(*args, **kw) return f
python
def default_intent(self, f): """Decorator routes any Alexa IntentRequest that is not matched by any existing @ask.intent routing.""" self._default_intent_view_func = f @wraps(f) def wrapper(*args, **kw): self._flask_view_func(*args, **kw) return f
[ "def", "default_intent", "(", "self", ",", "f", ")", ":", "self", ".", "_default_intent_view_func", "=", "f", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "self", ".", "_flask_view_func", "(", "*", ...
Decorator routes any Alexa IntentRequest that is not matched by any existing @ask.intent routing.
[ "Decorator", "routes", "any", "Alexa", "IntentRequest", "that", "is", "not", "matched", "by", "any", "existing" ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L270-L277
228,280
johnwheeler/flask-ask
flask_ask/core.py
Ask.display_element_selected
def display_element_selected(self, f): """Decorator routes Alexa Display.ElementSelected request to the wrapped view function. @ask.display_element_selected def eval_element(): return "", 200 The wrapped function is registered as the display_element_selected view function ...
python
def display_element_selected(self, f): """Decorator routes Alexa Display.ElementSelected request to the wrapped view function. @ask.display_element_selected def eval_element(): return "", 200 The wrapped function is registered as the display_element_selected view function ...
[ "def", "display_element_selected", "(", "self", ",", "f", ")", ":", "self", ".", "_display_element_selected_func", "=", "f", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "self", ".", "_flask_view_func", ...
Decorator routes Alexa Display.ElementSelected request to the wrapped view function. @ask.display_element_selected def eval_element(): return "", 200 The wrapped function is registered as the display_element_selected view function and renders the response for requests. ...
[ "Decorator", "routes", "Alexa", "Display", ".", "ElementSelected", "request", "to", "the", "wrapped", "view", "function", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L279-L297
228,281
johnwheeler/flask-ask
flask_ask/core.py
Ask.on_purchase_completed
def on_purchase_completed(self, mapping={'payload': 'payload','name':'name','status':'status','token':'token'}, convert={}, default={}): """Decorator routes an Connections.Response to the wrapped function. Request is sent when Alexa completes the purchase flow. See https://developer.amazon.co...
python
def on_purchase_completed(self, mapping={'payload': 'payload','name':'name','status':'status','token':'token'}, convert={}, default={}): """Decorator routes an Connections.Response to the wrapped function. Request is sent when Alexa completes the purchase flow. See https://developer.amazon.co...
[ "def", "on_purchase_completed", "(", "self", ",", "mapping", "=", "{", "'payload'", ":", "'payload'", ",", "'name'", ":", "'name'", ",", "'status'", ":", "'status'", ",", "'token'", ":", "'token'", "}", ",", "convert", "=", "{", "}", ",", "default", "=",...
Decorator routes an Connections.Response to the wrapped function. Request is sent when Alexa completes the purchase flow. See https://developer.amazon.com/docs/in-skill-purchase/add-isps-to-a-skill.html#handle-results The wrapped view function may accept parameters from the Request. ...
[ "Decorator", "routes", "an", "Connections", ".", "Response", "to", "the", "wrapped", "function", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L300-L328
228,282
johnwheeler/flask-ask
flask_ask/core.py
Ask.run_aws_lambda
def run_aws_lambda(self, event): """Invoke the Flask Ask application from an AWS Lambda function handler. Use this method to service AWS Lambda requests from a custom Alexa skill. This method will invoke your Flask application providing a WSGI-compatible environment that wraps the origi...
python
def run_aws_lambda(self, event): """Invoke the Flask Ask application from an AWS Lambda function handler. Use this method to service AWS Lambda requests from a custom Alexa skill. This method will invoke your Flask application providing a WSGI-compatible environment that wraps the origi...
[ "def", "run_aws_lambda", "(", "self", ",", "event", ")", ":", "# We are guaranteed to be called by AWS as a Lambda function does not", "# expose a public facing interface.", "self", ".", "app", ".", "config", "[", "'ASK_VERIFY_REQUESTS'", "]", "=", "False", "# Convert an envi...
Invoke the Flask Ask application from an AWS Lambda function handler. Use this method to service AWS Lambda requests from a custom Alexa skill. This method will invoke your Flask application providing a WSGI-compatible environment that wraps the original Alexa event provided to the AWS ...
[ "Invoke", "the", "Flask", "Ask", "application", "from", "an", "AWS", "Lambda", "function", "handler", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L585-L683
228,283
johnwheeler/flask-ask
flask_ask/core.py
Ask._parse_timestamp
def _parse_timestamp(timestamp): """ Parse a given timestamp value, raising ValueError if None or Flasey """ if timestamp: try: return aniso8601.parse_datetime(timestamp) except AttributeError: # raised by aniso8601 if raw_timestamp...
python
def _parse_timestamp(timestamp): """ Parse a given timestamp value, raising ValueError if None or Flasey """ if timestamp: try: return aniso8601.parse_datetime(timestamp) except AttributeError: # raised by aniso8601 if raw_timestamp...
[ "def", "_parse_timestamp", "(", "timestamp", ")", ":", "if", "timestamp", ":", "try", ":", "return", "aniso8601", ".", "parse_datetime", "(", "timestamp", ")", "except", "AttributeError", ":", "# raised by aniso8601 if raw_timestamp is not valid string", "# in ISO8601 for...
Parse a given timestamp value, raising ValueError if None or Flasey
[ "Parse", "a", "given", "timestamp", "value", "raising", "ValueError", "if", "None", "or", "Flasey" ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L724-L740
228,284
johnwheeler/flask-ask
flask_ask/core.py
Ask._map_player_request_to_func
def _map_player_request_to_func(self, player_request_type): """Provides appropriate parameters to the on_playback functions.""" # calbacks for on_playback requests are optional view_func = self._intent_view_funcs.get(player_request_type, lambda: None) argspec = inspect.getargspec(view_f...
python
def _map_player_request_to_func(self, player_request_type): """Provides appropriate parameters to the on_playback functions.""" # calbacks for on_playback requests are optional view_func = self._intent_view_funcs.get(player_request_type, lambda: None) argspec = inspect.getargspec(view_f...
[ "def", "_map_player_request_to_func", "(", "self", ",", "player_request_type", ")", ":", "# calbacks for on_playback requests are optional", "view_func", "=", "self", ".", "_intent_view_funcs", ".", "get", "(", "player_request_type", ",", "lambda", ":", "None", ")", "ar...
Provides appropriate parameters to the on_playback functions.
[ "Provides", "appropriate", "parameters", "to", "the", "on_playback", "functions", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L842-L851
228,285
johnwheeler/flask-ask
flask_ask/core.py
Ask._map_purchase_request_to_func
def _map_purchase_request_to_func(self, purchase_request_type): """Provides appropriate parameters to the on_purchase functions.""" if purchase_request_type in self._intent_view_funcs: view_func = self._intent_view_funcs[purchase_request_type] else: raise NotImpl...
python
def _map_purchase_request_to_func(self, purchase_request_type): """Provides appropriate parameters to the on_purchase functions.""" if purchase_request_type in self._intent_view_funcs: view_func = self._intent_view_funcs[purchase_request_type] else: raise NotImpl...
[ "def", "_map_purchase_request_to_func", "(", "self", ",", "purchase_request_type", ")", ":", "if", "purchase_request_type", "in", "self", ".", "_intent_view_funcs", ":", "view_func", "=", "self", ".", "_intent_view_funcs", "[", "purchase_request_type", "]", "else", ":...
Provides appropriate parameters to the on_purchase functions.
[ "Provides", "appropriate", "parameters", "to", "the", "on_purchase", "functions", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/core.py#L853-L866
228,286
johnwheeler/flask-ask
flask_ask/cache.py
push_stream
def push_stream(cache, user_id, stream): """ Push a stream onto the stream stack in cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :param stream: stream object to push onto stack :return: True on successful update, False if fa...
python
def push_stream(cache, user_id, stream): """ Push a stream onto the stream stack in cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :param stream: stream object to push onto stack :return: True on successful update, False if fa...
[ "def", "push_stream", "(", "cache", ",", "user_id", ",", "stream", ")", ":", "stack", "=", "cache", ".", "get", "(", "user_id", ")", "if", "stack", "is", "None", ":", "stack", "=", "[", "]", "if", "stream", ":", "stack", ".", "append", "(", "stream...
Push a stream onto the stream stack in cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :param stream: stream object to push onto stack :return: True on successful update, False if failed to update, None if invalid input wa...
[ "Push", "a", "stream", "onto", "the", "stream", "stack", "in", "cache", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/cache.py#L6-L24
228,287
johnwheeler/flask-ask
flask_ask/cache.py
pop_stream
def pop_stream(cache, user_id): """ Pop an item off the stack in the cache. If stack is empty after pop, it deletes the stack. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item from stack, otherwise None """ stack = cache.g...
python
def pop_stream(cache, user_id): """ Pop an item off the stack in the cache. If stack is empty after pop, it deletes the stack. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item from stack, otherwise None """ stack = cache.g...
[ "def", "pop_stream", "(", "cache", ",", "user_id", ")", ":", "stack", "=", "cache", ".", "get", "(", "user_id", ")", "if", "stack", "is", "None", ":", "return", "None", "result", "=", "stack", ".", "pop", "(", ")", "if", "len", "(", "stack", ")", ...
Pop an item off the stack in the cache. If stack is empty after pop, it deletes the stack. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item from stack, otherwise None
[ "Pop", "an", "item", "off", "the", "stack", "in", "the", "cache", ".", "If", "stack", "is", "empty", "after", "pop", "it", "deletes", "the", "stack", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/cache.py#L27-L48
228,288
johnwheeler/flask-ask
flask_ask/cache.py
top_stream
def top_stream(cache, user_id): """ Peek at the top of the stack in the cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item in user's cached stack, otherwise None """ if not user_id: return None stack = ca...
python
def top_stream(cache, user_id): """ Peek at the top of the stack in the cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item in user's cached stack, otherwise None """ if not user_id: return None stack = ca...
[ "def", "top_stream", "(", "cache", ",", "user_id", ")", ":", "if", "not", "user_id", ":", "return", "None", "stack", "=", "cache", ".", "get", "(", "user_id", ")", "if", "stack", "is", "None", ":", "return", "None", "return", "stack", ".", "pop", "("...
Peek at the top of the stack in the cache. :param cache: werkzeug BasicCache-like object :param user_id: id of user, used as key in cache :return: top item in user's cached stack, otherwise None
[ "Peek", "at", "the", "top", "of", "the", "stack", "in", "the", "cache", "." ]
fe407646ae404a8c90b363c86d5c4c201b6a5580
https://github.com/johnwheeler/flask-ask/blob/fe407646ae404a8c90b363c86d5c4c201b6a5580/flask_ask/cache.py#L65-L80
228,289
ecederstrand/exchangelib
exchangelib/transport.py
wrap
def wrap(content, version, account=None): """ Generate the necessary boilerplate XML for a raw SOAP request. The XML is specific to the server version. ExchangeImpersonation allows to act as the user we want to impersonate. """ envelope = create_element('s:Envelope', nsmap=ns_translation) header...
python
def wrap(content, version, account=None): """ Generate the necessary boilerplate XML for a raw SOAP request. The XML is specific to the server version. ExchangeImpersonation allows to act as the user we want to impersonate. """ envelope = create_element('s:Envelope', nsmap=ns_translation) header...
[ "def", "wrap", "(", "content", ",", "version", ",", "account", "=", "None", ")", ":", "envelope", "=", "create_element", "(", "'s:Envelope'", ",", "nsmap", "=", "ns_translation", ")", "header", "=", "create_element", "(", "'s:Header'", ")", "requestserverversi...
Generate the necessary boilerplate XML for a raw SOAP request. The XML is specific to the server version. ExchangeImpersonation allows to act as the user we want to impersonate.
[ "Generate", "the", "necessary", "boilerplate", "XML", "for", "a", "raw", "SOAP", "request", ".", "The", "XML", "is", "specific", "to", "the", "server", "version", ".", "ExchangeImpersonation", "allows", "to", "act", "as", "the", "user", "we", "want", "to", ...
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/transport.py#L49-L73
228,290
ecederstrand/exchangelib
exchangelib/autodiscover.py
discover
def discover(email, credentials): """ Performs the autodiscover dance and returns the primary SMTP address of the account and a Protocol on success. The autodiscover and EWS server might not be the same, so we use a different Protocol to do the autodiscover request, and return a hopefully-cached Protoco...
python
def discover(email, credentials): """ Performs the autodiscover dance and returns the primary SMTP address of the account and a Protocol on success. The autodiscover and EWS server might not be the same, so we use a different Protocol to do the autodiscover request, and return a hopefully-cached Protoco...
[ "def", "discover", "(", "email", ",", "credentials", ")", ":", "log", ".", "debug", "(", "'Attempting autodiscover on email %s'", ",", "email", ")", "if", "not", "isinstance", "(", "credentials", ",", "Credentials", ")", ":", "raise", "ValueError", "(", "\"'cr...
Performs the autodiscover dance and returns the primary SMTP address of the account and a Protocol on success. The autodiscover and EWS server might not be the same, so we use a different Protocol to do the autodiscover request, and return a hopefully-cached Protocol to the callee.
[ "Performs", "the", "autodiscover", "dance", "and", "returns", "the", "primary", "SMTP", "address", "of", "the", "account", "and", "a", "Protocol", "on", "success", ".", "The", "autodiscover", "and", "EWS", "server", "might", "not", "be", "the", "same", "so",...
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/autodiscover.py#L173-L223
228,291
ecederstrand/exchangelib
exchangelib/properties.py
TimeZone.to_server_timezone
def to_server_timezone(self, timezones, for_year): """Returns the Microsoft timezone ID corresponding to this timezone. There may not be a match at all, and there may be multiple matches. If so, we return a random timezone ID. :param timezones: A list of server timezones, as returned by ...
python
def to_server_timezone(self, timezones, for_year): """Returns the Microsoft timezone ID corresponding to this timezone. There may not be a match at all, and there may be multiple matches. If so, we return a random timezone ID. :param timezones: A list of server timezones, as returned by ...
[ "def", "to_server_timezone", "(", "self", ",", "timezones", ",", "for_year", ")", ":", "candidates", "=", "set", "(", ")", "for", "tz_id", ",", "tz_name", ",", "tz_periods", ",", "tz_transitions", ",", "tz_transitions_groups", "in", "timezones", ":", "candidat...
Returns the Microsoft timezone ID corresponding to this timezone. There may not be a match at all, and there may be multiple matches. If so, we return a random timezone ID. :param timezones: A list of server timezones, as returned by list(account.protocol.get_timezones(return_full_timezone_...
[ "Returns", "the", "Microsoft", "timezone", "ID", "corresponding", "to", "this", "timezone", ".", "There", "may", "not", "be", "a", "match", "at", "all", "and", "there", "may", "be", "multiple", "matches", ".", "If", "so", "we", "return", "a", "random", "...
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/properties.py#L560-L603
228,292
ecederstrand/exchangelib
exchangelib/protocol.py
BaseProtocol.decrease_poolsize
def decrease_poolsize(self): """Decreases the session pool size in response to error messages from the server requesting to rate-limit requests. We decrease by one session per call. """ # Take a single session from the pool and discard it. We need to protect this with a lock while we are...
python
def decrease_poolsize(self): """Decreases the session pool size in response to error messages from the server requesting to rate-limit requests. We decrease by one session per call. """ # Take a single session from the pool and discard it. We need to protect this with a lock while we are...
[ "def", "decrease_poolsize", "(", "self", ")", ":", "# Take a single session from the pool and discard it. We need to protect this with a lock while we are changing", "# the pool size variable, to avoid race conditions. We must keep at least one session in the pool.", "if", "self", ".", "_sessi...
Decreases the session pool size in response to error messages from the server requesting to rate-limit requests. We decrease by one session per call.
[ "Decreases", "the", "session", "pool", "size", "in", "response", "to", "error", "messages", "from", "the", "server", "requesting", "to", "rate", "-", "limit", "requests", ".", "We", "decrease", "by", "one", "session", "per", "call", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/protocol.py#L100-L115
228,293
ecederstrand/exchangelib
exchangelib/util.py
is_iterable
def is_iterable(value, generators_allowed=False): """ Checks if value is a list-like object. Don't match generators and generator-like objects here by default, because callers don't necessarily guarantee that they only iterate the value once. Take care to not match string types and bytes. :param va...
python
def is_iterable(value, generators_allowed=False): """ Checks if value is a list-like object. Don't match generators and generator-like objects here by default, because callers don't necessarily guarantee that they only iterate the value once. Take care to not match string types and bytes. :param va...
[ "def", "is_iterable", "(", "value", ",", "generators_allowed", "=", "False", ")", ":", "if", "generators_allowed", ":", "if", "not", "isinstance", "(", "value", ",", "string_types", "+", "(", "bytes", ",", ")", ")", "and", "hasattr", "(", "value", ",", "...
Checks if value is a list-like object. Don't match generators and generator-like objects here by default, because callers don't necessarily guarantee that they only iterate the value once. Take care to not match string types and bytes. :param value: any type of object :param generators_allowed: if True...
[ "Checks", "if", "value", "is", "a", "list", "-", "like", "object", ".", "Don", "t", "match", "generators", "and", "generator", "-", "like", "objects", "here", "by", "default", "because", "callers", "don", "t", "necessarily", "guarantee", "that", "they", "o...
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L64-L80
228,294
ecederstrand/exchangelib
exchangelib/util.py
chunkify
def chunkify(iterable, chunksize): """ Splits an iterable into chunks of size ``chunksize``. The last chunk may be smaller than ``chunksize``. """ from .queryset import QuerySet if hasattr(iterable, '__getitem__') and not isinstance(iterable, QuerySet): # tuple, list. QuerySet has __getitem_...
python
def chunkify(iterable, chunksize): """ Splits an iterable into chunks of size ``chunksize``. The last chunk may be smaller than ``chunksize``. """ from .queryset import QuerySet if hasattr(iterable, '__getitem__') and not isinstance(iterable, QuerySet): # tuple, list. QuerySet has __getitem_...
[ "def", "chunkify", "(", "iterable", ",", "chunksize", ")", ":", "from", ".", "queryset", "import", "QuerySet", "if", "hasattr", "(", "iterable", ",", "'__getitem__'", ")", "and", "not", "isinstance", "(", "iterable", ",", "QuerySet", ")", ":", "# tuple, list...
Splits an iterable into chunks of size ``chunksize``. The last chunk may be smaller than ``chunksize``.
[ "Splits", "an", "iterable", "into", "chunks", "of", "size", "chunksize", ".", "The", "last", "chunk", "may", "be", "smaller", "than", "chunksize", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L83-L101
228,295
ecederstrand/exchangelib
exchangelib/util.py
peek
def peek(iterable): """ Checks if an iterable is empty and returns status and the rewinded iterable """ from .queryset import QuerySet if isinstance(iterable, QuerySet): # QuerySet has __len__ but that evaluates the entire query greedily. We don't want that here. Instead, peek() # sh...
python
def peek(iterable): """ Checks if an iterable is empty and returns status and the rewinded iterable """ from .queryset import QuerySet if isinstance(iterable, QuerySet): # QuerySet has __len__ but that evaluates the entire query greedily. We don't want that here. Instead, peek() # sh...
[ "def", "peek", "(", "iterable", ")", ":", "from", ".", "queryset", "import", "QuerySet", "if", "isinstance", "(", "iterable", ",", "QuerySet", ")", ":", "# QuerySet has __len__ but that evaluates the entire query greedily. We don't want that here. Instead, peek()", "# should ...
Checks if an iterable is empty and returns status and the rewinded iterable
[ "Checks", "if", "an", "iterable", "is", "empty", "and", "returns", "status", "and", "the", "rewinded", "iterable" ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L104-L122
228,296
ecederstrand/exchangelib
exchangelib/util.py
xml_to_str
def xml_to_str(tree, encoding=None, xml_declaration=False): """Serialize an XML tree. Returns unicode if 'encoding' is None. Otherwise, we return encoded 'bytes'.""" if xml_declaration and not encoding: raise ValueError("'xml_declaration' is not supported when 'encoding' is None") if encoding: ...
python
def xml_to_str(tree, encoding=None, xml_declaration=False): """Serialize an XML tree. Returns unicode if 'encoding' is None. Otherwise, we return encoded 'bytes'.""" if xml_declaration and not encoding: raise ValueError("'xml_declaration' is not supported when 'encoding' is None") if encoding: ...
[ "def", "xml_to_str", "(", "tree", ",", "encoding", "=", "None", ",", "xml_declaration", "=", "False", ")", ":", "if", "xml_declaration", "and", "not", "encoding", ":", "raise", "ValueError", "(", "\"'xml_declaration' is not supported when 'encoding' is None\"", ")", ...
Serialize an XML tree. Returns unicode if 'encoding' is None. Otherwise, we return encoded 'bytes'.
[ "Serialize", "an", "XML", "tree", ".", "Returns", "unicode", "if", "encoding", "is", "None", ".", "Otherwise", "we", "return", "encoded", "bytes", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L125-L131
228,297
ecederstrand/exchangelib
exchangelib/util.py
is_xml
def is_xml(text): """ Helper function. Lightweight test if response is an XML doc """ # BOM_UTF8 is an UTF-8 byte order mark which may precede the XML from an Exchange server bom_len = len(BOM_UTF8) if text[:bom_len] == BOM_UTF8: return text[bom_len:bom_len + 5] == b'<?xml' return te...
python
def is_xml(text): """ Helper function. Lightweight test if response is an XML doc """ # BOM_UTF8 is an UTF-8 byte order mark which may precede the XML from an Exchange server bom_len = len(BOM_UTF8) if text[:bom_len] == BOM_UTF8: return text[bom_len:bom_len + 5] == b'<?xml' return te...
[ "def", "is_xml", "(", "text", ")", ":", "# BOM_UTF8 is an UTF-8 byte order mark which may precede the XML from an Exchange server", "bom_len", "=", "len", "(", "BOM_UTF8", ")", "if", "text", "[", ":", "bom_len", "]", "==", "BOM_UTF8", ":", "return", "text", "[", "bo...
Helper function. Lightweight test if response is an XML doc
[ "Helper", "function", ".", "Lightweight", "test", "if", "response", "is", "an", "XML", "doc" ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/util.py#L391-L399
228,298
ecederstrand/exchangelib
exchangelib/services.py
GetItem.call
def call(self, items, additional_fields, shape): """ Returns all items in an account that correspond to a list of ID's, in stable order. :param items: a list of (id, changekey) tuples or Item objects :param additional_fields: the extra fields that should be returned with the item, as Fi...
python
def call(self, items, additional_fields, shape): """ Returns all items in an account that correspond to a list of ID's, in stable order. :param items: a list of (id, changekey) tuples or Item objects :param additional_fields: the extra fields that should be returned with the item, as Fi...
[ "def", "call", "(", "self", ",", "items", ",", "additional_fields", ",", "shape", ")", ":", "return", "self", ".", "_pool_requests", "(", "payload_func", "=", "self", ".", "get_payload", ",", "*", "*", "dict", "(", "items", "=", "items", ",", "additional...
Returns all items in an account that correspond to a list of ID's, in stable order. :param items: a list of (id, changekey) tuples or Item objects :param additional_fields: the extra fields that should be returned with the item, as FieldPath objects :param shape: The shape of returned objects ...
[ "Returns", "all", "items", "in", "an", "account", "that", "correspond", "to", "a", "list", "of", "ID", "s", "in", "stable", "order", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/services.py#L689-L702
228,299
ecederstrand/exchangelib
exchangelib/services.py
FindFolder.call
def call(self, additional_fields, restriction, shape, depth, max_items, offset): """ Find subfolders of a folder. :param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects :param shape: The set of attributes to return :param depth: ...
python
def call(self, additional_fields, restriction, shape, depth, max_items, offset): """ Find subfolders of a folder. :param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects :param shape: The set of attributes to return :param depth: ...
[ "def", "call", "(", "self", ",", "additional_fields", ",", "restriction", ",", "shape", ",", "depth", ",", "max_items", ",", "offset", ")", ":", "from", ".", "folders", "import", "Folder", "roots", "=", "{", "f", ".", "root", "for", "f", "in", "self", ...
Find subfolders of a folder. :param additional_fields: the extra fields that should be returned with the folder, as FieldPath objects :param shape: The set of attributes to return :param depth: How deep in the folder structure to search for folders :param max_items: The maximum number o...
[ "Find", "subfolders", "of", "a", "folder", "." ]
736347b337c239fcd6d592db5b29e819f753c1ba
https://github.com/ecederstrand/exchangelib/blob/736347b337c239fcd6d592db5b29e819f753c1ba/exchangelib/services.py#L1067-L1094