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
partition
stringclasses
1 value
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAAdaptSigmaBase._update_ps
def _update_ps(self, es): """update the isotropic evolution path :type es: CMAEvolutionStrategy """ if not self.is_initialized_base: self.initialize_base(es) if self._ps_updated_iteration == es.countiter: return if es.countiter <= es.itereigenupda...
python
def _update_ps(self, es): """update the isotropic evolution path :type es: CMAEvolutionStrategy """ if not self.is_initialized_base: self.initialize_base(es) if self._ps_updated_iteration == es.countiter: return if es.countiter <= es.itereigenupda...
[ "def", "_update_ps", "(", "self", ",", "es", ")", ":", "if", "not", "self", ".", "is_initialized_base", ":", "self", ".", "initialize_base", "(", "es", ")", "if", "self", ".", "_ps_updated_iteration", "==", "es", ".", "countiter", ":", "return", "if", "e...
update the isotropic evolution path :type es: CMAEvolutionStrategy
[ "update", "the", "isotropic", "evolution", "path" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L2131-L2148
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAEvolutionStrategy.stop
def stop(self, check=True): """return a dictionary with the termination status. With ``check==False``, the termination conditions are not checked and the status might not reflect the current situation. """ if (check and self.countiter > 0 and self.opts['termination_callback'] an...
python
def stop(self, check=True): """return a dictionary with the termination status. With ``check==False``, the termination conditions are not checked and the status might not reflect the current situation. """ if (check and self.countiter > 0 and self.opts['termination_callback'] an...
[ "def", "stop", "(", "self", ",", "check", "=", "True", ")", ":", "if", "(", "check", "and", "self", ".", "countiter", ">", "0", "and", "self", ".", "opts", "[", "'termination_callback'", "]", "and", "self", ".", "opts", "[", "'termination_callback'", "...
return a dictionary with the termination status. With ``check==False``, the termination conditions are not checked and the status might not reflect the current situation.
[ "return", "a", "dictionary", "with", "the", "termination", "status", ".", "With", "check", "==", "False", "the", "termination", "conditions", "are", "not", "checked", "and", "the", "status", "might", "not", "reflect", "the", "current", "situation", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L2741-L2751
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAEvolutionStrategy.random_rescale_to_mahalanobis
def random_rescale_to_mahalanobis(self, x): """change `x` like for injection, all on genotypic level""" x -= self.mean if any(x): x *= sum(self.randn(len(x))**2)**0.5 / self.mahalanobis_norm(x) x += self.mean return x
python
def random_rescale_to_mahalanobis(self, x): """change `x` like for injection, all on genotypic level""" x -= self.mean if any(x): x *= sum(self.randn(len(x))**2)**0.5 / self.mahalanobis_norm(x) x += self.mean return x
[ "def", "random_rescale_to_mahalanobis", "(", "self", ",", "x", ")", ":", "x", "-=", "self", ".", "mean", "if", "any", "(", "x", ")", ":", "x", "*=", "sum", "(", "self", ".", "randn", "(", "len", "(", "x", ")", ")", "**", "2", ")", "**", "0.5", ...
change `x` like for injection, all on genotypic level
[ "change", "x", "like", "for", "injection", "all", "on", "genotypic", "level" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L3252-L3258
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAEvolutionStrategy.prepare_injection_directions
def prepare_injection_directions(self): """provide genotypic directions for TPA and selective mirroring, with no specific length normalization, to be used in the coming iteration. Details: This method is called in the end of `tell`. The result is assigned to ``self.pop_i...
python
def prepare_injection_directions(self): """provide genotypic directions for TPA and selective mirroring, with no specific length normalization, to be used in the coming iteration. Details: This method is called in the end of `tell`. The result is assigned to ``self.pop_i...
[ "def", "prepare_injection_directions", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'pop_injection_directions'", ")", "and", "self", ".", "pop_injection_directions", ":", "ValueError", "(", "\"Looks like a bug in calling order/logics\"", ")", "ary", "=", ...
provide genotypic directions for TPA and selective mirroring, with no specific length normalization, to be used in the coming iteration. Details: This method is called in the end of `tell`. The result is assigned to ``self.pop_injection_directions`` and used in `ask_geno...
[ "provide", "genotypic", "directions", "for", "TPA", "and", "selective", "mirroring", "with", "no", "specific", "length", "normalization", "to", "be", "used", "in", "the", "coming", "iteration", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L3492-L3527
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAEvolutionStrategy.inject
def inject(self, solutions): """inject a genotypic solution. The solution is used as direction relative to the distribution mean to compute a new candidate solution returned in method `ask_geno` which in turn is used in method `ask`. >>> import cma >>> es = cma.CMAEvolut...
python
def inject(self, solutions): """inject a genotypic solution. The solution is used as direction relative to the distribution mean to compute a new candidate solution returned in method `ask_geno` which in turn is used in method `ask`. >>> import cma >>> es = cma.CMAEvolut...
[ "def", "inject", "(", "self", ",", "solutions", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'pop_injection_directions'", ")", ":", "self", ".", "pop_injection_directions", "=", "[", "]", "for", "solution", "in", "solutions", ":", "if", "len", "(",...
inject a genotypic solution. The solution is used as direction relative to the distribution mean to compute a new candidate solution returned in method `ask_geno` which in turn is used in method `ask`. >>> import cma >>> es = cma.CMAEvolutionStrategy(4 * [1], 2) >>> whil...
[ "inject", "a", "genotypic", "solution", ".", "The", "solution", "is", "used", "as", "direction", "relative", "to", "the", "distribution", "mean", "to", "compute", "a", "new", "candidate", "solution", "returned", "in", "method", "ask_geno", "which", "in", "turn...
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L3863-L3885
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAEvolutionStrategy.result_pretty
def result_pretty(self, number_of_runs=0, time_str=None, fbestever=None): """pretty print result. Returns ``self.result()`` """ if fbestever is None: fbestever = self.best.f s = (' after %i restart' + ('s' if number_of_runs > 1 else '')) \ ...
python
def result_pretty(self, number_of_runs=0, time_str=None, fbestever=None): """pretty print result. Returns ``self.result()`` """ if fbestever is None: fbestever = self.best.f s = (' after %i restart' + ('s' if number_of_runs > 1 else '')) \ ...
[ "def", "result_pretty", "(", "self", ",", "number_of_runs", "=", "0", ",", "time_str", "=", "None", ",", "fbestever", "=", "None", ")", ":", "if", "fbestever", "is", "None", ":", "fbestever", "=", "self", ".", "best", ".", "f", "s", "=", "(", "' afte...
pretty print result. Returns ``self.result()``
[ "pretty", "print", "result", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L3898-L3921
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAEvolutionStrategy.clip_or_fit_solutions
def clip_or_fit_solutions(self, pop, idx): """make sure that solutions fit to sample distribution, this interface will probably change. In particular the frequency of long vectors appearing in pop[idx] - self.mean is limited. """ for k in idx: self.repair_genotype(pop[k])
python
def clip_or_fit_solutions(self, pop, idx): """make sure that solutions fit to sample distribution, this interface will probably change. In particular the frequency of long vectors appearing in pop[idx] - self.mean is limited. """ for k in idx: self.repair_genotype(pop[k])
[ "def", "clip_or_fit_solutions", "(", "self", ",", "pop", ",", "idx", ")", ":", "for", "k", "in", "idx", ":", "self", ".", "repair_genotype", "(", "pop", "[", "k", "]", ")" ]
make sure that solutions fit to sample distribution, this interface will probably change. In particular the frequency of long vectors appearing in pop[idx] - self.mean is limited.
[ "make", "sure", "that", "solutions", "fit", "to", "sample", "distribution", "this", "interface", "will", "probably", "change", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L3923-L3930
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAEvolutionStrategy.repair_genotype
def repair_genotype(self, x, copy_if_changed=False): """make sure that solutions fit to the sample distribution, this interface will probably change. In particular the frequency of x - self.mean being long is limited. """ x = array(x, copy=False) mold = array(self.mean, copy=Fa...
python
def repair_genotype(self, x, copy_if_changed=False): """make sure that solutions fit to the sample distribution, this interface will probably change. In particular the frequency of x - self.mean being long is limited. """ x = array(x, copy=False) mold = array(self.mean, copy=Fa...
[ "def", "repair_genotype", "(", "self", ",", "x", ",", "copy_if_changed", "=", "False", ")", ":", "x", "=", "array", "(", "x", ",", "copy", "=", "False", ")", "mold", "=", "array", "(", "self", ".", "mean", ",", "copy", "=", "False", ")", "if", "1...
make sure that solutions fit to the sample distribution, this interface will probably change. In particular the frequency of x - self.mean being long is limited.
[ "make", "sure", "that", "solutions", "fit", "to", "the", "sample", "distribution", "this", "interface", "will", "probably", "change", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L3932-L3964
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAEvolutionStrategy.decompose_C
def decompose_C(self): """eigen-decompose self.C and update self.dC, self.C, self.B. Known bugs: this might give a runtime error with CMA_diagonal / separable option on. """ if self.opts['CMA_diagonal']: _print_warning("this might fail with CMA_diagonal option on", ...
python
def decompose_C(self): """eigen-decompose self.C and update self.dC, self.C, self.B. Known bugs: this might give a runtime error with CMA_diagonal / separable option on. """ if self.opts['CMA_diagonal']: _print_warning("this might fail with CMA_diagonal option on", ...
[ "def", "decompose_C", "(", "self", ")", ":", "if", "self", ".", "opts", "[", "'CMA_diagonal'", "]", ":", "_print_warning", "(", "\"this might fail with CMA_diagonal option on\"", ",", "iteration", "=", "self", ".", "countiter", ")", "print", "(", "self", ".", ...
eigen-decompose self.C and update self.dC, self.C, self.B. Known bugs: this might give a runtime error with CMA_diagonal / separable option on.
[ "eigen", "-", "decompose", "self", ".", "C", "and", "update", "self", ".", "dC", "self", ".", "C", "self", ".", "B", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L3966-L3998
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAEvolutionStrategy.feedForResume
def feedForResume(self, X, function_values): """Given all "previous" candidate solutions and their respective function values, the state of a `CMAEvolutionStrategy` object can be reconstructed from this history. This is the purpose of function `feedForResume`. Arguments ...
python
def feedForResume(self, X, function_values): """Given all "previous" candidate solutions and their respective function values, the state of a `CMAEvolutionStrategy` object can be reconstructed from this history. This is the purpose of function `feedForResume`. Arguments ...
[ "def", "feedForResume", "(", "self", ",", "X", ",", "function_values", ")", ":", "if", "self", ".", "countiter", ">", "0", ":", "_print_warning", "(", "'feed should generally be used with a new object instance'", ")", "if", "len", "(", "X", ")", "!=", "len", "...
Given all "previous" candidate solutions and their respective function values, the state of a `CMAEvolutionStrategy` object can be reconstructed from this history. This is the purpose of function `feedForResume`. Arguments --------- `X` (all) solution p...
[ "Given", "all", "previous", "candidate", "solutions", "and", "their", "respective", "function", "values", "the", "state", "of", "a", "CMAEvolutionStrategy", "object", "can", "be", "reconstructed", "from", "this", "history", ".", "This", "is", "the", "purpose", "...
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4162-L4226
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAOptions.defaults
def defaults(): """return a dictionary with default option values and description""" return dict((str(k), str(v)) for k, v in cma_default_options.items())
python
def defaults(): """return a dictionary with default option values and description""" return dict((str(k), str(v)) for k, v in cma_default_options.items())
[ "def", "defaults", "(", ")", ":", "return", "dict", "(", "(", "str", "(", "k", ")", ",", "str", "(", "v", ")", ")", "for", "k", ",", "v", "in", "cma_default_options", ".", "items", "(", ")", ")" ]
return a dictionary with default option values and description
[ "return", "a", "dictionary", "with", "default", "option", "values", "and", "description" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4445-L4447
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAOptions.check
def check(self, options=None): """check for ambiguous keys and move attributes into dict""" self.check_values(options) self.check_attributes(options) self.check_values(options) return self
python
def check(self, options=None): """check for ambiguous keys and move attributes into dict""" self.check_values(options) self.check_attributes(options) self.check_values(options) return self
[ "def", "check", "(", "self", ",", "options", "=", "None", ")", ":", "self", ".", "check_values", "(", "options", ")", "self", ".", "check_attributes", "(", "options", ")", "self", ".", "check_values", "(", "options", ")", "return", "self" ]
check for ambiguous keys and move attributes into dict
[ "check", "for", "ambiguous", "keys", "and", "move", "attributes", "into", "dict" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4462-L4467
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAOptions.init
def init(self, dict_or_str, val=None, warn=True): """initialize one or several options. Arguments --------- `dict_or_str` a dictionary if ``val is None``, otherwise a key. If `val` is provided `dict_or_str` must be a valid key. `val` ...
python
def init(self, dict_or_str, val=None, warn=True): """initialize one or several options. Arguments --------- `dict_or_str` a dictionary if ``val is None``, otherwise a key. If `val` is provided `dict_or_str` must be a valid key. `val` ...
[ "def", "init", "(", "self", ",", "dict_or_str", ",", "val", "=", "None", ",", "warn", "=", "True", ")", ":", "self", ".", "check", "(", "dict_or_str", ")", "dic", "=", "dict_or_str", "if", "val", "is", "not", "None", ":", "dic", "=", "{", "dict_or_...
initialize one or several options. Arguments --------- `dict_or_str` a dictionary if ``val is None``, otherwise a key. If `val` is provided `dict_or_str` must be a valid key. `val` value for key Details ------- ...
[ "initialize", "one", "or", "several", "options", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4568-L4600
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAOptions.complement
def complement(self): """add all missing options with their default values""" # add meta-parameters, given options have priority self.check() for key in CMAOptions.defaults(): if key not in self: self[key] = CMAOptions.defaults()[key] return self
python
def complement(self): """add all missing options with their default values""" # add meta-parameters, given options have priority self.check() for key in CMAOptions.defaults(): if key not in self: self[key] = CMAOptions.defaults()[key] return self
[ "def", "complement", "(", "self", ")", ":", "self", ".", "check", "(", ")", "for", "key", "in", "CMAOptions", ".", "defaults", "(", ")", ":", "if", "key", "not", "in", "self", ":", "self", "[", "key", "]", "=", "CMAOptions", ".", "defaults", "(", ...
add all missing options with their default values
[ "add", "all", "missing", "options", "with", "their", "default", "values" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4634-L4642
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAOptions.settable
def settable(self): """return the subset of those options that are settable at any time. Settable options are in `versatile_options()`, but the list might be incomplete. """ return CMAOptions([i for i in list(self.items()) if i[0] in CMAO...
python
def settable(self): """return the subset of those options that are settable at any time. Settable options are in `versatile_options()`, but the list might be incomplete. """ return CMAOptions([i for i in list(self.items()) if i[0] in CMAO...
[ "def", "settable", "(", "self", ")", ":", "return", "CMAOptions", "(", "[", "i", "for", "i", "in", "list", "(", "self", ".", "items", "(", ")", ")", "if", "i", "[", "0", "]", "in", "CMAOptions", ".", "versatile_options", "(", ")", "]", ")" ]
return the subset of those options that are settable at any time. Settable options are in `versatile_options()`, but the list might be incomplete.
[ "return", "the", "subset", "of", "those", "options", "that", "are", "settable", "at", "any", "time", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4644-L4653
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAOptions.eval
def eval(self, key, default=None, loc=None, correct_key=True): """Evaluates and sets the specified option value in environment `loc`. Many options need ``N`` to be defined in `loc`, some need `popsize`. Details ------- Keys that contain 'filename' are not evaluated. ...
python
def eval(self, key, default=None, loc=None, correct_key=True): """Evaluates and sets the specified option value in environment `loc`. Many options need ``N`` to be defined in `loc`, some need `popsize`. Details ------- Keys that contain 'filename' are not evaluated. ...
[ "def", "eval", "(", "self", ",", "key", ",", "default", "=", "None", ",", "loc", "=", "None", ",", "correct_key", "=", "True", ")", ":", "if", "correct_key", ":", "key", "=", "self", ".", "corrected_key", "(", "key", ")", "self", "[", "key", "]", ...
Evaluates and sets the specified option value in environment `loc`. Many options need ``N`` to be defined in `loc`, some need `popsize`. Details ------- Keys that contain 'filename' are not evaluated. For `loc` is None, the self-dict is used as environment :See:...
[ "Evaluates", "and", "sets", "the", "specified", "option", "value", "in", "environment", "loc", ".", "Many", "options", "need", "N", "to", "be", "defined", "in", "loc", "some", "need", "popsize", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4705-L4723
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAOptions.evalall
def evalall(self, loc=None, defaults=None): """Evaluates all option values in environment `loc`. :See: `eval()` """ self.check() if defaults is None: defaults = cma_default_options # TODO: this needs rather the parameter N instead of loc if 'N' in lo...
python
def evalall(self, loc=None, defaults=None): """Evaluates all option values in environment `loc`. :See: `eval()` """ self.check() if defaults is None: defaults = cma_default_options # TODO: this needs rather the parameter N instead of loc if 'N' in lo...
[ "def", "evalall", "(", "self", ",", "loc", "=", "None", ",", "defaults", "=", "None", ")", ":", "self", ".", "check", "(", ")", "if", "defaults", "is", "None", ":", "defaults", "=", "cma_default_options", "if", "'N'", "in", "loc", ":", "popsize", "="...
Evaluates all option values in environment `loc`. :See: `eval()`
[ "Evaluates", "all", "option", "values", "in", "environment", "loc", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4725-L4742
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMAOptions.match
def match(self, s=''): """return all options that match, in the name or the description, with string `s`, case is disregarded. Example: ``cma.CMAOptions().match('verb')`` returns the verbosity options. """ match = s.lower() res = {} for k in sorted(self)...
python
def match(self, s=''): """return all options that match, in the name or the description, with string `s`, case is disregarded. Example: ``cma.CMAOptions().match('verb')`` returns the verbosity options. """ match = s.lower() res = {} for k in sorted(self)...
[ "def", "match", "(", "self", ",", "s", "=", "''", ")", ":", "match", "=", "s", ".", "lower", "(", ")", "res", "=", "{", "}", "for", "k", "in", "sorted", "(", "self", ")", ":", "s", "=", "str", "(", "k", ")", "+", "'=\\''", "+", "str", "("...
return all options that match, in the name or the description, with string `s`, case is disregarded. Example: ``cma.CMAOptions().match('verb')`` returns the verbosity options.
[ "return", "all", "options", "that", "match", "in", "the", "name", "or", "the", "description", "with", "string", "s", "case", "is", "disregarded", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L4744-L4758
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMADataLogger.data
def data(self): """return dictionary with data. If data entries are None or incomplete, consider calling ``.load().data()`` to (re-)load the data from files first. """ d = {} for name in self.key_names: d[name] = self.__dict__.get(name, None) return ...
python
def data(self): """return dictionary with data. If data entries are None or incomplete, consider calling ``.load().data()`` to (re-)load the data from files first. """ d = {} for name in self.key_names: d[name] = self.__dict__.get(name, None) return ...
[ "def", "data", "(", "self", ")", ":", "d", "=", "{", "}", "for", "name", "in", "self", ".", "key_names", ":", "d", "[", "name", "]", "=", "self", ".", "__dict__", ".", "get", "(", "name", ",", "None", ")", "return", "d" ]
return dictionary with data. If data entries are None or incomplete, consider calling ``.load().data()`` to (re-)load the data from files first.
[ "return", "dictionary", "with", "data", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L5711-L5721
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMADataLogger.register
def register(self, es, append=None, modulo=None): """register a `CMAEvolutionStrategy` instance for logging, ``append=True`` appends to previous data logged under the same name, by default previous data are overwritten. """ if not isinstance(es, CMAEvolutionStrategy): ...
python
def register(self, es, append=None, modulo=None): """register a `CMAEvolutionStrategy` instance for logging, ``append=True`` appends to previous data logged under the same name, by default previous data are overwritten. """ if not isinstance(es, CMAEvolutionStrategy): ...
[ "def", "register", "(", "self", ",", "es", ",", "append", "=", "None", ",", "modulo", "=", "None", ")", ":", "if", "not", "isinstance", "(", "es", ",", "CMAEvolutionStrategy", ")", ":", "raise", "TypeError", "(", "\"only class CMAEvolutionStrategy can be \"", ...
register a `CMAEvolutionStrategy` instance for logging, ``append=True`` appends to previous data logged under the same name, by default previous data are overwritten.
[ "register", "a", "CMAEvolutionStrategy", "instance", "for", "logging", "append", "=", "True", "appends", "to", "previous", "data", "logged", "under", "the", "same", "name", "by", "default", "previous", "data", "are", "overwritten", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L5722-L5737
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMADataLogger.save_to
def save_to(self, nameprefix, switch=False): """saves logger data to a different set of files, for ``switch=True`` also the loggers name prefix is switched to the new value """ if not nameprefix or not isinstance(nameprefix, basestring): raise _Error('filename prefix...
python
def save_to(self, nameprefix, switch=False): """saves logger data to a different set of files, for ``switch=True`` also the loggers name prefix is switched to the new value """ if not nameprefix or not isinstance(nameprefix, basestring): raise _Error('filename prefix...
[ "def", "save_to", "(", "self", ",", "nameprefix", ",", "switch", "=", "False", ")", ":", "if", "not", "nameprefix", "or", "not", "isinstance", "(", "nameprefix", ",", "basestring", ")", ":", "raise", "_Error", "(", "'filename prefix must be a nonempty string'", ...
saves logger data to a different set of files, for ``switch=True`` also the loggers name prefix is switched to the new value
[ "saves", "logger", "data", "to", "a", "different", "set", "of", "files", "for", "switch", "=", "True", "also", "the", "loggers", "name", "prefix", "is", "switched", "to", "the", "new", "value" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L6029-L6048
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMADataLogger.select_data
def select_data(self, iteration_indices): """keep only data of `iteration_indices`""" dat = self iteridx = iteration_indices dat.f = dat.f[np.where([x in iteridx for x in dat.f[:, 0]])[0], :] dat.D = dat.D[np.where([x in iteridx for x in dat.D[:, 0]])[0], :] try: ...
python
def select_data(self, iteration_indices): """keep only data of `iteration_indices`""" dat = self iteridx = iteration_indices dat.f = dat.f[np.where([x in iteridx for x in dat.f[:, 0]])[0], :] dat.D = dat.D[np.where([x in iteridx for x in dat.D[:, 0]])[0], :] try: ...
[ "def", "select_data", "(", "self", ",", "iteration_indices", ")", ":", "dat", "=", "self", "iteridx", "=", "iteration_indices", "dat", ".", "f", "=", "dat", ".", "f", "[", "np", ".", "where", "(", "[", "x", "in", "iteridx", "for", "x", "in", "dat", ...
keep only data of `iteration_indices`
[ "keep", "only", "data", "of", "iteration_indices" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L6049-L6073
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMADataLogger.plot_correlations
def plot_correlations(self, iabscissa=1): """spectrum of correlation matrix and largest correlation""" if not hasattr(self, 'corrspec'): self.load() if len(self.corrspec) < 2: return self x = self.corrspec[:, iabscissa] y = self.corrspec[:, 6:] # principl...
python
def plot_correlations(self, iabscissa=1): """spectrum of correlation matrix and largest correlation""" if not hasattr(self, 'corrspec'): self.load() if len(self.corrspec) < 2: return self x = self.corrspec[:, iabscissa] y = self.corrspec[:, 6:] # principl...
[ "def", "plot_correlations", "(", "self", ",", "iabscissa", "=", "1", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'corrspec'", ")", ":", "self", ".", "load", "(", ")", "if", "len", "(", "self", ".", "corrspec", ")", "<", "2", ":", "return",...
spectrum of correlation matrix and largest correlation
[ "spectrum", "of", "correlation", "matrix", "and", "largest", "correlation" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L6347-L6380
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMADataLogger._enter_plotting
def _enter_plotting(self, fontsize=9): """assumes that a figure is open """ # interactive_status = matplotlib.is_interactive() self.original_fontsize = pyplot.rcParams['font.size'] pyplot.rcParams['font.size'] = fontsize pyplot.hold(False) # opens a figure window, if non exists ...
python
def _enter_plotting(self, fontsize=9): """assumes that a figure is open """ # interactive_status = matplotlib.is_interactive() self.original_fontsize = pyplot.rcParams['font.size'] pyplot.rcParams['font.size'] = fontsize pyplot.hold(False) # opens a figure window, if non exists ...
[ "def", "_enter_plotting", "(", "self", ",", "fontsize", "=", "9", ")", ":", "self", ".", "original_fontsize", "=", "pyplot", ".", "rcParams", "[", "'font.size'", "]", "pyplot", ".", "rcParams", "[", "'font.size'", "]", "=", "fontsize", "pyplot", ".", "hold...
assumes that a figure is open
[ "assumes", "that", "a", "figure", "is", "open" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L6522-L6528
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMADataLogger.downsampling
def downsampling(self, factor=10, first=3, switch=True, verbose=True): """ rude downsampling of a `CMADataLogger` data file by `factor`, keeping also the first `first` entries. This function is a stump and subject to future changes. Return self. Arguments --------- ...
python
def downsampling(self, factor=10, first=3, switch=True, verbose=True): """ rude downsampling of a `CMADataLogger` data file by `factor`, keeping also the first `first` entries. This function is a stump and subject to future changes. Return self. Arguments --------- ...
[ "def", "downsampling", "(", "self", ",", "factor", "=", "10", ",", "first", "=", "3", ",", "switch", "=", "True", ",", "verbose", "=", "True", ")", ":", "newprefix", "=", "self", ".", "name_prefix", "+", "'down'", "for", "name", "in", "self", ".", ...
rude downsampling of a `CMADataLogger` data file by `factor`, keeping also the first `first` entries. This function is a stump and subject to future changes. Return self. Arguments --------- - `factor` -- downsampling factor - `first` -- keep first `first` entries ...
[ "rude", "downsampling", "of", "a", "CMADataLogger", "data", "file", "by", "factor", "keeping", "also", "the", "first", "first", "entries", ".", "This", "function", "is", "a", "stump", "and", "subject", "to", "future", "changes", ".", "Return", "self", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L6613-L6654
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
NoiseHandler.update_measure
def update_measure(self): """updated noise level measure using two fitness lists ``self.fit`` and ``self.fitre``, return ``self.noiseS, all_individual_measures``. Assumes that `self.idx` contains the indices where the fitness lists differ """ lam = len(self.fit) ...
python
def update_measure(self): """updated noise level measure using two fitness lists ``self.fit`` and ``self.fitre``, return ``self.noiseS, all_individual_measures``. Assumes that `self.idx` contains the indices where the fitness lists differ """ lam = len(self.fit) ...
[ "def", "update_measure", "(", "self", ")", ":", "lam", "=", "len", "(", "self", ".", "fit", ")", "idx", "=", "np", ".", "argsort", "(", "self", ".", "fit", "+", "self", ".", "fitre", ")", "ranks", "=", "np", ".", "argsort", "(", "idx", ")", "."...
updated noise level measure using two fitness lists ``self.fit`` and ``self.fitre``, return ``self.noiseS, all_individual_measures``. Assumes that `self.idx` contains the indices where the fitness lists differ
[ "updated", "noise", "level", "measure", "using", "two", "fitness", "lists", "self", ".", "fit", "and", "self", ".", "fitre", "return", "self", ".", "noiseS", "all_individual_measures", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L7066-L7090
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
NoiseHandler.indices
def indices(self, fit): """return the set of indices to be reevaluated for noise measurement. Given the first values are the earliest, this is a useful policy also with a time changing objective. """ ## meta_parameters.noise_reeval_multiplier == 1.0 lam_reev = 1...
python
def indices(self, fit): """return the set of indices to be reevaluated for noise measurement. Given the first values are the earliest, this is a useful policy also with a time changing objective. """ ## meta_parameters.noise_reeval_multiplier == 1.0 lam_reev = 1...
[ "def", "indices", "(", "self", ",", "fit", ")", ":", "lam_reev", "=", "1.0", "*", "(", "self", ".", "lam_reeval", "if", "self", ".", "lam_reeval", "else", "2", "+", "len", "(", "fit", ")", "/", "20", ")", "lam_reev", "=", "int", "(", "lam_reev", ...
return the set of indices to be reevaluated for noise measurement. Given the first values are the earliest, this is a useful policy also with a time changing objective.
[ "return", "the", "set", "of", "indices", "to", "be", "reevaluated", "for", "noise", "measurement", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L7092-L7122
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
Sections.plot
def plot(self, plot_cmd=None, tf=lambda y: y): """plot the data we have, return ``self``""" if not plot_cmd: plot_cmd = self.plot_cmd colors = 'bgrcmyk' pyplot.hold(False) res = self.res flatx, flatf = self.flattened() minf = np.inf for i in f...
python
def plot(self, plot_cmd=None, tf=lambda y: y): """plot the data we have, return ``self``""" if not plot_cmd: plot_cmd = self.plot_cmd colors = 'bgrcmyk' pyplot.hold(False) res = self.res flatx, flatf = self.flattened() minf = np.inf for i in f...
[ "def", "plot", "(", "self", ",", "plot_cmd", "=", "None", ",", "tf", "=", "lambda", "y", ":", "y", ")", ":", "if", "not", "plot_cmd", ":", "plot_cmd", "=", "self", ".", "plot_cmd", "colors", "=", "'bgrcmyk'", "pyplot", ".", "hold", "(", "False", ")...
plot the data we have, return ``self``
[ "plot", "the", "data", "we", "have", "return", "self" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L7250-L7276
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
Sections.save
def save(self, name=None): """save to file""" import pickle name = name if name else self.name fun = self.func del self.func # instance method produces error pickle.dump(self, open(name + '.pkl', "wb")) self.func = fun return self
python
def save(self, name=None): """save to file""" import pickle name = name if name else self.name fun = self.func del self.func # instance method produces error pickle.dump(self, open(name + '.pkl', "wb")) self.func = fun return self
[ "def", "save", "(", "self", ",", "name", "=", "None", ")", ":", "import", "pickle", "name", "=", "name", "if", "name", "else", "self", ".", "name", "fun", "=", "self", ".", "func", "del", "self", ".", "func", "pickle", ".", "dump", "(", "self", "...
save to file
[ "save", "to", "file" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L7295-L7303
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
Sections.load
def load(self, name=None): """load from file""" import pickle name = name if name else self.name s = pickle.load(open(name + '.pkl', 'rb')) self.res = s.res # disregard the class return self
python
def load(self, name=None): """load from file""" import pickle name = name if name else self.name s = pickle.load(open(name + '.pkl', 'rb')) self.res = s.res # disregard the class return self
[ "def", "load", "(", "self", ",", "name", "=", "None", ")", ":", "import", "pickle", "name", "=", "name", "if", "name", "else", "self", ".", "name", "s", "=", "pickle", ".", "load", "(", "open", "(", "name", "+", "'.pkl'", ",", "'rb'", ")", ")", ...
load from file
[ "load", "from", "file" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L7305-L7311
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
Misc.loglikelihood
def loglikelihood(self, x, previous=False): """return log-likelihood of `x` regarding the current sample distribution""" # testing of original fct: MC integrate must be one: mean(p(x_i)) * volume(where x_i are uniformely sampled) # for i in xrange(3): print mean([cma.likelihood(20*r-10, dim * [0...
python
def loglikelihood(self, x, previous=False): """return log-likelihood of `x` regarding the current sample distribution""" # testing of original fct: MC integrate must be one: mean(p(x_i)) * volume(where x_i are uniformely sampled) # for i in xrange(3): print mean([cma.likelihood(20*r-10, dim * [0...
[ "def", "loglikelihood", "(", "self", ",", "x", ",", "previous", "=", "False", ")", ":", "if", "previous", "and", "hasattr", "(", "self", ",", "'lastiter'", ")", ":", "sigma", "=", "self", ".", "lastiter", ".", "sigma", "Crootinv", "=", "self", ".", "...
return log-likelihood of `x` regarding the current sample distribution
[ "return", "log", "-", "likelihood", "of", "x", "regarding", "the", "current", "sample", "distribution" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L7505-L7537
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.noisysphere
def noisysphere(self, x, noise=2.10e-9, cond=1.0, noise_offset=0.10): """noise=10 does not work with default popsize, noise handling does not help """ return self.elli(x, cond=cond) * (1 + noise * np.random.randn() / len(x)) + noise_offset * np.random.rand()
python
def noisysphere(self, x, noise=2.10e-9, cond=1.0, noise_offset=0.10): """noise=10 does not work with default popsize, noise handling does not help """ return self.elli(x, cond=cond) * (1 + noise * np.random.randn() / len(x)) + noise_offset * np.random.rand()
[ "def", "noisysphere", "(", "self", ",", "x", ",", "noise", "=", "2.10e-9", ",", "cond", "=", "1.0", ",", "noise_offset", "=", "0.10", ")", ":", "return", "self", ".", "elli", "(", "x", ",", "cond", "=", "cond", ")", "*", "(", "1", "+", "noise", ...
noise=10 does not work with default popsize, noise handling does not help
[ "noise", "=", "10", "does", "not", "work", "with", "default", "popsize", "noise", "handling", "does", "not", "help" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8277-L8279
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.cigar
def cigar(self, x, rot=0, cond=1e6, noise=0): """Cigar test objective function""" if rot: x = rotate(x) x = [x] if isscalar(x[0]) else x # scalar into list f = [(x[0]**2 + cond * sum(x[1:]**2)) * np.exp(noise * np.random.randn(1)[0] / len(x)) for x in x] return f if ...
python
def cigar(self, x, rot=0, cond=1e6, noise=0): """Cigar test objective function""" if rot: x = rotate(x) x = [x] if isscalar(x[0]) else x # scalar into list f = [(x[0]**2 + cond * sum(x[1:]**2)) * np.exp(noise * np.random.randn(1)[0] / len(x)) for x in x] return f if ...
[ "def", "cigar", "(", "self", ",", "x", ",", "rot", "=", "0", ",", "cond", "=", "1e6", ",", "noise", "=", "0", ")", ":", "if", "rot", ":", "x", "=", "rotate", "(", "x", ")", "x", "=", "[", "x", "]", "if", "isscalar", "(", "x", "[", "0", ...
Cigar test objective function
[ "Cigar", "test", "objective", "function" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8336-L8342
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.tablet
def tablet(self, x, rot=0): """Tablet test objective function""" if rot and rot is not fcts.tablet: x = rotate(x) x = [x] if isscalar(x[0]) else x # scalar into list f = [1e6 * x[0]**2 + sum(x[1:]**2) for x in x] return f if len(f) > 1 else f[0] # 1-element-list int...
python
def tablet(self, x, rot=0): """Tablet test objective function""" if rot and rot is not fcts.tablet: x = rotate(x) x = [x] if isscalar(x[0]) else x # scalar into list f = [1e6 * x[0]**2 + sum(x[1:]**2) for x in x] return f if len(f) > 1 else f[0] # 1-element-list int...
[ "def", "tablet", "(", "self", ",", "x", ",", "rot", "=", "0", ")", ":", "if", "rot", "and", "rot", "is", "not", "fcts", ".", "tablet", ":", "x", "=", "rotate", "(", "x", ")", "x", "=", "[", "x", "]", "if", "isscalar", "(", "x", "[", "0", ...
Tablet test objective function
[ "Tablet", "test", "objective", "function" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8353-L8359
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.elli
def elli(self, x, rot=0, xoffset=0, cond=1e6, actuator_noise=0.0, both=False): """Ellipsoid test objective function""" if not isscalar(x[0]): # parallel evaluation return [self.elli(xi, rot) for xi in x] # could save 20% overall if rot: x = rotate(x) N = len(x) ...
python
def elli(self, x, rot=0, xoffset=0, cond=1e6, actuator_noise=0.0, both=False): """Ellipsoid test objective function""" if not isscalar(x[0]): # parallel evaluation return [self.elli(xi, rot) for xi in x] # could save 20% overall if rot: x = rotate(x) N = len(x) ...
[ "def", "elli", "(", "self", ",", "x", ",", "rot", "=", "0", ",", "xoffset", "=", "0", ",", "cond", "=", "1e6", ",", "actuator_noise", "=", "0.0", ",", "both", "=", "False", ")", ":", "if", "not", "isscalar", "(", "x", "[", "0", "]", ")", ":",...
Ellipsoid test objective function
[ "Ellipsoid", "test", "objective", "function" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8384-L8406
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.elliconstraint
def elliconstraint(self, x, cfac=1e8, tough=True, cond=1e6): """ellipsoid test objective function with "constraints" """ N = len(x) f = sum(cond**(np.arange(N)[-1::-1] / (N - 1)) * x**2) cvals = (x[0] + 1, x[0] + 1 + 100 * x[1], x[0] + 1 - 100 * x[1]) ...
python
def elliconstraint(self, x, cfac=1e8, tough=True, cond=1e6): """ellipsoid test objective function with "constraints" """ N = len(x) f = sum(cond**(np.arange(N)[-1::-1] / (N - 1)) * x**2) cvals = (x[0] + 1, x[0] + 1 + 100 * x[1], x[0] + 1 - 100 * x[1]) ...
[ "def", "elliconstraint", "(", "self", ",", "x", ",", "cfac", "=", "1e8", ",", "tough", "=", "True", ",", "cond", "=", "1e6", ")", ":", "N", "=", "len", "(", "x", ")", "f", "=", "sum", "(", "cond", "**", "(", "np", ".", "arange", "(", "N", "...
ellipsoid test objective function with "constraints"
[ "ellipsoid", "test", "objective", "function", "with", "constraints" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8434-L8445
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.rosen
def rosen(self, x, alpha=1e2): """Rosenbrock test objective function""" x = [x] if isscalar(x[0]) else x # scalar into list f = [sum(alpha * (x[:-1]**2 - x[1:])**2 + (1. - x[:-1])**2) for x in x] return f if len(f) > 1 else f[0] # 1-element-list into scalar
python
def rosen(self, x, alpha=1e2): """Rosenbrock test objective function""" x = [x] if isscalar(x[0]) else x # scalar into list f = [sum(alpha * (x[:-1]**2 - x[1:])**2 + (1. - x[:-1])**2) for x in x] return f if len(f) > 1 else f[0] # 1-element-list into scalar
[ "def", "rosen", "(", "self", ",", "x", ",", "alpha", "=", "1e2", ")", ":", "x", "=", "[", "x", "]", "if", "isscalar", "(", "x", "[", "0", "]", ")", "else", "x", "f", "=", "[", "sum", "(", "alpha", "*", "(", "x", "[", ":", "-", "1", "]",...
Rosenbrock test objective function
[ "Rosenbrock", "test", "objective", "function" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8446-L8450
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.diffpow
def diffpow(self, x, rot=0): """Diffpow test objective function""" N = len(x) if rot: x = rotate(x) return sum(np.abs(x)**(2. + 4.*np.arange(N) / (N - 1.)))**0.5
python
def diffpow(self, x, rot=0): """Diffpow test objective function""" N = len(x) if rot: x = rotate(x) return sum(np.abs(x)**(2. + 4.*np.arange(N) / (N - 1.)))**0.5
[ "def", "diffpow", "(", "self", ",", "x", ",", "rot", "=", "0", ")", ":", "N", "=", "len", "(", "x", ")", "if", "rot", ":", "x", "=", "rotate", "(", "x", ")", "return", "sum", "(", "np", ".", "abs", "(", "x", ")", "**", "(", "2.", "+", "...
Diffpow test objective function
[ "Diffpow", "test", "objective", "function" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8459-L8464
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.ridgecircle
def ridgecircle(self, x, expo=0.5): """happy cat by HG Beyer""" a = len(x) s = sum(x**2) return ((s - a)**2)**(expo / 2) + s / a + sum(x) / a
python
def ridgecircle(self, x, expo=0.5): """happy cat by HG Beyer""" a = len(x) s = sum(x**2) return ((s - a)**2)**(expo / 2) + s / a + sum(x) / a
[ "def", "ridgecircle", "(", "self", ",", "x", ",", "expo", "=", "0.5", ")", ":", "a", "=", "len", "(", "x", ")", "s", "=", "sum", "(", "x", "**", "2", ")", "return", "(", "(", "s", "-", "a", ")", "**", "2", ")", "**", "(", "expo", "/", "...
happy cat by HG Beyer
[ "happy", "cat", "by", "HG", "Beyer" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8472-L8476
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.rastrigin
def rastrigin(self, x): """Rastrigin test objective function""" if not isscalar(x[0]): N = len(x[0]) return [10 * N + sum(xi**2 - 10 * np.cos(2 * np.pi * xi)) for xi in x] # return 10*N + sum(x**2 - 10*np.cos(2*np.pi*x), axis=1) N = len(x) return 10 * ...
python
def rastrigin(self, x): """Rastrigin test objective function""" if not isscalar(x[0]): N = len(x[0]) return [10 * N + sum(xi**2 - 10 * np.cos(2 * np.pi * xi)) for xi in x] # return 10*N + sum(x**2 - 10*np.cos(2*np.pi*x), axis=1) N = len(x) return 10 * ...
[ "def", "rastrigin", "(", "self", ",", "x", ")", ":", "if", "not", "isscalar", "(", "x", "[", "0", "]", ")", ":", "N", "=", "len", "(", "x", "[", "0", "]", ")", "return", "[", "10", "*", "N", "+", "sum", "(", "xi", "**", "2", "-", "10", ...
Rastrigin test objective function
[ "Rastrigin", "test", "objective", "function" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8498-L8505
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.schwefelmult
def schwefelmult(self, x, pen_fac=1e4): """multimodal Schwefel function with domain -500..500""" y = [x] if isscalar(x[0]) else x N = len(y[0]) f = array([418.9829 * N - 1.27275661e-5 * N - sum(x * np.sin(np.abs(x)**0.5)) + pen_fac * sum((abs(x) > 500) * (abs(x) - 500)**2...
python
def schwefelmult(self, x, pen_fac=1e4): """multimodal Schwefel function with domain -500..500""" y = [x] if isscalar(x[0]) else x N = len(y[0]) f = array([418.9829 * N - 1.27275661e-5 * N - sum(x * np.sin(np.abs(x)**0.5)) + pen_fac * sum((abs(x) > 500) * (abs(x) - 500)**2...
[ "def", "schwefelmult", "(", "self", ",", "x", ",", "pen_fac", "=", "1e4", ")", ":", "y", "=", "[", "x", "]", "if", "isscalar", "(", "x", "[", "0", "]", ")", "else", "x", "N", "=", "len", "(", "y", "[", "0", "]", ")", "f", "=", "array", "(...
multimodal Schwefel function with domain -500..500
[ "multimodal", "Schwefel", "function", "with", "domain", "-", "500", "..", "500" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8519-L8525
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.lincon
def lincon(self, x, theta=0.01): """ridge like linear function with one linear constraint""" if x[0] < 0: return np.NaN return theta * x[1] + x[0]
python
def lincon(self, x, theta=0.01): """ridge like linear function with one linear constraint""" if x[0] < 0: return np.NaN return theta * x[1] + x[0]
[ "def", "lincon", "(", "self", ",", "x", ",", "theta", "=", "0.01", ")", ":", "if", "x", "[", "0", "]", "<", "0", ":", "return", "np", ".", "NaN", "return", "theta", "*", "x", "[", "1", "]", "+", "x", "[", "0", "]" ]
ridge like linear function with one linear constraint
[ "ridge", "like", "linear", "function", "with", "one", "linear", "constraint" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8530-L8534
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.rosen_nesterov
def rosen_nesterov(self, x, rho=100): """needs exponential number of steps in a non-increasing f-sequence. x_0 = (-1,1,...,1) See Jarre (2011) "On Nesterov's Smooth Chebyshev-Rosenbrock Function" """ f = 0.25 * (x[0] - 1)**2 f += rho * sum((x[1:] - 2 * x[:-1]**2 + 1)**2...
python
def rosen_nesterov(self, x, rho=100): """needs exponential number of steps in a non-increasing f-sequence. x_0 = (-1,1,...,1) See Jarre (2011) "On Nesterov's Smooth Chebyshev-Rosenbrock Function" """ f = 0.25 * (x[0] - 1)**2 f += rho * sum((x[1:] - 2 * x[:-1]**2 + 1)**2...
[ "def", "rosen_nesterov", "(", "self", ",", "x", ",", "rho", "=", "100", ")", ":", "f", "=", "0.25", "*", "(", "x", "[", "0", "]", "-", "1", ")", "**", "2", "f", "+=", "rho", "*", "sum", "(", "(", "x", "[", "1", ":", "]", "-", "2", "*", ...
needs exponential number of steps in a non-increasing f-sequence. x_0 = (-1,1,...,1) See Jarre (2011) "On Nesterov's Smooth Chebyshev-Rosenbrock Function"
[ "needs", "exponential", "number", "of", "steps", "in", "a", "non", "-", "increasing", "f", "-", "sequence", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8535-L8544
train
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
FitnessFunctions.bukin
def bukin(self, x): """Bukin function from Wikipedia, generalized simplistically from 2-D. http://en.wikipedia.org/wiki/Test_functions_for_optimization""" s = 0 for k in xrange((1+len(x)) // 2): z = x[2 * k] y = x[min((2*k + 1, len(x)-1))] s += 100 * ...
python
def bukin(self, x): """Bukin function from Wikipedia, generalized simplistically from 2-D. http://en.wikipedia.org/wiki/Test_functions_for_optimization""" s = 0 for k in xrange((1+len(x)) // 2): z = x[2 * k] y = x[min((2*k + 1, len(x)-1))] s += 100 * ...
[ "def", "bukin", "(", "self", ",", "x", ")", ":", "s", "=", "0", "for", "k", "in", "xrange", "(", "(", "1", "+", "len", "(", "x", ")", ")", "//", "2", ")", ":", "z", "=", "x", "[", "2", "*", "k", "]", "y", "=", "x", "[", "min", "(", ...
Bukin function from Wikipedia, generalized simplistically from 2-D. http://en.wikipedia.org/wiki/Test_functions_for_optimization
[ "Bukin", "function", "from", "Wikipedia", "generalized", "simplistically", "from", "2", "-", "D", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L8562-L8571
train
flowersteam/explauto
explauto/models/pydmps/dmp.py
DMPs.check_offset
def check_offset(self): """Check to see if initial position and goal are the same if they are, offset slightly so that the forcing term is not 0""" for d in range(self.dmps): if (self.y0[d] == self.goal[d]): self.goal[d] += 1e-4
python
def check_offset(self): """Check to see if initial position and goal are the same if they are, offset slightly so that the forcing term is not 0""" for d in range(self.dmps): if (self.y0[d] == self.goal[d]): self.goal[d] += 1e-4
[ "def", "check_offset", "(", "self", ")", ":", "for", "d", "in", "range", "(", "self", ".", "dmps", ")", ":", "if", "(", "self", ".", "y0", "[", "d", "]", "==", "self", ".", "goal", "[", "d", "]", ")", ":", "self", ".", "goal", "[", "d", "]"...
Check to see if initial position and goal are the same if they are, offset slightly so that the forcing term is not 0
[ "Check", "to", "see", "if", "initial", "position", "and", "goal", "are", "the", "same", "if", "they", "are", "offset", "slightly", "so", "that", "the", "forcing", "term", "is", "not", "0" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/models/pydmps/dmp.py#L65-L71
train
flowersteam/explauto
explauto/models/pydmps/dmp.py
DMPs.rollout
def rollout(self, timesteps=None, **kwargs): """Generate a system trial, no feedback is incorporated.""" self.reset_state() if timesteps is None: if kwargs.has_key('tau'): timesteps = int(self.timesteps / kwargs['tau']) else: timesteps =...
python
def rollout(self, timesteps=None, **kwargs): """Generate a system trial, no feedback is incorporated.""" self.reset_state() if timesteps is None: if kwargs.has_key('tau'): timesteps = int(self.timesteps / kwargs['tau']) else: timesteps =...
[ "def", "rollout", "(", "self", ",", "timesteps", "=", "None", ",", "**", "kwargs", ")", ":", "self", ".", "reset_state", "(", ")", "if", "timesteps", "is", "None", ":", "if", "kwargs", ".", "has_key", "(", "'tau'", ")", ":", "timesteps", "=", "int", ...
Generate a system trial, no feedback is incorporated.
[ "Generate", "a", "system", "trial", "no", "feedback", "is", "incorporated", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/models/pydmps/dmp.py#L147-L172
train
flowersteam/explauto
explauto/models/pydmps/dmp.py
DMPs.reset_state
def reset_state(self): """Reset the system state""" self.y = self.y0.copy() self.dy = np.zeros(self.dmps) self.ddy = np.zeros(self.dmps) self.cs.reset_state()
python
def reset_state(self): """Reset the system state""" self.y = self.y0.copy() self.dy = np.zeros(self.dmps) self.ddy = np.zeros(self.dmps) self.cs.reset_state()
[ "def", "reset_state", "(", "self", ")", ":", "self", ".", "y", "=", "self", ".", "y0", ".", "copy", "(", ")", "self", ".", "dy", "=", "np", ".", "zeros", "(", "self", ".", "dmps", ")", "self", ".", "ddy", "=", "np", ".", "zeros", "(", "self",...
Reset the system state
[ "Reset", "the", "system", "state" ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/models/pydmps/dmp.py#L174-L179
train
flowersteam/explauto
explauto/models/pydmps/dmp.py
DMPs.step
def step(self, tau=1.0, state_fb=None): """Run the DMP system for a single timestep. tau float: scales the timestep increase tau to make the system execute faster state_fb np.array: optional system feedback """ # run canonical system cs_args = {'tau':tau...
python
def step(self, tau=1.0, state_fb=None): """Run the DMP system for a single timestep. tau float: scales the timestep increase tau to make the system execute faster state_fb np.array: optional system feedback """ # run canonical system cs_args = {'tau':tau...
[ "def", "step", "(", "self", ",", "tau", "=", "1.0", ",", "state_fb", "=", "None", ")", ":", "cs_args", "=", "{", "'tau'", ":", "tau", ",", "'error_coupling'", ":", "1.0", "}", "if", "state_fb", "is", "not", "None", ":", "state_fb", "=", "state_fb", ...
Run the DMP system for a single timestep. tau float: scales the timestep increase tau to make the system execute faster state_fb np.array: optional system feedback
[ "Run", "the", "DMP", "system", "for", "a", "single", "timestep", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/models/pydmps/dmp.py#L181-L215
train
flowersteam/explauto
explauto/environment/npendulum/simulation.py
step
def step(weights, duration): """ This function creates a sum of boxcar functions. :param numpy.array weight: height of each boxcar function. :param float duration: duration of the generated trajectory. """ dt = duration / len(weights) def activate(t, dt): """This function returns 1 if...
python
def step(weights, duration): """ This function creates a sum of boxcar functions. :param numpy.array weight: height of each boxcar function. :param float duration: duration of the generated trajectory. """ dt = duration / len(weights) def activate(t, dt): """This function returns 1 if...
[ "def", "step", "(", "weights", ",", "duration", ")", ":", "dt", "=", "duration", "/", "len", "(", "weights", ")", "def", "activate", "(", "t", ",", "dt", ")", ":", "return", "0", "<=", "t", "<", "dt", "return", "(", "lambda", "t", ":", "sum", "...
This function creates a sum of boxcar functions. :param numpy.array weight: height of each boxcar function. :param float duration: duration of the generated trajectory.
[ "This", "function", "creates", "a", "sum", "of", "boxcar", "functions", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/environment/npendulum/simulation.py#L9-L26
train
flowersteam/explauto
explauto/environment/npendulum/simulation.py
cartesian
def cartesian(n, states): """ This function computes cartesians coordinates from the states returned by the simulate function. :param int n: number of particules suspended to the top one :param numpy.array states: list of the positions and speeds at a certain time. """ length = 1. / n # arm_length...
python
def cartesian(n, states): """ This function computes cartesians coordinates from the states returned by the simulate function. :param int n: number of particules suspended to the top one :param numpy.array states: list of the positions and speeds at a certain time. """ length = 1. / n # arm_length...
[ "def", "cartesian", "(", "n", ",", "states", ")", ":", "length", "=", "1.", "/", "n", "pos_x", "=", "hstack", "(", "(", "states", "[", "0", "]", ",", "zeros", "(", "n", ")", ")", ")", "pos_y", "=", "zeros", "(", "n", "+", "1", ")", "for", "...
This function computes cartesians coordinates from the states returned by the simulate function. :param int n: number of particules suspended to the top one :param numpy.array states: list of the positions and speeds at a certain time.
[ "This", "function", "computes", "cartesians", "coordinates", "from", "the", "states", "returned", "by", "the", "simulate", "function", "." ]
cf0f81ecb9f6412f7276a95bd27359000e1e26b6
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/environment/npendulum/simulation.py#L151-L164
train
aamalev/aiohttp_apiset
aiohttp_apiset/swagger/route.py
SwaggerRoute.build_swagger_data
def build_swagger_data(self, loader): """ Prepare data when schema loaded :param swagger_schema: loaded schema """ if self.is_built: return self.is_built = True self._required = [] self._parameters = {} if not self._swagger_data: r...
python
def build_swagger_data(self, loader): """ Prepare data when schema loaded :param swagger_schema: loaded schema """ if self.is_built: return self.is_built = True self._required = [] self._parameters = {} if not self._swagger_data: r...
[ "def", "build_swagger_data", "(", "self", ",", "loader", ")", ":", "if", "self", ".", "is_built", ":", "return", "self", ".", "is_built", "=", "True", "self", ".", "_required", "=", "[", "]", "self", ".", "_parameters", "=", "{", "}", "if", "not", "s...
Prepare data when schema loaded :param swagger_schema: loaded schema
[ "Prepare", "data", "when", "schema", "loaded" ]
ba3492ce929e39be1325d506b727a8bfb34e7b33
https://github.com/aamalev/aiohttp_apiset/blob/ba3492ce929e39be1325d506b727a8bfb34e7b33/aiohttp_apiset/swagger/route.py#L38-L62
train
aamalev/aiohttp_apiset
aiohttp_apiset/swagger/route.py
SwaggerRoute.validate
async def validate(self, request: web.Request): """ Returns parameters extract from request and multidict errors :param request: Request :return: tuple of parameters and errors """ parameters = {} files = {} errors = self.errors_factory() body = None ...
python
async def validate(self, request: web.Request): """ Returns parameters extract from request and multidict errors :param request: Request :return: tuple of parameters and errors """ parameters = {} files = {} errors = self.errors_factory() body = None ...
[ "async", "def", "validate", "(", "self", ",", "request", ":", "web", ".", "Request", ")", ":", "parameters", "=", "{", "}", "files", "=", "{", "}", "errors", "=", "self", ".", "errors_factory", "(", ")", "body", "=", "None", "if", "request", ".", "...
Returns parameters extract from request and multidict errors :param request: Request :return: tuple of parameters and errors
[ "Returns", "parameters", "extract", "from", "request", "and", "multidict", "errors" ]
ba3492ce929e39be1325d506b727a8bfb34e7b33
https://github.com/aamalev/aiohttp_apiset/blob/ba3492ce929e39be1325d506b727a8bfb34e7b33/aiohttp_apiset/swagger/route.py#L96-L181
train
aamalev/aiohttp_apiset
aiohttp_apiset/swagger/router.py
SwaggerRouter.include
def include(self, spec, *, basePath=None, operationId_mapping=None, name=None): """ Adds a new specification to a router :param spec: path to specification :param basePath: override base path specify in specification :param operationId_map...
python
def include(self, spec, *, basePath=None, operationId_mapping=None, name=None): """ Adds a new specification to a router :param spec: path to specification :param basePath: override base path specify in specification :param operationId_map...
[ "def", "include", "(", "self", ",", "spec", ",", "*", ",", "basePath", "=", "None", ",", "operationId_mapping", "=", "None", ",", "name", "=", "None", ")", ":", "data", "=", "self", ".", "_file_loader", ".", "load", "(", "spec", ")", "if", "basePath"...
Adds a new specification to a router :param spec: path to specification :param basePath: override base path specify in specification :param operationId_mapping: mapping for handlers :param name: name to access original spec
[ "Adds", "a", "new", "specification", "to", "a", "router" ]
ba3492ce929e39be1325d506b727a8bfb34e7b33
https://github.com/aamalev/aiohttp_apiset/blob/ba3492ce929e39be1325d506b727a8bfb34e7b33/aiohttp_apiset/swagger/router.py#L183-L244
train
aamalev/aiohttp_apiset
aiohttp_apiset/swagger/router.py
SwaggerRouter.setup
def setup(self, app: web.Application): """ Installation routes to app.router :param app: instance of aiohttp.web.Application """ if self.app is app: raise ValueError('The router is already configured ' 'for this application') self.app = a...
python
def setup(self, app: web.Application): """ Installation routes to app.router :param app: instance of aiohttp.web.Application """ if self.app is app: raise ValueError('The router is already configured ' 'for this application') self.app = a...
[ "def", "setup", "(", "self", ",", "app", ":", "web", ".", "Application", ")", ":", "if", "self", ".", "app", "is", "app", ":", "raise", "ValueError", "(", "'The router is already configured '", "'for this application'", ")", "self", ".", "app", "=", "app", ...
Installation routes to app.router :param app: instance of aiohttp.web.Application
[ "Installation", "routes", "to", "app", ".", "router" ]
ba3492ce929e39be1325d506b727a8bfb34e7b33
https://github.com/aamalev/aiohttp_apiset/blob/ba3492ce929e39be1325d506b727a8bfb34e7b33/aiohttp_apiset/swagger/router.py#L283-L303
train
aamalev/aiohttp_apiset
aiohttp_apiset/jinja2.py
template
def template(template_name, *, app_key=APP_KEY, encoding='utf-8', status=200): """ Decorator compatible with aiohttp_apiset router """ def wrapper(func): @functools.wraps(func) async def wrapped(*args, **kwargs): if asyncio.iscoroutinefunction(func): coro = f...
python
def template(template_name, *, app_key=APP_KEY, encoding='utf-8', status=200): """ Decorator compatible with aiohttp_apiset router """ def wrapper(func): @functools.wraps(func) async def wrapped(*args, **kwargs): if asyncio.iscoroutinefunction(func): coro = f...
[ "def", "template", "(", "template_name", ",", "*", ",", "app_key", "=", "APP_KEY", ",", "encoding", "=", "'utf-8'", ",", "status", "=", "200", ")", ":", "def", "wrapper", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "async...
Decorator compatible with aiohttp_apiset router
[ "Decorator", "compatible", "with", "aiohttp_apiset", "router" ]
ba3492ce929e39be1325d506b727a8bfb34e7b33
https://github.com/aamalev/aiohttp_apiset/blob/ba3492ce929e39be1325d506b727a8bfb34e7b33/aiohttp_apiset/jinja2.py#L10-L41
train
aamalev/aiohttp_apiset
aiohttp_apiset/swagger/validate.py
get_collection
def get_collection(source, name, collection_format, default): """get collection named `name` from the given `source` that formatted accordingly to `collection_format`. """ if collection_format in COLLECTION_SEP: separator = COLLECTION_SEP[collection_format] value = source.get(name, None)...
python
def get_collection(source, name, collection_format, default): """get collection named `name` from the given `source` that formatted accordingly to `collection_format`. """ if collection_format in COLLECTION_SEP: separator = COLLECTION_SEP[collection_format] value = source.get(name, None)...
[ "def", "get_collection", "(", "source", ",", "name", ",", "collection_format", ",", "default", ")", ":", "if", "collection_format", "in", "COLLECTION_SEP", ":", "separator", "=", "COLLECTION_SEP", "[", "collection_format", "]", "value", "=", "source", ".", "get"...
get collection named `name` from the given `source` that formatted accordingly to `collection_format`.
[ "get", "collection", "named", "name", "from", "the", "given", "source", "that", "formatted", "accordingly", "to", "collection_format", "." ]
ba3492ce929e39be1325d506b727a8bfb34e7b33
https://github.com/aamalev/aiohttp_apiset/blob/ba3492ce929e39be1325d506b727a8bfb34e7b33/aiohttp_apiset/swagger/validate.py#L171-L184
train
aamalev/aiohttp_apiset
aiohttp_apiset/compat.py
CompatRouter.add_get
def add_get(self, *args, **kwargs): """ Shortcut for add_route with method GET """ return self.add_route(hdrs.METH_GET, *args, **kwargs)
python
def add_get(self, *args, **kwargs): """ Shortcut for add_route with method GET """ return self.add_route(hdrs.METH_GET, *args, **kwargs)
[ "def", "add_get", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "return", "self", ".", "add_route", "(", "hdrs", ".", "METH_GET", ",", "*", "args", ",", "**", "kwargs", ")" ]
Shortcut for add_route with method GET
[ "Shortcut", "for", "add_route", "with", "method", "GET" ]
ba3492ce929e39be1325d506b727a8bfb34e7b33
https://github.com/aamalev/aiohttp_apiset/blob/ba3492ce929e39be1325d506b727a8bfb34e7b33/aiohttp_apiset/compat.py#L352-L356
train
aamalev/aiohttp_apiset
aiohttp_apiset/swagger/operations.py
OperationIdMapping.add
def add(self, *args, **kwargs): """ Add new mapping from args and kwargs >>> om = OperationIdMapping() >>> om.add( ... OperationIdMapping(), ... 'aiohttp_apiset.swagger.operations', # any module ... getPets='mymod.handler', ... getPet='mymod.get_...
python
def add(self, *args, **kwargs): """ Add new mapping from args and kwargs >>> om = OperationIdMapping() >>> om.add( ... OperationIdMapping(), ... 'aiohttp_apiset.swagger.operations', # any module ... getPets='mymod.handler', ... getPet='mymod.get_...
[ "def", "add", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "for", "arg", "in", "args", ":", "if", "isinstance", "(", "arg", ",", "str", ")", ":", "self", ".", "_operations", ".", "append", "(", "self", ".", "_from_str", "(", "arg...
Add new mapping from args and kwargs >>> om = OperationIdMapping() >>> om.add( ... OperationIdMapping(), ... 'aiohttp_apiset.swagger.operations', # any module ... getPets='mymod.handler', ... getPet='mymod.get_pet', ... ) >>> om['getPets'...
[ "Add", "new", "mapping", "from", "args", "and", "kwargs" ]
ba3492ce929e39be1325d506b727a8bfb34e7b33
https://github.com/aamalev/aiohttp_apiset/blob/ba3492ce929e39be1325d506b727a8bfb34e7b33/aiohttp_apiset/swagger/operations.py#L48-L70
train
mila/pyoo
pyoo.py
str_repr
def str_repr(klass): """ Implements string conversion methods for the given class. The given class must implement the __str__ method. This decorat will add __repr__ and __unicode__ (for Python 2). """ if PY2: klass.__unicode__ = klass.__str__ klass.__str__ = lambda self: self._...
python
def str_repr(klass): """ Implements string conversion methods for the given class. The given class must implement the __str__ method. This decorat will add __repr__ and __unicode__ (for Python 2). """ if PY2: klass.__unicode__ = klass.__str__ klass.__str__ = lambda self: self._...
[ "def", "str_repr", "(", "klass", ")", ":", "if", "PY2", ":", "klass", ".", "__unicode__", "=", "klass", ".", "__str__", "klass", ".", "__str__", "=", "lambda", "self", ":", "self", ".", "__unicode__", "(", ")", ".", "encode", "(", "'utf-8'", ")", "kl...
Implements string conversion methods for the given class. The given class must implement the __str__ method. This decorat will add __repr__ and __unicode__ (for Python 2).
[ "Implements", "string", "conversion", "methods", "for", "the", "given", "class", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L97-L109
train
mila/pyoo
pyoo.py
_clean_slice
def _clean_slice(key, length): """ Validates and normalizes a cell range slice. >>> _clean_slice(slice(None, None), 10) (0, 10) >>> _clean_slice(slice(-10, 10), 10) (0, 10) >>> _clean_slice(slice(-11, 11), 10) (0, 10) >>> _clean_slice(slice('x', 'y'), 10) Traceback (most recent ...
python
def _clean_slice(key, length): """ Validates and normalizes a cell range slice. >>> _clean_slice(slice(None, None), 10) (0, 10) >>> _clean_slice(slice(-10, 10), 10) (0, 10) >>> _clean_slice(slice(-11, 11), 10) (0, 10) >>> _clean_slice(slice('x', 'y'), 10) Traceback (most recent ...
[ "def", "_clean_slice", "(", "key", ",", "length", ")", ":", "if", "key", ".", "step", "is", "not", "None", ":", "raise", "NotImplementedError", "(", "'Cell slice with step is not supported.'", ")", "start", ",", "stop", "=", "key", ".", "start", ",", "key", ...
Validates and normalizes a cell range slice. >>> _clean_slice(slice(None, None), 10) (0, 10) >>> _clean_slice(slice(-10, 10), 10) (0, 10) >>> _clean_slice(slice(-11, 11), 10) (0, 10) >>> _clean_slice(slice('x', 'y'), 10) Traceback (most recent call last): ... TypeError: Cell ind...
[ "Validates", "and", "normalizes", "a", "cell", "range", "slice", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L112-L154
train
mila/pyoo
pyoo.py
_clean_index
def _clean_index(key, length): """ Validates and normalizes a cell range index. >>> _clean_index(0, 10) 0 >>> _clean_index(-10, 10) 0 >>> _clean_index(10, 10) Traceback (most recent call last): ... IndexError: Cell index out of range. >>> _clean_index(-11, 10) Traceback ...
python
def _clean_index(key, length): """ Validates and normalizes a cell range index. >>> _clean_index(0, 10) 0 >>> _clean_index(-10, 10) 0 >>> _clean_index(10, 10) Traceback (most recent call last): ... IndexError: Cell index out of range. >>> _clean_index(-11, 10) Traceback ...
[ "def", "_clean_index", "(", "key", ",", "length", ")", ":", "if", "not", "isinstance", "(", "key", ",", "integer_types", ")", ":", "raise", "TypeError", "(", "'Cell indices must be integers, %s given.'", "%", "type", "(", "key", ")", ".", "__name__", ")", "i...
Validates and normalizes a cell range index. >>> _clean_index(0, 10) 0 >>> _clean_index(-10, 10) 0 >>> _clean_index(10, 10) Traceback (most recent call last): ... IndexError: Cell index out of range. >>> _clean_index(-11, 10) Traceback (most recent call last): ... IndexE...
[ "Validates", "and", "normalizes", "a", "cell", "range", "index", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L157-L186
train
mila/pyoo
pyoo.py
_col_name
def _col_name(index): """ Converts a column index to a column name. >>> _col_name(0) 'A' >>> _col_name(26) 'AA' """ for exp in itertools.count(1): limit = 26 ** exp if index < limit: return ''.join(chr(ord('A') + index // (26 ** i) % 26) for i in range(exp-1...
python
def _col_name(index): """ Converts a column index to a column name. >>> _col_name(0) 'A' >>> _col_name(26) 'AA' """ for exp in itertools.count(1): limit = 26 ** exp if index < limit: return ''.join(chr(ord('A') + index // (26 ** i) % 26) for i in range(exp-1...
[ "def", "_col_name", "(", "index", ")", ":", "for", "exp", "in", "itertools", ".", "count", "(", "1", ")", ":", "limit", "=", "26", "**", "exp", "if", "index", "<", "limit", ":", "return", "''", ".", "join", "(", "chr", "(", "ord", "(", "'A'", "...
Converts a column index to a column name. >>> _col_name(0) 'A' >>> _col_name(26) 'AA'
[ "Converts", "a", "column", "index", "to", "a", "column", "name", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L202-L216
train
mila/pyoo
pyoo.py
Axis.__set_title
def __set_title(self, value): """ Sets title of this axis. """ # OpenOffice on Debian "squeeze" ignore value of target.XAxis.String # unless target.HasXAxisTitle is set to True first. (Despite the # fact that target.HasXAxisTitle is reported to be False until # ta...
python
def __set_title(self, value): """ Sets title of this axis. """ # OpenOffice on Debian "squeeze" ignore value of target.XAxis.String # unless target.HasXAxisTitle is set to True first. (Despite the # fact that target.HasXAxisTitle is reported to be False until # ta...
[ "def", "__set_title", "(", "self", ",", "value", ")", ":", "self", ".", "_target", ".", "setPropertyValue", "(", "self", ".", "_has_axis_title_property", ",", "True", ")", "target", "=", "self", ".", "_get_title_target", "(", ")", "target", ".", "setProperty...
Sets title of this axis.
[ "Sets", "title", "of", "this", "axis", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L505-L515
train
mila/pyoo
pyoo.py
Chart.ranges
def ranges(self): """ Returns a list of addresses with source data. """ ranges = self._target.getRanges() return map(SheetAddress._from_uno, ranges)
python
def ranges(self): """ Returns a list of addresses with source data. """ ranges = self._target.getRanges() return map(SheetAddress._from_uno, ranges)
[ "def", "ranges", "(", "self", ")", ":", "ranges", "=", "self", ".", "_target", ".", "getRanges", "(", ")", "return", "map", "(", "SheetAddress", ".", "_from_uno", ",", "ranges", ")" ]
Returns a list of addresses with source data.
[ "Returns", "a", "list", "of", "addresses", "with", "source", "data", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L805-L810
train
mila/pyoo
pyoo.py
Chart.diagram
def diagram(self): """ Diagram - inner content of this chart. The diagram can be replaced by another type using change_type method. """ target = self._embedded.getDiagram() target_type = target.getDiagramType() cls = _DIAGRAM_TYPES.get(target_type, Diagram) ...
python
def diagram(self): """ Diagram - inner content of this chart. The diagram can be replaced by another type using change_type method. """ target = self._embedded.getDiagram() target_type = target.getDiagramType() cls = _DIAGRAM_TYPES.get(target_type, Diagram) ...
[ "def", "diagram", "(", "self", ")", ":", "target", "=", "self", ".", "_embedded", ".", "getDiagram", "(", ")", "target_type", "=", "target", ".", "getDiagramType", "(", ")", "cls", "=", "_DIAGRAM_TYPES", ".", "get", "(", "target_type", ",", "Diagram", ")...
Diagram - inner content of this chart. The diagram can be replaced by another type using change_type method.
[ "Diagram", "-", "inner", "content", "of", "this", "chart", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L813-L822
train
mila/pyoo
pyoo.py
Chart.change_type
def change_type(self, cls): """ Change type of diagram in this chart. Accepts one of classes which extend Diagram. """ target_type = cls._type target = self._embedded.createInstance(target_type) self._embedded.setDiagram(target) return cls(target)
python
def change_type(self, cls): """ Change type of diagram in this chart. Accepts one of classes which extend Diagram. """ target_type = cls._type target = self._embedded.createInstance(target_type) self._embedded.setDiagram(target) return cls(target)
[ "def", "change_type", "(", "self", ",", "cls", ")", ":", "target_type", "=", "cls", ".", "_type", "target", "=", "self", ".", "_embedded", ".", "createInstance", "(", "target_type", ")", "self", ".", "_embedded", ".", "setDiagram", "(", "target", ")", "r...
Change type of diagram in this chart. Accepts one of classes which extend Diagram.
[ "Change", "type", "of", "diagram", "in", "this", "chart", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L824-L833
train
mila/pyoo
pyoo.py
ChartCollection.create
def create(self, name, position, ranges=(), col_header=False, row_header=False): """ Creates and inserts a new chart. """ rect = self._uno_rect(position) ranges = self._uno_ranges(ranges) self._create(name, rect, ranges, col_header, row_header) return self[name]
python
def create(self, name, position, ranges=(), col_header=False, row_header=False): """ Creates and inserts a new chart. """ rect = self._uno_rect(position) ranges = self._uno_ranges(ranges) self._create(name, rect, ranges, col_header, row_header) return self[name]
[ "def", "create", "(", "self", ",", "name", ",", "position", ",", "ranges", "=", "(", ")", ",", "col_header", "=", "False", ",", "row_header", "=", "False", ")", ":", "rect", "=", "self", ".", "_uno_rect", "(", "position", ")", "ranges", "=", "self", ...
Creates and inserts a new chart.
[ "Creates", "and", "inserts", "a", "new", "chart", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L852-L859
train
mila/pyoo
pyoo.py
SheetCursor.get_target
def get_target(self, row, col, row_count, col_count): """ Moves cursor to the specified position and returns in. """ # This method is called for almost any operation so it should # be maximally optimized. # # Any comparison here is negligible compared to UNO call....
python
def get_target(self, row, col, row_count, col_count): """ Moves cursor to the specified position and returns in. """ # This method is called for almost any operation so it should # be maximally optimized. # # Any comparison here is negligible compared to UNO call....
[ "def", "get_target", "(", "self", ",", "row", ",", "col", ",", "row_count", ",", "col_count", ")", ":", "target", "=", "self", ".", "_target", "if", "self", ".", "row", "+", "row_count", ">", "self", ".", "max_row_count", "or", "self", ".", "col", "+...
Moves cursor to the specified position and returns in.
[ "Moves", "cursor", "to", "the", "specified", "position", "and", "returns", "in", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L916-L952
train
mila/pyoo
pyoo.py
Cell.__set_value
def __set_value(self, value): """ Sets cell value to a string or number based on the given value. """ array = ((self._clean_value(value),),) return self._get_target().setDataArray(array)
python
def __set_value(self, value): """ Sets cell value to a string or number based on the given value. """ array = ((self._clean_value(value),),) return self._get_target().setDataArray(array)
[ "def", "__set_value", "(", "self", ",", "value", ")", ":", "array", "=", "(", "(", "self", ".", "_clean_value", "(", "value", ")", ",", ")", ",", ")", "return", "self", ".", "_get_target", "(", ")", ".", "setDataArray", "(", "array", ")" ]
Sets cell value to a string or number based on the given value.
[ "Sets", "cell", "value", "to", "a", "string", "or", "number", "based", "on", "the", "given", "value", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1285-L1290
train
mila/pyoo
pyoo.py
Cell.__set_formula
def __set_formula(self, formula): """ Sets a formula in this cell. Any cell value can be set using this method. Actual formulas must start with an equal sign. """ array = ((self._clean_formula(formula),),) return self._get_target().setFormulaArray(array)
python
def __set_formula(self, formula): """ Sets a formula in this cell. Any cell value can be set using this method. Actual formulas must start with an equal sign. """ array = ((self._clean_formula(formula),),) return self._get_target().setFormulaArray(array)
[ "def", "__set_formula", "(", "self", ",", "formula", ")", ":", "array", "=", "(", "(", "self", ".", "_clean_formula", "(", "formula", ")", ",", ")", ",", ")", "return", "self", ".", "_get_target", "(", ")", ".", "setFormulaArray", "(", "array", ")" ]
Sets a formula in this cell. Any cell value can be set using this method. Actual formulas must start with an equal sign.
[ "Sets", "a", "formula", "in", "this", "cell", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1302-L1310
train
mila/pyoo
pyoo.py
TabularCellRange.__set_values
def __set_values(self, values): """ Sets values in this cell range from an iterable of iterables. """ # Tuple of tuples is required array = tuple(tuple(self._clean_value(col) for col in row) for row in values) self._get_target().setDataArray(array)
python
def __set_values(self, values): """ Sets values in this cell range from an iterable of iterables. """ # Tuple of tuples is required array = tuple(tuple(self._clean_value(col) for col in row) for row in values) self._get_target().setDataArray(array)
[ "def", "__set_values", "(", "self", ",", "values", ")", ":", "array", "=", "tuple", "(", "tuple", "(", "self", ".", "_clean_value", "(", "col", ")", "for", "col", "in", "row", ")", "for", "row", "in", "values", ")", "self", ".", "_get_target", "(", ...
Sets values in this cell range from an iterable of iterables.
[ "Sets", "values", "in", "this", "cell", "range", "from", "an", "iterable", "of", "iterables", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1390-L1396
train
mila/pyoo
pyoo.py
TabularCellRange.__set_formulas
def __set_formulas(self, formulas): """ Sets formulas in this cell range from an iterable of iterables. Any cell values can be set using this method. Actual formulas must start with an equal sign. """ # Tuple of tuples is required array = tuple(tuple(self._clean_...
python
def __set_formulas(self, formulas): """ Sets formulas in this cell range from an iterable of iterables. Any cell values can be set using this method. Actual formulas must start with an equal sign. """ # Tuple of tuples is required array = tuple(tuple(self._clean_...
[ "def", "__set_formulas", "(", "self", ",", "formulas", ")", ":", "array", "=", "tuple", "(", "tuple", "(", "self", ".", "_clean_formula", "(", "col", ")", "for", "col", "in", "row", ")", "for", "row", "in", "formulas", ")", "self", ".", "_get_target", ...
Sets formulas in this cell range from an iterable of iterables. Any cell values can be set using this method. Actual formulas must start with an equal sign.
[ "Sets", "formulas", "in", "this", "cell", "range", "from", "an", "iterable", "of", "iterables", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1407-L1416
train
mila/pyoo
pyoo.py
VerticalCellRange.__get_values
def __get_values(self): """ Gets values in this cell range as a tuple. This is much more effective than reading cell values one by one. """ array = self._get_target().getDataArray() return tuple(itertools.chain.from_iterable(array))
python
def __get_values(self): """ Gets values in this cell range as a tuple. This is much more effective than reading cell values one by one. """ array = self._get_target().getDataArray() return tuple(itertools.chain.from_iterable(array))
[ "def", "__get_values", "(", "self", ")", ":", "array", "=", "self", ".", "_get_target", "(", ")", ".", "getDataArray", "(", ")", "return", "tuple", "(", "itertools", ".", "chain", ".", "from_iterable", "(", "array", ")", ")" ]
Gets values in this cell range as a tuple. This is much more effective than reading cell values one by one.
[ "Gets", "values", "in", "this", "cell", "range", "as", "a", "tuple", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1511-L1518
train
mila/pyoo
pyoo.py
VerticalCellRange.__set_values
def __set_values(self, values): """ Sets values in this cell range from an iterable. This is much more effective than writing cell values one by one. """ array = tuple((self._clean_value(v),) for v in values) self._get_target().setDataArray(array)
python
def __set_values(self, values): """ Sets values in this cell range from an iterable. This is much more effective than writing cell values one by one. """ array = tuple((self._clean_value(v),) for v in values) self._get_target().setDataArray(array)
[ "def", "__set_values", "(", "self", ",", "values", ")", ":", "array", "=", "tuple", "(", "(", "self", ".", "_clean_value", "(", "v", ")", ",", ")", "for", "v", "in", "values", ")", "self", ".", "_get_target", "(", ")", ".", "setDataArray", "(", "ar...
Sets values in this cell range from an iterable. This is much more effective than writing cell values one by one.
[ "Sets", "values", "in", "this", "cell", "range", "from", "an", "iterable", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1519-L1526
train
mila/pyoo
pyoo.py
VerticalCellRange.__get_formulas
def __get_formulas(self): """ Gets formulas in this cell range as a tuple. If cells contain actual formulas then the returned values start with an equal sign but all values are returned. """ array = self._get_target().getFormulaArray() return tuple(itertools.cha...
python
def __get_formulas(self): """ Gets formulas in this cell range as a tuple. If cells contain actual formulas then the returned values start with an equal sign but all values are returned. """ array = self._get_target().getFormulaArray() return tuple(itertools.cha...
[ "def", "__get_formulas", "(", "self", ")", ":", "array", "=", "self", ".", "_get_target", "(", ")", ".", "getFormulaArray", "(", ")", "return", "tuple", "(", "itertools", ".", "chain", ".", "from_iterable", "(", "array", ")", ")" ]
Gets formulas in this cell range as a tuple. If cells contain actual formulas then the returned values start with an equal sign but all values are returned.
[ "Gets", "formulas", "in", "this", "cell", "range", "as", "a", "tuple", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1529-L1537
train
mila/pyoo
pyoo.py
VerticalCellRange.__set_formulas
def __set_formulas(self, formulas): """ Sets formulas in this cell range from an iterable. Any cell values can be set using this method. Actual formulas must start with an equal sign. """ array = tuple((self._clean_formula(v),) for v in formulas) self._get_target...
python
def __set_formulas(self, formulas): """ Sets formulas in this cell range from an iterable. Any cell values can be set using this method. Actual formulas must start with an equal sign. """ array = tuple((self._clean_formula(v),) for v in formulas) self._get_target...
[ "def", "__set_formulas", "(", "self", ",", "formulas", ")", ":", "array", "=", "tuple", "(", "(", "self", ".", "_clean_formula", "(", "v", ")", ",", ")", "for", "v", "in", "formulas", ")", "self", ".", "_get_target", "(", ")", ".", "setFormulaArray", ...
Sets formulas in this cell range from an iterable. Any cell values can be set using this method. Actual formulas must start with an equal sign.
[ "Sets", "formulas", "in", "this", "cell", "range", "from", "an", "iterable", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1538-L1546
train
mila/pyoo
pyoo.py
SpreadsheetCollection.create
def create(self, name, index=None): """ Creates a new sheet with the given name. If an optional index argument is not provided then the created sheet is appended at the end. Returns the new sheet. """ if index is None: index = len(self) self._create(n...
python
def create(self, name, index=None): """ Creates a new sheet with the given name. If an optional index argument is not provided then the created sheet is appended at the end. Returns the new sheet. """ if index is None: index = len(self) self._create(n...
[ "def", "create", "(", "self", ",", "name", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "index", "=", "len", "(", "self", ")", "self", ".", "_create", "(", "name", ",", "index", ")", "return", "self", "[", "name", "]" ]
Creates a new sheet with the given name. If an optional index argument is not provided then the created sheet is appended at the end. Returns the new sheet.
[ "Creates", "a", "new", "sheet", "with", "the", "given", "name", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1624-L1634
train
mila/pyoo
pyoo.py
SpreadsheetCollection.copy
def copy(self, old_name, new_name, index=None): """ Copies an old sheet with the old_name to a new sheet with new_name. If an optional index argument is not provided then the created sheet is appended at the end. Returns the new sheet. """ if index is None: i...
python
def copy(self, old_name, new_name, index=None): """ Copies an old sheet with the old_name to a new sheet with new_name. If an optional index argument is not provided then the created sheet is appended at the end. Returns the new sheet. """ if index is None: i...
[ "def", "copy", "(", "self", ",", "old_name", ",", "new_name", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "index", "=", "len", "(", "self", ")", "self", ".", "_copy", "(", "old_name", ",", "new_name", ",", "index", ")", ...
Copies an old sheet with the old_name to a new sheet with new_name. If an optional index argument is not provided then the created sheet is appended at the end. Returns the new sheet.
[ "Copies", "an", "old", "sheet", "with", "the", "old_name", "to", "a", "new", "sheet", "with", "new_name", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1636-L1646
train
mila/pyoo
pyoo.py
SpreadsheetDocument.save
def save(self, path=None, filter_name=None): """ Saves this document to a local file system. The optional first argument defaults to the document's path. Accept optional second argument which defines type of the saved file. Use one of FILTER_* constants or see list of ...
python
def save(self, path=None, filter_name=None): """ Saves this document to a local file system. The optional first argument defaults to the document's path. Accept optional second argument which defines type of the saved file. Use one of FILTER_* constants or see list of ...
[ "def", "save", "(", "self", ",", "path", "=", "None", ",", "filter_name", "=", "None", ")", ":", "if", "path", "is", "None", ":", "try", ":", "self", ".", "_target", ".", "store", "(", ")", "except", "_IOException", "as", "e", ":", "raise", "IOErro...
Saves this document to a local file system. The optional first argument defaults to the document's path. Accept optional second argument which defines type of the saved file. Use one of FILTER_* constants or see list of available filters at http://wakka.net/archives/7 or http:...
[ "Saves", "this", "document", "to", "a", "local", "file", "system", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1698-L1730
train
mila/pyoo
pyoo.py
SpreadsheetDocument.get_locale
def get_locale(self, language=None, country=None, variant=None): """ Returns locale which can be used for access to number formats. """ # http://www.openoffice.org/api/docs/common/ref/com/sun/star/lang/Locale.html locale = uno.createUnoStruct('com.sun.star.lang.Locale') i...
python
def get_locale(self, language=None, country=None, variant=None): """ Returns locale which can be used for access to number formats. """ # http://www.openoffice.org/api/docs/common/ref/com/sun/star/lang/Locale.html locale = uno.createUnoStruct('com.sun.star.lang.Locale') i...
[ "def", "get_locale", "(", "self", ",", "language", "=", "None", ",", "country", "=", "None", ",", "variant", "=", "None", ")", ":", "locale", "=", "uno", ".", "createUnoStruct", "(", "'com.sun.star.lang.Locale'", ")", "if", "language", ":", "locale", ".", ...
Returns locale which can be used for access to number formats.
[ "Returns", "locale", "which", "can", "be", "used", "for", "access", "to", "number", "formats", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1739-L1752
train
mila/pyoo
pyoo.py
SpreadsheetDocument.sheets
def sheets(self): """ Collection of sheets in this document. """ # http://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/XSpreadsheetDocument.html#getSheets try: return self._sheets except AttributeError: target = self._target.getSheets(...
python
def sheets(self): """ Collection of sheets in this document. """ # http://www.openoffice.org/api/docs/common/ref/com/sun/star/sheet/XSpreadsheetDocument.html#getSheets try: return self._sheets except AttributeError: target = self._target.getSheets(...
[ "def", "sheets", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_sheets", "except", "AttributeError", ":", "target", "=", "self", ".", "_target", ".", "getSheets", "(", ")", "self", ".", "_sheets", "=", "SpreadsheetCollection", "(", "self", "...
Collection of sheets in this document.
[ "Collection", "of", "sheets", "in", "this", "document", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1755-L1765
train
mila/pyoo
pyoo.py
SpreadsheetDocument.date_from_number
def date_from_number(self, value): """ Converts a float value to corresponding datetime instance. """ if not isinstance(value, numbers.Real): return None delta = datetime.timedelta(days=value) return self._null_date + delta
python
def date_from_number(self, value): """ Converts a float value to corresponding datetime instance. """ if not isinstance(value, numbers.Real): return None delta = datetime.timedelta(days=value) return self._null_date + delta
[ "def", "date_from_number", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "numbers", ".", "Real", ")", ":", "return", "None", "delta", "=", "datetime", ".", "timedelta", "(", "days", "=", "value", ")", "return", "sel...
Converts a float value to corresponding datetime instance.
[ "Converts", "a", "float", "value", "to", "corresponding", "datetime", "instance", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1767-L1774
train
mila/pyoo
pyoo.py
SpreadsheetDocument.date_to_number
def date_to_number(self, date): """ Converts a date or datetime instance to a corresponding float value. """ if isinstance(date, datetime.datetime): delta = date - self._null_date elif isinstance(date, datetime.date): delta = date - self._null_date.date() ...
python
def date_to_number(self, date): """ Converts a date or datetime instance to a corresponding float value. """ if isinstance(date, datetime.datetime): delta = date - self._null_date elif isinstance(date, datetime.date): delta = date - self._null_date.date() ...
[ "def", "date_to_number", "(", "self", ",", "date", ")", ":", "if", "isinstance", "(", "date", ",", "datetime", ".", "datetime", ")", ":", "delta", "=", "date", "-", "self", ".", "_null_date", "elif", "isinstance", "(", "date", ",", "datetime", ".", "da...
Converts a date or datetime instance to a corresponding float value.
[ "Converts", "a", "date", "or", "datetime", "instance", "to", "a", "corresponding", "float", "value", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1776-L1786
train
mila/pyoo
pyoo.py
SpreadsheetDocument.time_from_number
def time_from_number(self, value): """ Converts a float value to corresponding time instance. """ if not isinstance(value, numbers.Real): return None delta = datetime.timedelta(days=value) minutes, second = divmod(delta.seconds, 60) hour, minute = divm...
python
def time_from_number(self, value): """ Converts a float value to corresponding time instance. """ if not isinstance(value, numbers.Real): return None delta = datetime.timedelta(days=value) minutes, second = divmod(delta.seconds, 60) hour, minute = divm...
[ "def", "time_from_number", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "numbers", ".", "Real", ")", ":", "return", "None", "delta", "=", "datetime", ".", "timedelta", "(", "days", "=", "value", ")", "minutes", ","...
Converts a float value to corresponding time instance.
[ "Converts", "a", "float", "value", "to", "corresponding", "time", "instance", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1788-L1797
train
mila/pyoo
pyoo.py
SpreadsheetDocument.time_to_number
def time_to_number(self, time): """ Converts a time instance to a corresponding float value. """ if not isinstance(time, datetime.time): raise TypeError(time) return ((time.second / 60.0 + time.minute) / 60.0 + time.hour) / 24.0
python
def time_to_number(self, time): """ Converts a time instance to a corresponding float value. """ if not isinstance(time, datetime.time): raise TypeError(time) return ((time.second / 60.0 + time.minute) / 60.0 + time.hour) / 24.0
[ "def", "time_to_number", "(", "self", ",", "time", ")", ":", "if", "not", "isinstance", "(", "time", ",", "datetime", ".", "time", ")", ":", "raise", "TypeError", "(", "time", ")", "return", "(", "(", "time", ".", "second", "/", "60.0", "+", "time", ...
Converts a time instance to a corresponding float value.
[ "Converts", "a", "time", "instance", "to", "a", "corresponding", "float", "value", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1799-L1805
train
mila/pyoo
pyoo.py
SpreadsheetDocument._null_date
def _null_date(self): """ Returns date which is represented by a integer 0. """ # http://www.openoffice.org/api/docs/common/ref/com/sun/star/util/NumberFormatSettings.html#NullDate try: return self.__null_date except AttributeError: number_settings...
python
def _null_date(self): """ Returns date which is represented by a integer 0. """ # http://www.openoffice.org/api/docs/common/ref/com/sun/star/util/NumberFormatSettings.html#NullDate try: return self.__null_date except AttributeError: number_settings...
[ "def", "_null_date", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__null_date", "except", "AttributeError", ":", "number_settings", "=", "self", ".", "_target", ".", "getNumberFormatSettings", "(", ")", "d", "=", "number_settings", ".", "getPrope...
Returns date which is represented by a integer 0.
[ "Returns", "date", "which", "is", "represented", "by", "a", "integer", "0", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1810-L1821
train
mila/pyoo
pyoo.py
LazyDesktop.create_spreadsheet
def create_spreadsheet(self): """ Creates a new spreadsheet document. """ desktop = self.cls(self.hostname, self.port, self.pipe) return desktop.create_spreadsheet()
python
def create_spreadsheet(self): """ Creates a new spreadsheet document. """ desktop = self.cls(self.hostname, self.port, self.pipe) return desktop.create_spreadsheet()
[ "def", "create_spreadsheet", "(", "self", ")", ":", "desktop", "=", "self", ".", "cls", "(", "self", ".", "hostname", ",", "self", ".", "port", ",", "self", ".", "pipe", ")", "return", "desktop", ".", "create_spreadsheet", "(", ")" ]
Creates a new spreadsheet document.
[ "Creates", "a", "new", "spreadsheet", "document", "." ]
1e024999f608c87ea72cd443e39c89eb0ba3cc62
https://github.com/mila/pyoo/blob/1e024999f608c87ea72cd443e39c89eb0ba3cc62/pyoo.py#L1911-L1916
train
mbakker7/timml
timml/util.py
PlotTim.vcontoursf1D
def vcontoursf1D(self, x1, x2, nx, levels, labels=False, decimals=0, color=None, nudge=1e-6, newfig=True, figsize=None, layout=True, ax=None): """ Vertical contour for 1D model """ naq = self.aq.naq xflow = np.linspace(x1 + nudge, x2 - nudge, nx) Qx ...
python
def vcontoursf1D(self, x1, x2, nx, levels, labels=False, decimals=0, color=None, nudge=1e-6, newfig=True, figsize=None, layout=True, ax=None): """ Vertical contour for 1D model """ naq = self.aq.naq xflow = np.linspace(x1 + nudge, x2 - nudge, nx) Qx ...
[ "def", "vcontoursf1D", "(", "self", ",", "x1", ",", "x2", ",", "nx", ",", "levels", ",", "labels", "=", "False", ",", "decimals", "=", "0", ",", "color", "=", "None", ",", "nudge", "=", "1e-6", ",", "newfig", "=", "True", ",", "figsize", "=", "No...
Vertical contour for 1D model
[ "Vertical", "contour", "for", "1D", "model" ]
91e99ad573cb8a9ad8ac1fa041c3ca44520c2390
https://github.com/mbakker7/timml/blob/91e99ad573cb8a9ad8ac1fa041c3ca44520c2390/timml/util.py#L211-L241
train
mbakker7/timml
timml/linesink1d.py
LineSink1DBase.discharge
def discharge(self): """Discharge per unit length""" Q = np.zeros(self.aq.naq) Q[self.layers] = self.parameters[:, 0] return Q
python
def discharge(self): """Discharge per unit length""" Q = np.zeros(self.aq.naq) Q[self.layers] = self.parameters[:, 0] return Q
[ "def", "discharge", "(", "self", ")", ":", "Q", "=", "np", ".", "zeros", "(", "self", ".", "aq", ".", "naq", ")", "Q", "[", "self", ".", "layers", "]", "=", "self", ".", "parameters", "[", ":", ",", "0", "]", "return", "Q" ]
Discharge per unit length
[ "Discharge", "per", "unit", "length" ]
91e99ad573cb8a9ad8ac1fa041c3ca44520c2390
https://github.com/mbakker7/timml/blob/91e99ad573cb8a9ad8ac1fa041c3ca44520c2390/timml/linesink1d.py#L92-L96
train
mbakker7/timml
timml/linesink.py
LineSinkStringBase2.discharge
def discharge(self): """Discharge of the element in each layer """ rv = np.zeros(self.aq[0].naq) Qls = self.parameters[:, 0] * self.dischargeinf() Qls.shape = (self.nls, self.nlayers, self.order + 1) Qls = np.sum(Qls, 2) for i, q in enumerate(Qls): ...
python
def discharge(self): """Discharge of the element in each layer """ rv = np.zeros(self.aq[0].naq) Qls = self.parameters[:, 0] * self.dischargeinf() Qls.shape = (self.nls, self.nlayers, self.order + 1) Qls = np.sum(Qls, 2) for i, q in enumerate(Qls): ...
[ "def", "discharge", "(", "self", ")", ":", "rv", "=", "np", ".", "zeros", "(", "self", ".", "aq", "[", "0", "]", ".", "naq", ")", "Qls", "=", "self", ".", "parameters", "[", ":", ",", "0", "]", "*", "self", ".", "dischargeinf", "(", ")", "Qls...
Discharge of the element in each layer
[ "Discharge", "of", "the", "element", "in", "each", "layer" ]
91e99ad573cb8a9ad8ac1fa041c3ca44520c2390
https://github.com/mbakker7/timml/blob/91e99ad573cb8a9ad8ac1fa041c3ca44520c2390/timml/linesink.py#L753-L764
train
mbakker7/timml
timml/aquifer.py
AquiferData.findlayer
def findlayer(self, z): ''' Returns layer-number, layer-type and model-layer-number''' if z > self.z[0]: modellayer, ltype = -1, 'above' layernumber = None elif z < self.z[-1]: modellayer, ltype = len(self.layernumber), 'below' layernumber ...
python
def findlayer(self, z): ''' Returns layer-number, layer-type and model-layer-number''' if z > self.z[0]: modellayer, ltype = -1, 'above' layernumber = None elif z < self.z[-1]: modellayer, ltype = len(self.layernumber), 'below' layernumber ...
[ "def", "findlayer", "(", "self", ",", "z", ")", ":", "if", "z", ">", "self", ".", "z", "[", "0", "]", ":", "modellayer", ",", "ltype", "=", "-", "1", ",", "'above'", "layernumber", "=", "None", "elif", "z", "<", "self", ".", "z", "[", "-", "1...
Returns layer-number, layer-type and model-layer-number
[ "Returns", "layer", "-", "number", "layer", "-", "type", "and", "model", "-", "layer", "-", "number" ]
91e99ad573cb8a9ad8ac1fa041c3ca44520c2390
https://github.com/mbakker7/timml/blob/91e99ad573cb8a9ad8ac1fa041c3ca44520c2390/timml/aquifer.py#L85-L98
train
mbakker7/timml
timml/model.py
Model.remove_element
def remove_element(self, e): """Remove element `e` from model """ if e.label is not None: self.elementdict.pop(e.label) self.elementlist.remove(e)
python
def remove_element(self, e): """Remove element `e` from model """ if e.label is not None: self.elementdict.pop(e.label) self.elementlist.remove(e)
[ "def", "remove_element", "(", "self", ",", "e", ")", ":", "if", "e", ".", "label", "is", "not", "None", ":", "self", ".", "elementdict", ".", "pop", "(", "e", ".", "label", ")", "self", ".", "elementlist", ".", "remove", "(", "e", ")" ]
Remove element `e` from model
[ "Remove", "element", "e", "from", "model" ]
91e99ad573cb8a9ad8ac1fa041c3ca44520c2390
https://github.com/mbakker7/timml/blob/91e99ad573cb8a9ad8ac1fa041c3ca44520c2390/timml/model.py#L70-L75
train
limix/pandas-plink
pandas_plink/_read.py
read_plink
def read_plink(file_prefix, verbose=True): r"""Read PLINK files into Pandas data frames. Parameters ---------- file_prefix : str Path prefix to the set of PLINK files. It supports loading many BED files at once using globstrings wildcard. verbose : bool ``True`` for progress...
python
def read_plink(file_prefix, verbose=True): r"""Read PLINK files into Pandas data frames. Parameters ---------- file_prefix : str Path prefix to the set of PLINK files. It supports loading many BED files at once using globstrings wildcard. verbose : bool ``True`` for progress...
[ "def", "read_plink", "(", "file_prefix", ",", "verbose", "=", "True", ")", ":", "r", "from", "dask", ".", "array", "import", "concatenate", "file_prefixes", "=", "sorted", "(", "glob", "(", "file_prefix", ")", ")", "if", "len", "(", "file_prefixes", ")", ...
r"""Read PLINK files into Pandas data frames. Parameters ---------- file_prefix : str Path prefix to the set of PLINK files. It supports loading many BED files at once using globstrings wildcard. verbose : bool ``True`` for progress information; ``False`` otherwise. Returns...
[ "r", "Read", "PLINK", "files", "into", "Pandas", "data", "frames", "." ]
11ab505eef6ca9155dab6c7ec9e238a3747e0ec0
https://github.com/limix/pandas-plink/blob/11ab505eef6ca9155dab6c7ec9e238a3747e0ec0/pandas_plink/_read.py#L25-L151
train
moremoban/moban
setup.py
read_files
def read_files(*files): """Read files into setup""" text = "" for single_file in files: content = read(single_file) text = text + content + "\n" return text
python
def read_files(*files): """Read files into setup""" text = "" for single_file in files: content = read(single_file) text = text + content + "\n" return text
[ "def", "read_files", "(", "*", "files", ")", ":", "text", "=", "\"\"", "for", "single_file", "in", "files", ":", "content", "=", "read", "(", "single_file", ")", "text", "=", "text", "+", "content", "+", "\"\\n\"", "return", "text" ]
Read files into setup
[ "Read", "files", "into", "setup" ]
5d1674ae461b065a9a54fe89c445cbf6d3cd63c0
https://github.com/moremoban/moban/blob/5d1674ae461b065a9a54fe89c445cbf6d3cd63c0/setup.py#L148-L154
train
moremoban/moban
setup.py
read
def read(afile): """Read a file into setup""" the_relative_file = os.path.join(HERE, afile) with codecs.open(the_relative_file, 'r', 'utf-8') as opened_file: content = filter_out_test_code(opened_file) content = "".join(list(content)) return content
python
def read(afile): """Read a file into setup""" the_relative_file = os.path.join(HERE, afile) with codecs.open(the_relative_file, 'r', 'utf-8') as opened_file: content = filter_out_test_code(opened_file) content = "".join(list(content)) return content
[ "def", "read", "(", "afile", ")", ":", "the_relative_file", "=", "os", ".", "path", ".", "join", "(", "HERE", ",", "afile", ")", "with", "codecs", ".", "open", "(", "the_relative_file", ",", "'r'", ",", "'utf-8'", ")", "as", "opened_file", ":", "conten...
Read a file into setup
[ "Read", "a", "file", "into", "setup" ]
5d1674ae461b065a9a54fe89c445cbf6d3cd63c0
https://github.com/moremoban/moban/blob/5d1674ae461b065a9a54fe89c445cbf6d3cd63c0/setup.py#L157-L163
train
moremoban/moban
moban/main.py
main
def main(): """ program entry point """ parser = create_parser() options = vars(parser.parse_args()) HASH_STORE.IGNORE_CACHE_FILE = options[constants.LABEL_FORCE] moban_file = options[constants.LABEL_MOBANFILE] load_engine_factory_and_engines() # Error: jinja2 if removed if moban_fi...
python
def main(): """ program entry point """ parser = create_parser() options = vars(parser.parse_args()) HASH_STORE.IGNORE_CACHE_FILE = options[constants.LABEL_FORCE] moban_file = options[constants.LABEL_MOBANFILE] load_engine_factory_and_engines() # Error: jinja2 if removed if moban_fi...
[ "def", "main", "(", ")", ":", "parser", "=", "create_parser", "(", ")", "options", "=", "vars", "(", "parser", ".", "parse_args", "(", ")", ")", "HASH_STORE", ".", "IGNORE_CACHE_FILE", "=", "options", "[", "constants", ".", "LABEL_FORCE", "]", "moban_file"...
program entry point
[ "program", "entry", "point" ]
5d1674ae461b065a9a54fe89c445cbf6d3cd63c0
https://github.com/moremoban/moban/blob/5d1674ae461b065a9a54fe89c445cbf6d3cd63c0/moban/main.py#L21-L49
train
moremoban/moban
moban/main.py
create_parser
def create_parser(): """ construct the program options """ parser = argparse.ArgumentParser( prog=constants.PROGRAM_NAME, description=constants.PROGRAM_DESCRIPTION ) parser.add_argument( "-cd", "--%s" % constants.LABEL_CONFIG_DIR, help="the directory for configura...
python
def create_parser(): """ construct the program options """ parser = argparse.ArgumentParser( prog=constants.PROGRAM_NAME, description=constants.PROGRAM_DESCRIPTION ) parser.add_argument( "-cd", "--%s" % constants.LABEL_CONFIG_DIR, help="the directory for configura...
[ "def", "create_parser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "constants", ".", "PROGRAM_NAME", ",", "description", "=", "constants", ".", "PROGRAM_DESCRIPTION", ")", "parser", ".", "add_argument", "(", "\"-cd\"", "...
construct the program options
[ "construct", "the", "program", "options" ]
5d1674ae461b065a9a54fe89c445cbf6d3cd63c0
https://github.com/moremoban/moban/blob/5d1674ae461b065a9a54fe89c445cbf6d3cd63c0/moban/main.py#L61-L125
train
moremoban/moban
moban/main.py
handle_moban_file
def handle_moban_file(moban_file, options): """ act upon default moban file """ moban_file_configurations = load_data(None, moban_file) if moban_file_configurations is None: raise exceptions.MobanfileGrammarException( constants.ERROR_INVALID_MOBAN_FILE % moban_file ) ...
python
def handle_moban_file(moban_file, options): """ act upon default moban file """ moban_file_configurations = load_data(None, moban_file) if moban_file_configurations is None: raise exceptions.MobanfileGrammarException( constants.ERROR_INVALID_MOBAN_FILE % moban_file ) ...
[ "def", "handle_moban_file", "(", "moban_file", ",", "options", ")", ":", "moban_file_configurations", "=", "load_data", "(", "None", ",", "moban_file", ")", "if", "moban_file_configurations", "is", "None", ":", "raise", "exceptions", ".", "MobanfileGrammarException", ...
act upon default moban file
[ "act", "upon", "default", "moban", "file" ]
5d1674ae461b065a9a54fe89c445cbf6d3cd63c0
https://github.com/moremoban/moban/blob/5d1674ae461b065a9a54fe89c445cbf6d3cd63c0/moban/main.py#L128-L154
train
moremoban/moban
moban/main.py
handle_command_line
def handle_command_line(options): """ act upon command options """ options = merge(options, constants.DEFAULT_OPTIONS) engine = plugins.ENGINES.get_engine( options[constants.LABEL_TEMPLATE_TYPE], options[constants.LABEL_TMPL_DIRS], options[constants.LABEL_CONFIG_DIR], ) ...
python
def handle_command_line(options): """ act upon command options """ options = merge(options, constants.DEFAULT_OPTIONS) engine = plugins.ENGINES.get_engine( options[constants.LABEL_TEMPLATE_TYPE], options[constants.LABEL_TMPL_DIRS], options[constants.LABEL_CONFIG_DIR], ) ...
[ "def", "handle_command_line", "(", "options", ")", ":", "options", "=", "merge", "(", "options", ",", "constants", ".", "DEFAULT_OPTIONS", ")", "engine", "=", "plugins", ".", "ENGINES", ".", "get_engine", "(", "options", "[", "constants", ".", "LABEL_TEMPLATE_...
act upon command options
[ "act", "upon", "command", "options" ]
5d1674ae461b065a9a54fe89c445cbf6d3cd63c0
https://github.com/moremoban/moban/blob/5d1674ae461b065a9a54fe89c445cbf6d3cd63c0/moban/main.py#L179-L209
train
tammoippen/iso4217parse
iso4217parse/__init__.py
by_symbol
def by_symbol(symbol, country_code=None): """Get list of possible currencies for symbol; filter by country_code Look for all currencies that use the `symbol`. If there are currencies used in the country of `country_code`, return only those; otherwise return all found currencies. Parameters: ...
python
def by_symbol(symbol, country_code=None): """Get list of possible currencies for symbol; filter by country_code Look for all currencies that use the `symbol`. If there are currencies used in the country of `country_code`, return only those; otherwise return all found currencies. Parameters: ...
[ "def", "by_symbol", "(", "symbol", ",", "country_code", "=", "None", ")", ":", "res", "=", "_data", "(", ")", "[", "'symbol'", "]", ".", "get", "(", "symbol", ")", "if", "res", ":", "tmp_res", "=", "[", "]", "for", "d", "in", "res", ":", "if", ...
Get list of possible currencies for symbol; filter by country_code Look for all currencies that use the `symbol`. If there are currencies used in the country of `country_code`, return only those; otherwise return all found currencies. Parameters: symbol: unicode Currency symbo...
[ "Get", "list", "of", "possible", "currencies", "for", "symbol", ";", "filter", "by", "country_code" ]
dd2971bd66e83424c43d16d6b54b3f6d0c4201cf
https://github.com/tammoippen/iso4217parse/blob/dd2971bd66e83424c43d16d6b54b3f6d0c4201cf/iso4217parse/__init__.py#L157-L181
train