repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.from_other
def from_other(cls, ori, **kwargs): """ Creates a new instance with an existing one as a template. Parameters ---------- ori : SymbolicSys instance \\*\\*kwargs: Keyword arguments used to create the new instance. Returns ------- A new instanc...
python
def from_other(cls, ori, **kwargs): """ Creates a new instance with an existing one as a template. Parameters ---------- ori : SymbolicSys instance \\*\\*kwargs: Keyword arguments used to create the new instance. Returns ------- A new instanc...
[ "def", "from_other", "(", "cls", ",", "ori", ",", "*", "*", "kwargs", ")", ":", "for", "k", "in", "cls", ".", "_attrs_to_copy", "+", "(", "'params'", ",", "'roots'", ",", "'init_indep'", ",", "'init_dep'", ")", ":", "if", "k", "not", "in", "kwargs", ...
Creates a new instance with an existing one as a template. Parameters ---------- ori : SymbolicSys instance \\*\\*kwargs: Keyword arguments used to create the new instance. Returns ------- A new instance of the class.
[ "Creates", "a", "new", "instance", "with", "an", "existing", "one", "as", "a", "template", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L466-L508
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.from_other_new_params
def from_other_new_params(cls, ori, par_subs, new_pars, new_par_names=None, new_latex_par_names=None, **kwargs): """ Creates a new instance with an existing one as a template (with new parameters) Calls ``.from_other`` but first it replaces some parameters according to ``p...
python
def from_other_new_params(cls, ori, par_subs, new_pars, new_par_names=None, new_latex_par_names=None, **kwargs): """ Creates a new instance with an existing one as a template (with new parameters) Calls ``.from_other`` but first it replaces some parameters according to ``p...
[ "def", "from_other_new_params", "(", "cls", ",", "ori", ",", "par_subs", ",", "new_pars", ",", "new_par_names", "=", "None", ",", "new_latex_par_names", "=", "None", ",", "*", "*", "kwargs", ")", ":", "new_exprs", "=", "[", "expr", ".", "subs", "(", "par...
Creates a new instance with an existing one as a template (with new parameters) Calls ``.from_other`` but first it replaces some parameters according to ``par_subs`` and (optionally) introduces new parameters given in ``new_pars``. Parameters ---------- ori : SymbolicSys instan...
[ "Creates", "a", "new", "instance", "with", "an", "existing", "one", "as", "a", "template", "(", "with", "new", "parameters", ")" ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L511-L557
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.from_other_new_params_by_name
def from_other_new_params_by_name(cls, ori, par_subs, new_par_names=(), **kwargs): """ Creates a new instance with an existing one as a template (with new parameters) Calls ``.from_other_new_params`` but first it creates the new instances from user provided callbacks generating the expressions ...
python
def from_other_new_params_by_name(cls, ori, par_subs, new_par_names=(), **kwargs): """ Creates a new instance with an existing one as a template (with new parameters) Calls ``.from_other_new_params`` but first it creates the new instances from user provided callbacks generating the expressions ...
[ "def", "from_other_new_params_by_name", "(", "cls", ",", "ori", ",", "par_subs", ",", "new_par_names", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "if", "not", "ori", ".", "dep_by_name", ":", "warnings", ".", "warn", "(", "'dep_by_name is not True'", ...
Creates a new instance with an existing one as a template (with new parameters) Calls ``.from_other_new_params`` but first it creates the new instances from user provided callbacks generating the expressions the parameter substitutions. Parameters ---------- ori : SymbolicSys i...
[ "Creates", "a", "new", "instance", "with", "an", "existing", "one", "as", "a", "template", "(", "with", "new", "parameters", ")" ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L560-L587
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.get_jac
def get_jac(self): """ Derives the jacobian from ``self.exprs`` and ``self.dep``. """ if self._jac is True: if self.sparse is True: self._jac, self._colptrs, self._rowvals = self.be.sparse_jacobian_csc(self.exprs, self.dep) elif self.band is not None: # Banded ...
python
def get_jac(self): """ Derives the jacobian from ``self.exprs`` and ``self.dep``. """ if self._jac is True: if self.sparse is True: self._jac, self._colptrs, self._rowvals = self.be.sparse_jacobian_csc(self.exprs, self.dep) elif self.band is not None: # Banded ...
[ "def", "get_jac", "(", "self", ")", ":", "if", "self", ".", "_jac", "is", "True", ":", "if", "self", ".", "sparse", "is", "True", ":", "self", ".", "_jac", ",", "self", ".", "_colptrs", ",", "self", ".", "_rowvals", "=", "self", ".", "be", ".", ...
Derives the jacobian from ``self.exprs`` and ``self.dep``.
[ "Derives", "the", "jacobian", "from", "self", ".", "exprs", "and", "self", ".", "dep", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L637-L650
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.get_jtimes
def get_jtimes(self): """ Derive the jacobian-vector product from ``self.exprs`` and ``self.dep``""" if self._jtimes is False: return False if self._jtimes is True: r = self.be.Dummy('r') v = tuple(self.be.Dummy('v_{0}'.format(i)) for i in range(self.ny)) ...
python
def get_jtimes(self): """ Derive the jacobian-vector product from ``self.exprs`` and ``self.dep``""" if self._jtimes is False: return False if self._jtimes is True: r = self.be.Dummy('r') v = tuple(self.be.Dummy('v_{0}'.format(i)) for i in range(self.ny)) ...
[ "def", "get_jtimes", "(", "self", ")", ":", "if", "self", ".", "_jtimes", "is", "False", ":", "return", "False", "if", "self", ".", "_jtimes", "is", "True", ":", "r", "=", "self", ".", "be", ".", "Dummy", "(", "'r'", ")", "v", "=", "tuple", "(", ...
Derive the jacobian-vector product from ``self.exprs`` and ``self.dep``
[ "Derive", "the", "jacobian", "-", "vector", "product", "from", "self", ".", "exprs", "and", "self", ".", "dep" ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L652-L664
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.jacobian_singular
def jacobian_singular(self): """ Returns True if Jacobian is singular, else False. """ cses, (jac_in_cses,) = self.be.cse(self.get_jac()) if jac_in_cses.nullspace(): return True else: return False
python
def jacobian_singular(self): """ Returns True if Jacobian is singular, else False. """ cses, (jac_in_cses,) = self.be.cse(self.get_jac()) if jac_in_cses.nullspace(): return True else: return False
[ "def", "jacobian_singular", "(", "self", ")", ":", "cses", ",", "(", "jac_in_cses", ",", ")", "=", "self", ".", "be", ".", "cse", "(", "self", ".", "get_jac", "(", ")", ")", "if", "jac_in_cses", ".", "nullspace", "(", ")", ":", "return", "True", "e...
Returns True if Jacobian is singular, else False.
[ "Returns", "True", "if", "Jacobian", "is", "singular", "else", "False", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L666-L672
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.get_dfdx
def get_dfdx(self): """ Calculates 2nd derivatives of ``self.exprs`` """ if self._dfdx is True: if self.indep is None: zero = 0*self.be.Dummy()**0 self._dfdx = self.be.Matrix(1, self.ny, [zero]*self.ny) else: self._dfdx = self.be.Ma...
python
def get_dfdx(self): """ Calculates 2nd derivatives of ``self.exprs`` """ if self._dfdx is True: if self.indep is None: zero = 0*self.be.Dummy()**0 self._dfdx = self.be.Matrix(1, self.ny, [zero]*self.ny) else: self._dfdx = self.be.Ma...
[ "def", "get_dfdx", "(", "self", ")", ":", "if", "self", ".", "_dfdx", "is", "True", ":", "if", "self", ".", "indep", "is", "None", ":", "zero", "=", "0", "*", "self", ".", "be", ".", "Dummy", "(", ")", "**", "0", "self", ".", "_dfdx", "=", "s...
Calculates 2nd derivatives of ``self.exprs``
[ "Calculates", "2nd", "derivatives", "of", "self", ".", "exprs" ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L674-L684
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.get_f_ty_callback
def get_f_ty_callback(self): """ Generates a callback for evaluating ``self.exprs``. """ cb = self._callback_factory(self.exprs) lb = self.lower_bounds ub = self.upper_bounds if lb is not None or ub is not None: def _bounds_wrapper(t, y, p=(), be=None): ...
python
def get_f_ty_callback(self): """ Generates a callback for evaluating ``self.exprs``. """ cb = self._callback_factory(self.exprs) lb = self.lower_bounds ub = self.upper_bounds if lb is not None or ub is not None: def _bounds_wrapper(t, y, p=(), be=None): ...
[ "def", "get_f_ty_callback", "(", "self", ")", ":", "cb", "=", "self", ".", "_callback_factory", "(", "self", ".", "exprs", ")", "lb", "=", "self", ".", "lower_bounds", "ub", "=", "self", ".", "upper_bounds", "if", "lb", "is", "not", "None", "or", "ub",...
Generates a callback for evaluating ``self.exprs``.
[ "Generates", "a", "callback", "for", "evaluating", "self", ".", "exprs", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L689-L709
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.get_j_ty_callback
def get_j_ty_callback(self): """ Generates a callback for evaluating the jacobian. """ j_exprs = self.get_jac() if j_exprs is False: return None cb = self._callback_factory(j_exprs) if self.sparse: from scipy.sparse import csc_matrix def spars...
python
def get_j_ty_callback(self): """ Generates a callback for evaluating the jacobian. """ j_exprs = self.get_jac() if j_exprs is False: return None cb = self._callback_factory(j_exprs) if self.sparse: from scipy.sparse import csc_matrix def spars...
[ "def", "get_j_ty_callback", "(", "self", ")", ":", "j_exprs", "=", "self", ".", "get_jac", "(", ")", "if", "j_exprs", "is", "False", ":", "return", "None", "cb", "=", "self", ".", "_callback_factory", "(", "j_exprs", ")", "if", "self", ".", "sparse", "...
Generates a callback for evaluating the jacobian.
[ "Generates", "a", "callback", "for", "evaluating", "the", "jacobian", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L711-L726
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.get_dfdx_callback
def get_dfdx_callback(self): """ Generate a callback for evaluating derivative of ``self.exprs`` """ dfdx_exprs = self.get_dfdx() if dfdx_exprs is False: return None return self._callback_factory(dfdx_exprs)
python
def get_dfdx_callback(self): """ Generate a callback for evaluating derivative of ``self.exprs`` """ dfdx_exprs = self.get_dfdx() if dfdx_exprs is False: return None return self._callback_factory(dfdx_exprs)
[ "def", "get_dfdx_callback", "(", "self", ")", ":", "dfdx_exprs", "=", "self", ".", "get_dfdx", "(", ")", "if", "dfdx_exprs", "is", "False", ":", "return", "None", "return", "self", ".", "_callback_factory", "(", "dfdx_exprs", ")" ]
Generate a callback for evaluating derivative of ``self.exprs``
[ "Generate", "a", "callback", "for", "evaluating", "derivative", "of", "self", ".", "exprs" ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L728-L733
bjodah/pyodesys
pyodesys/symbolic.py
SymbolicSys.get_jtimes_callback
def get_jtimes_callback(self): """ Generate a callback fro evaluating the jacobian-vector product.""" jtimes = self.get_jtimes() if jtimes is False: return None v, jtimes_exprs = jtimes return _Callback(self.indep, tuple(self.dep) + tuple(v), self.params, ...
python
def get_jtimes_callback(self): """ Generate a callback fro evaluating the jacobian-vector product.""" jtimes = self.get_jtimes() if jtimes is False: return None v, jtimes_exprs = jtimes return _Callback(self.indep, tuple(self.dep) + tuple(v), self.params, ...
[ "def", "get_jtimes_callback", "(", "self", ")", ":", "jtimes", "=", "self", ".", "get_jtimes", "(", ")", "if", "jtimes", "is", "False", ":", "return", "None", "v", ",", "jtimes_exprs", "=", "jtimes", "return", "_Callback", "(", "self", ".", "indep", ",",...
Generate a callback fro evaluating the jacobian-vector product.
[ "Generate", "a", "callback", "fro", "evaluating", "the", "jacobian", "-", "vector", "product", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L735-L742
bjodah/pyodesys
pyodesys/symbolic.py
TransformedSys.from_callback
def from_callback(cls, cb, ny=None, nparams=None, dep_transf_cbs=None, indep_transf_cbs=None, roots_cb=None, **kwargs): """ Create an instance from a callback. Analogous to :func:`SymbolicSys.from_callback`. Parameters ---------- cb : callable ...
python
def from_callback(cls, cb, ny=None, nparams=None, dep_transf_cbs=None, indep_transf_cbs=None, roots_cb=None, **kwargs): """ Create an instance from a callback. Analogous to :func:`SymbolicSys.from_callback`. Parameters ---------- cb : callable ...
[ "def", "from_callback", "(", "cls", ",", "cb", ",", "ny", "=", "None", ",", "nparams", "=", "None", ",", "dep_transf_cbs", "=", "None", ",", "indep_transf_cbs", "=", "None", ",", "roots_cb", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ny", ",", ...
Create an instance from a callback. Analogous to :func:`SymbolicSys.from_callback`. Parameters ---------- cb : callable Signature ``rhs(x, y[:], p[:]) -> f[:]`` ny : int length of y nparams : int length of p dep_transf_cbs : i...
[ "Create", "an", "instance", "from", "a", "callback", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L885-L935
bjodah/pyodesys
pyodesys/symbolic.py
ScaledSys.from_callback
def from_callback(cls, cb, ny=None, nparams=None, dep_scaling=1, indep_scaling=1, **kwargs): """ Create an instance from a callback. Analogous to :func:`SymbolicSys.from_callback`. Parameters ---------- cb : callable Signature rhs(x, y[...
python
def from_callback(cls, cb, ny=None, nparams=None, dep_scaling=1, indep_scaling=1, **kwargs): """ Create an instance from a callback. Analogous to :func:`SymbolicSys.from_callback`. Parameters ---------- cb : callable Signature rhs(x, y[...
[ "def", "from_callback", "(", "cls", ",", "cb", ",", "ny", "=", "None", ",", "nparams", "=", "None", ",", "dep_scaling", "=", "1", ",", "indep_scaling", "=", "1", ",", "*", "*", "kwargs", ")", ":", "return", "TransformedSys", ".", "from_callback", "(", ...
Create an instance from a callback. Analogous to :func:`SymbolicSys.from_callback`. Parameters ---------- cb : callable Signature rhs(x, y[:], p[:]) -> f[:] ny : int length of y nparams : int length of p dep_scaling : number (...
[ "Create", "an", "instance", "from", "a", "callback", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L1086-L1122
bjodah/pyodesys
pyodesys/symbolic.py
PartiallySolvedSystem.from_linear_invariants
def from_linear_invariants(cls, ori_sys, preferred=None, **kwargs): """ Reformulates the ODE system in fewer variables. Given linear invariant equations one can always reduce the number of dependent variables in the system by the rank of the matrix describing this linear system. ...
python
def from_linear_invariants(cls, ori_sys, preferred=None, **kwargs): """ Reformulates the ODE system in fewer variables. Given linear invariant equations one can always reduce the number of dependent variables in the system by the rank of the matrix describing this linear system. ...
[ "def", "from_linear_invariants", "(", "cls", ",", "ori_sys", ",", "preferred", "=", "None", ",", "*", "*", "kwargs", ")", ":", "_be", "=", "ori_sys", ".", "be", "A", "=", "_be", ".", "Matrix", "(", "ori_sys", ".", "linear_invariants", ")", "rA", ",", ...
Reformulates the ODE system in fewer variables. Given linear invariant equations one can always reduce the number of dependent variables in the system by the rank of the matrix describing this linear system. Parameters ---------- ori_sys : :class:`SymbolicSys` instance ...
[ "Reformulates", "the", "ODE", "system", "in", "fewer", "variables", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/symbolic.py#L1275-L1335
bjodah/pyodesys
pyodesys/core.py
integrate_auto_switch
def integrate_auto_switch(odes, kw, x, y0, params=(), **kwargs): """ Auto-switching between formulations of ODE system. In case one has a formulation of a system of ODEs which is preferential in the beginning of the integration, this function allows the user to run the integration with this system wher...
python
def integrate_auto_switch(odes, kw, x, y0, params=(), **kwargs): """ Auto-switching between formulations of ODE system. In case one has a formulation of a system of ODEs which is preferential in the beginning of the integration, this function allows the user to run the integration with this system wher...
[ "def", "integrate_auto_switch", "(", "odes", ",", "kw", ",", "x", ",", "y0", ",", "params", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "x_arr", "=", "np", ".", "asarray", "(", "x", ")", "if", "x_arr", ".", "shape", "[", "-", "1", "]", ...
Auto-switching between formulations of ODE system. In case one has a formulation of a system of ODEs which is preferential in the beginning of the integration, this function allows the user to run the integration with this system where it takes a user-specified maximum number of steps before switching ...
[ "Auto", "-", "switching", "between", "formulations", "of", "ODE", "system", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L820-L911
bjodah/pyodesys
pyodesys/core.py
chained_parameter_variation
def chained_parameter_variation(subject, durations, y0, varied_params, default_params=None, integrate_kwargs=None, x0=None, npoints=1, numpy=None): """ Integrate an ODE-system for a serie of durations with some parameters changed in-between Parameters ---------- subject ...
python
def chained_parameter_variation(subject, durations, y0, varied_params, default_params=None, integrate_kwargs=None, x0=None, npoints=1, numpy=None): """ Integrate an ODE-system for a serie of durations with some parameters changed in-between Parameters ---------- subject ...
[ "def", "chained_parameter_variation", "(", "subject", ",", "durations", ",", "y0", ",", "varied_params", ",", "default_params", "=", "None", ",", "integrate_kwargs", "=", "None", ",", "x0", "=", "None", ",", "npoints", "=", "1", ",", "numpy", "=", "None", ...
Integrate an ODE-system for a serie of durations with some parameters changed in-between Parameters ---------- subject : function or ODESys instance If a function: should have the signature of :meth:`pyodesys.ODESys.integrate` (and resturn a :class:`pyodesys.results.Result` object). ...
[ "Integrate", "an", "ODE", "-", "system", "for", "a", "serie", "of", "durations", "with", "some", "parameters", "changed", "in", "-", "between" ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L917-L996
bjodah/pyodesys
pyodesys/core.py
ODESys.pre_process
def pre_process(self, xout, y0, params=()): """ Transforms input to internal values, used internally. """ for pre_processor in self.pre_processors: xout, y0, params = pre_processor(xout, y0, params) return [self.numpy.atleast_1d(arr) for arr in (xout, y0, params)]
python
def pre_process(self, xout, y0, params=()): """ Transforms input to internal values, used internally. """ for pre_processor in self.pre_processors: xout, y0, params = pre_processor(xout, y0, params) return [self.numpy.atleast_1d(arr) for arr in (xout, y0, params)]
[ "def", "pre_process", "(", "self", ",", "xout", ",", "y0", ",", "params", "=", "(", ")", ")", ":", "for", "pre_processor", "in", "self", ".", "pre_processors", ":", "xout", ",", "y0", ",", "params", "=", "pre_processor", "(", "xout", ",", "y0", ",", ...
Transforms input to internal values, used internally.
[ "Transforms", "input", "to", "internal", "values", "used", "internally", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L286-L290
bjodah/pyodesys
pyodesys/core.py
ODESys.post_process
def post_process(self, xout, yout, params): """ Transforms internal values to output, used internally. """ for post_processor in self.post_processors: xout, yout, params = post_processor(xout, yout, params) return xout, yout, params
python
def post_process(self, xout, yout, params): """ Transforms internal values to output, used internally. """ for post_processor in self.post_processors: xout, yout, params = post_processor(xout, yout, params) return xout, yout, params
[ "def", "post_process", "(", "self", ",", "xout", ",", "yout", ",", "params", ")", ":", "for", "post_processor", "in", "self", ".", "post_processors", ":", "xout", ",", "yout", ",", "params", "=", "post_processor", "(", "xout", ",", "yout", ",", "params",...
Transforms internal values to output, used internally.
[ "Transforms", "internal", "values", "to", "output", "used", "internally", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L292-L296
bjodah/pyodesys
pyodesys/core.py
ODESys.adaptive
def adaptive(self, y0, x0, xend, params=(), **kwargs): """ Integrate with integrator chosen output. Parameters ---------- integrator : str See :meth:`integrate`. y0 : array_like See :meth:`integrate`. x0 : float Initial value of the in...
python
def adaptive(self, y0, x0, xend, params=(), **kwargs): """ Integrate with integrator chosen output. Parameters ---------- integrator : str See :meth:`integrate`. y0 : array_like See :meth:`integrate`. x0 : float Initial value of the in...
[ "def", "adaptive", "(", "self", ",", "y0", ",", "x0", ",", "xend", ",", "params", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "integrate", "(", "(", "x0", ",", "xend", ")", ",", "y0", ",", "params", "=", "params", ...
Integrate with integrator chosen output. Parameters ---------- integrator : str See :meth:`integrate`. y0 : array_like See :meth:`integrate`. x0 : float Initial value of the independent variable. xend : float Final value of...
[ "Integrate", "with", "integrator", "chosen", "output", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L298-L321
bjodah/pyodesys
pyodesys/core.py
ODESys.predefined
def predefined(self, y0, xout, params=(), **kwargs): """ Integrate with user chosen output. Parameters ---------- integrator : str See :meth:`integrate`. y0 : array_like See :meth:`integrate`. xout : array_like params : array_like ...
python
def predefined(self, y0, xout, params=(), **kwargs): """ Integrate with user chosen output. Parameters ---------- integrator : str See :meth:`integrate`. y0 : array_like See :meth:`integrate`. xout : array_like params : array_like ...
[ "def", "predefined", "(", "self", ",", "y0", ",", "xout", ",", "params", "=", "(", ")", ",", "*", "*", "kwargs", ")", ":", "xout", ",", "yout", ",", "info", "=", "self", ".", "integrate", "(", "xout", ",", "y0", ",", "params", "=", "params", ",...
Integrate with user chosen output. Parameters ---------- integrator : str See :meth:`integrate`. y0 : array_like See :meth:`integrate`. xout : array_like params : array_like See :meth:`integrate`. \*\*kwargs: See :m...
[ "Integrate", "with", "user", "chosen", "output", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L323-L345
bjodah/pyodesys
pyodesys/core.py
ODESys.integrate
def integrate(self, x, y0, params=(), atol=1e-8, rtol=1e-8, **kwargs): """ Integrate the system of ordinary differential equations. Solves the initial value problem (IVP). Parameters ---------- x : array_like or pair (start and final time) or float if float: ...
python
def integrate(self, x, y0, params=(), atol=1e-8, rtol=1e-8, **kwargs): """ Integrate the system of ordinary differential equations. Solves the initial value problem (IVP). Parameters ---------- x : array_like or pair (start and final time) or float if float: ...
[ "def", "integrate", "(", "self", ",", "x", ",", "y0", ",", "params", "=", "(", ")", ",", "atol", "=", "1e-8", ",", "rtol", "=", "1e-8", ",", "*", "*", "kwargs", ")", ":", "arrs", "=", "self", ".", "to_arrays", "(", "x", ",", "y0", ",", "param...
Integrate the system of ordinary differential equations. Solves the initial value problem (IVP). Parameters ---------- x : array_like or pair (start and final time) or float if float: make it a pair: (0, x) if pair or length-2 array: ...
[ "Integrate", "the", "system", "of", "ordinary", "differential", "equations", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L347-L449
bjodah/pyodesys
pyodesys/core.py
ODESys._integrate_scipy
def _integrate_scipy(self, intern_xout, intern_y0, intern_p, atol=1e-8, rtol=1e-8, first_step=None, with_jacobian=None, force_predefined=False, name=None, **kwargs): """ Do not use directly (use ``integrate('scipy', ...)``). Uses `scipy.integrate.ode <h...
python
def _integrate_scipy(self, intern_xout, intern_y0, intern_p, atol=1e-8, rtol=1e-8, first_step=None, with_jacobian=None, force_predefined=False, name=None, **kwargs): """ Do not use directly (use ``integrate('scipy', ...)``). Uses `scipy.integrate.ode <h...
[ "def", "_integrate_scipy", "(", "self", ",", "intern_xout", ",", "intern_y0", ",", "intern_p", ",", "atol", "=", "1e-8", ",", "rtol", "=", "1e-8", ",", "first_step", "=", "None", ",", "with_jacobian", "=", "None", ",", "force_predefined", "=", "False", ","...
Do not use directly (use ``integrate('scipy', ...)``). Uses `scipy.integrate.ode <http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.ode.html>`_ Parameters ---------- \*args : See :meth:`integrate`. name : str (default: 'lsoda'/'dopri5' when jacobia...
[ "Do", "not", "use", "directly", "(", "use", "integrate", "(", "scipy", "...", ")", ")", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L455-L567
bjodah/pyodesys
pyodesys/core.py
ODESys._integrate_gsl
def _integrate_gsl(self, *args, **kwargs): """ Do not use directly (use ``integrate(..., integrator='gsl')``). Uses `GNU Scientific Library <http://www.gnu.org/software/gsl/>`_ (via `pygslodeiv2 <https://pypi.python.org/pypi/pygslodeiv2>`_) to integrate the ODE system. Paramete...
python
def _integrate_gsl(self, *args, **kwargs): """ Do not use directly (use ``integrate(..., integrator='gsl')``). Uses `GNU Scientific Library <http://www.gnu.org/software/gsl/>`_ (via `pygslodeiv2 <https://pypi.python.org/pypi/pygslodeiv2>`_) to integrate the ODE system. Paramete...
[ "def", "_integrate_gsl", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "pygslodeiv2", "# Python interface GSL's \"odeiv2\" integrators", "kwargs", "[", "'with_jacobian'", "]", "=", "kwargs", ".", "get", "(", "'method'", ",", "'bsimp...
Do not use directly (use ``integrate(..., integrator='gsl')``). Uses `GNU Scientific Library <http://www.gnu.org/software/gsl/>`_ (via `pygslodeiv2 <https://pypi.python.org/pypi/pygslodeiv2>`_) to integrate the ODE system. Parameters ---------- \*args : see ...
[ "Do", "not", "use", "directly", "(", "use", "integrate", "(", "...", "integrator", "=", "gsl", ")", ")", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L665-L691
bjodah/pyodesys
pyodesys/core.py
ODESys._integrate_odeint
def _integrate_odeint(self, *args, **kwargs): """ Do not use directly (use ``integrate(..., integrator='odeint')``). Uses `Boost.Numeric.Odeint <http://www.odeint.com>`_ (via `pyodeint <https://pypi.python.org/pypi/pyodeint>`_) to integrate the ODE system. """ import pyo...
python
def _integrate_odeint(self, *args, **kwargs): """ Do not use directly (use ``integrate(..., integrator='odeint')``). Uses `Boost.Numeric.Odeint <http://www.odeint.com>`_ (via `pyodeint <https://pypi.python.org/pypi/pyodeint>`_) to integrate the ODE system. """ import pyo...
[ "def", "_integrate_odeint", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "pyodeint", "# Python interface to boost's odeint integrators", "kwargs", "[", "'with_jacobian'", "]", "=", "kwargs", ".", "get", "(", "'method'", ",", "'rose...
Do not use directly (use ``integrate(..., integrator='odeint')``). Uses `Boost.Numeric.Odeint <http://www.odeint.com>`_ (via `pyodeint <https://pypi.python.org/pypi/pyodeint>`_) to integrate the ODE system.
[ "Do", "not", "use", "directly", "(", "use", "integrate", "(", "...", "integrator", "=", "odeint", ")", ")", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L693-L705
bjodah/pyodesys
pyodesys/core.py
ODESys._integrate_cvode
def _integrate_cvode(self, *args, **kwargs): """ Do not use directly (use ``integrate(..., integrator='cvode')``). Uses CVode from CVodes in `SUNDIALS <https://computation.llnl.gov/casc/sundials/>`_ (via `pycvodes <https://pypi.python.org/pypi/pycvodes>`_) to integrate the ODE s...
python
def _integrate_cvode(self, *args, **kwargs): """ Do not use directly (use ``integrate(..., integrator='cvode')``). Uses CVode from CVodes in `SUNDIALS <https://computation.llnl.gov/casc/sundials/>`_ (via `pycvodes <https://pypi.python.org/pypi/pycvodes>`_) to integrate the ODE s...
[ "def", "_integrate_cvode", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "import", "pycvodes", "# Python interface to SUNDIALS's cvodes integrators", "kwargs", "[", "'with_jacobian'", "]", "=", "kwargs", ".", "get", "(", "'method'", ",", "'bd...
Do not use directly (use ``integrate(..., integrator='cvode')``). Uses CVode from CVodes in `SUNDIALS <https://computation.llnl.gov/casc/sundials/>`_ (via `pycvodes <https://pypi.python.org/pypi/pycvodes>`_) to integrate the ODE system.
[ "Do", "not", "use", "directly", "(", "use", "integrate", "(", "...", "integrator", "=", "cvode", ")", ")", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L707-L725
bjodah/pyodesys
pyodesys/core.py
ODESys.plot_phase_plane
def plot_phase_plane(self, indices=None, **kwargs): """ Plots a phase portrait from last integration. This method will be deprecated. Please use :meth:`Result.plot_phase_plane`. See :func:`pyodesys.plotting.plot_phase_plane` """ return self._plot(plot_phase_plane, indices=indice...
python
def plot_phase_plane(self, indices=None, **kwargs): """ Plots a phase portrait from last integration. This method will be deprecated. Please use :meth:`Result.plot_phase_plane`. See :func:`pyodesys.plotting.plot_phase_plane` """ return self._plot(plot_phase_plane, indices=indice...
[ "def", "plot_phase_plane", "(", "self", ",", "indices", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_plot", "(", "plot_phase_plane", ",", "indices", "=", "indices", ",", "*", "*", "kwargs", ")" ]
Plots a phase portrait from last integration. This method will be deprecated. Please use :meth:`Result.plot_phase_plane`. See :func:`pyodesys.plotting.plot_phase_plane`
[ "Plots", "a", "phase", "portrait", "from", "last", "integration", "." ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L756-L762
bjodah/pyodesys
pyodesys/core.py
ODESys.stiffness
def stiffness(self, xyp=None, eigenvals_cb=None): """ [DEPRECATED] Use :meth:`Result.stiffness`, stiffness ration Running stiffness ratio from last integration. Calculate sittness ratio, i.e. the ratio between the largest and smallest absolute eigenvalue of the jacobian matrix. The user...
python
def stiffness(self, xyp=None, eigenvals_cb=None): """ [DEPRECATED] Use :meth:`Result.stiffness`, stiffness ration Running stiffness ratio from last integration. Calculate sittness ratio, i.e. the ratio between the largest and smallest absolute eigenvalue of the jacobian matrix. The user...
[ "def", "stiffness", "(", "self", ",", "xyp", "=", "None", ",", "eigenvals_cb", "=", "None", ")", ":", "if", "eigenvals_cb", "is", "None", ":", "if", "self", ".", "band", "is", "not", "None", ":", "raise", "NotImplementedError", "eigenvals_cb", "=", "self...
[DEPRECATED] Use :meth:`Result.stiffness`, stiffness ration Running stiffness ratio from last integration. Calculate sittness ratio, i.e. the ratio between the largest and smallest absolute eigenvalue of the jacobian matrix. The user may supply their own routine for calculating the eige...
[ "[", "DEPRECATED", "]", "Use", ":", "meth", ":", "Result", ".", "stiffness", "stiffness", "ration" ]
train
https://github.com/bjodah/pyodesys/blob/0034a6165b550d8d9808baef58678dca5a493ab7/pyodesys/core.py#L769-L805
neon-jungle/wagtailnews
wagtailnews/views/editor.py
build_dummy_request
def build_dummy_request(newsitem): """ Construct a HttpRequest object that is, as far as possible, representative of ones that would receive this page as a response. Used for previewing / moderation and any other place where we want to display a view of this page in the admin interface without going...
python
def build_dummy_request(newsitem): """ Construct a HttpRequest object that is, as far as possible, representative of ones that would receive this page as a response. Used for previewing / moderation and any other place where we want to display a view of this page in the admin interface without going...
[ "def", "build_dummy_request", "(", "newsitem", ")", ":", "url", "=", "newsitem", ".", "full_url", "if", "url", ":", "url_info", "=", "urlparse", "(", "url", ")", "hostname", "=", "url_info", ".", "hostname", "path", "=", "url_info", ".", "path", "port", ...
Construct a HttpRequest object that is, as far as possible, representative of ones that would receive this page as a response. Used for previewing / moderation and any other place where we want to display a view of this page in the admin interface without going through the regular page routing logic.
[ "Construct", "a", "HttpRequest", "object", "that", "is", "as", "far", "as", "possible", "representative", "of", "ones", "that", "would", "receive", "this", "page", "as", "a", "response", ".", "Used", "for", "previewing", "/", "moderation", "and", "any", "oth...
train
https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/views/editor.py#L225-L268
neon-jungle/wagtailnews
wagtailnews/permissions.py
user_can_edit_news
def user_can_edit_news(user): """ Check if the user has permission to edit any of the registered NewsItem types. """ newsitem_models = [model.get_newsitem_model() for model in NEWSINDEX_MODEL_CLASSES] if user.is_active and user.is_superuser: # admin can edit news ...
python
def user_can_edit_news(user): """ Check if the user has permission to edit any of the registered NewsItem types. """ newsitem_models = [model.get_newsitem_model() for model in NEWSINDEX_MODEL_CLASSES] if user.is_active and user.is_superuser: # admin can edit news ...
[ "def", "user_can_edit_news", "(", "user", ")", ":", "newsitem_models", "=", "[", "model", ".", "get_newsitem_model", "(", ")", "for", "model", "in", "NEWSINDEX_MODEL_CLASSES", "]", "if", "user", ".", "is_active", "and", "user", ".", "is_superuser", ":", "# adm...
Check if the user has permission to edit any of the registered NewsItem types.
[ "Check", "if", "the", "user", "has", "permission", "to", "edit", "any", "of", "the", "registered", "NewsItem", "types", "." ]
train
https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/permissions.py#L21-L38
neon-jungle/wagtailnews
wagtailnews/permissions.py
user_can_edit_newsitem
def user_can_edit_newsitem(user, NewsItem): """ Check if the user has permission to edit a particular NewsItem type. """ for perm in format_perms(NewsItem, ['add', 'change', 'delete']): if user.has_perm(perm): return True return False
python
def user_can_edit_newsitem(user, NewsItem): """ Check if the user has permission to edit a particular NewsItem type. """ for perm in format_perms(NewsItem, ['add', 'change', 'delete']): if user.has_perm(perm): return True return False
[ "def", "user_can_edit_newsitem", "(", "user", ",", "NewsItem", ")", ":", "for", "perm", "in", "format_perms", "(", "NewsItem", ",", "[", "'add'", ",", "'change'", ",", "'delete'", "]", ")", ":", "if", "user", ".", "has_perm", "(", "perm", ")", ":", "re...
Check if the user has permission to edit a particular NewsItem type.
[ "Check", "if", "the", "user", "has", "permission", "to", "edit", "a", "particular", "NewsItem", "type", "." ]
train
https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/permissions.py#L41-L49
neon-jungle/wagtailnews
wagtailnews/models.py
get_date_or_404
def get_date_or_404(year, month, day): """Try to make a date from the given inputs, raising Http404 on error""" try: return datetime.date(int(year), int(month), int(day)) except ValueError: raise Http404
python
def get_date_or_404(year, month, day): """Try to make a date from the given inputs, raising Http404 on error""" try: return datetime.date(int(year), int(month), int(day)) except ValueError: raise Http404
[ "def", "get_date_or_404", "(", "year", ",", "month", ",", "day", ")", ":", "try", ":", "return", "datetime", ".", "date", "(", "int", "(", "year", ")", ",", "int", "(", "month", ")", ",", "int", "(", "day", ")", ")", "except", "ValueError", ":", ...
Try to make a date from the given inputs, raising Http404 on error
[ "Try", "to", "make", "a", "date", "from", "the", "given", "inputs", "raising", "Http404", "on", "error" ]
train
https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/models.py#L29-L34
neon-jungle/wagtailnews
wagtailnews/models.py
NewsIndexMixin.respond
def respond(self, request, view, newsitems, extra_context={}): """A helper that takes some news items and returns an HttpResponse""" context = self.get_context(request, view=view) context.update(self.paginate_newsitems(request, newsitems)) context.update(extra_context) template =...
python
def respond(self, request, view, newsitems, extra_context={}): """A helper that takes some news items and returns an HttpResponse""" context = self.get_context(request, view=view) context.update(self.paginate_newsitems(request, newsitems)) context.update(extra_context) template =...
[ "def", "respond", "(", "self", ",", "request", ",", "view", ",", "newsitems", ",", "extra_context", "=", "{", "}", ")", ":", "context", "=", "self", ".", "get_context", "(", "request", ",", "view", "=", "view", ")", "context", ".", "update", "(", "se...
A helper that takes some news items and returns an HttpResponse
[ "A", "helper", "that", "takes", "some", "news", "items", "and", "returns", "an", "HttpResponse" ]
train
https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/models.py#L80-L86
neon-jungle/wagtailnews
wagtailnews/views/chooser.py
get_newsitem_model
def get_newsitem_model(model_string): """ Get the NewsItem model from a model string. Raises ValueError if the model string is invalid, or references a model that is not a NewsItem. """ try: NewsItem = apps.get_model(model_string) assert issubclass(NewsItem, AbstractNewsItem) exc...
python
def get_newsitem_model(model_string): """ Get the NewsItem model from a model string. Raises ValueError if the model string is invalid, or references a model that is not a NewsItem. """ try: NewsItem = apps.get_model(model_string) assert issubclass(NewsItem, AbstractNewsItem) exc...
[ "def", "get_newsitem_model", "(", "model_string", ")", ":", "try", ":", "NewsItem", "=", "apps", ".", "get_model", "(", "model_string", ")", "assert", "issubclass", "(", "NewsItem", ",", "AbstractNewsItem", ")", "except", "(", "ValueError", ",", "LookupError", ...
Get the NewsItem model from a model string. Raises ValueError if the model string is invalid, or references a model that is not a NewsItem.
[ "Get", "the", "NewsItem", "model", "from", "a", "model", "string", ".", "Raises", "ValueError", "if", "the", "model", "string", "is", "invalid", "or", "references", "a", "model", "that", "is", "not", "a", "NewsItem", "." ]
train
https://github.com/neon-jungle/wagtailnews/blob/4cdec7013cca276dcfc658d3c986444ba6a42a84/wagtailnews/views/chooser.py#L119-L129
geometalab/pyGeoTile
pygeotile/point.py
Point.from_latitude_longitude
def from_latitude_longitude(cls, latitude=0.0, longitude=0.0): """Creates a point from lat/lon in WGS84""" assert -180.0 <= longitude <= 180.0, 'Longitude needs to be a value between -180.0 and 180.0.' assert -90.0 <= latitude <= 90.0, 'Latitude needs to be a value between -90.0 and 90.0.' ...
python
def from_latitude_longitude(cls, latitude=0.0, longitude=0.0): """Creates a point from lat/lon in WGS84""" assert -180.0 <= longitude <= 180.0, 'Longitude needs to be a value between -180.0 and 180.0.' assert -90.0 <= latitude <= 90.0, 'Latitude needs to be a value between -90.0 and 90.0.' ...
[ "def", "from_latitude_longitude", "(", "cls", ",", "latitude", "=", "0.0", ",", "longitude", "=", "0.0", ")", ":", "assert", "-", "180.0", "<=", "longitude", "<=", "180.0", ",", "'Longitude needs to be a value between -180.0 and 180.0.'", "assert", "-", "90.0", "<...
Creates a point from lat/lon in WGS84
[ "Creates", "a", "point", "from", "lat", "/", "lon", "in", "WGS84" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/point.py#L12-L16
geometalab/pyGeoTile
pygeotile/point.py
Point.from_pixel
def from_pixel(cls, pixel_x=0, pixel_y=0, zoom=None): """Creates a point from pixels X Y Z (zoom) in pyramid""" max_pixel = (2 ** zoom) * TILE_SIZE assert 0 <= pixel_x <= max_pixel, 'Point X needs to be a value between 0 and (2^zoom) * 256.' assert 0 <= pixel_y <= max_pixel, 'Point Y nee...
python
def from_pixel(cls, pixel_x=0, pixel_y=0, zoom=None): """Creates a point from pixels X Y Z (zoom) in pyramid""" max_pixel = (2 ** zoom) * TILE_SIZE assert 0 <= pixel_x <= max_pixel, 'Point X needs to be a value between 0 and (2^zoom) * 256.' assert 0 <= pixel_y <= max_pixel, 'Point Y nee...
[ "def", "from_pixel", "(", "cls", ",", "pixel_x", "=", "0", ",", "pixel_y", "=", "0", ",", "zoom", "=", "None", ")", ":", "max_pixel", "=", "(", "2", "**", "zoom", ")", "*", "TILE_SIZE", "assert", "0", "<=", "pixel_x", "<=", "max_pixel", ",", "'Poin...
Creates a point from pixels X Y Z (zoom) in pyramid
[ "Creates", "a", "point", "from", "pixels", "X", "Y", "Z", "(", "zoom", ")", "in", "pyramid" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/point.py#L19-L27
geometalab/pyGeoTile
pygeotile/point.py
Point.from_meters
def from_meters(cls, meter_x=0.0, meter_y=0.0): """Creates a point from X Y Z (zoom) meters in Spherical Mercator EPSG:900913""" assert -ORIGIN_SHIFT <= meter_x <= ORIGIN_SHIFT, \ 'Meter X needs to be a value between -{0} and {0}.'.format(ORIGIN_SHIFT) assert -ORIGIN_SHIFT <= meter_y...
python
def from_meters(cls, meter_x=0.0, meter_y=0.0): """Creates a point from X Y Z (zoom) meters in Spherical Mercator EPSG:900913""" assert -ORIGIN_SHIFT <= meter_x <= ORIGIN_SHIFT, \ 'Meter X needs to be a value between -{0} and {0}.'.format(ORIGIN_SHIFT) assert -ORIGIN_SHIFT <= meter_y...
[ "def", "from_meters", "(", "cls", ",", "meter_x", "=", "0.0", ",", "meter_y", "=", "0.0", ")", ":", "assert", "-", "ORIGIN_SHIFT", "<=", "meter_x", "<=", "ORIGIN_SHIFT", ",", "'Meter X needs to be a value between -{0} and {0}.'", ".", "format", "(", "ORIGIN_SHIFT"...
Creates a point from X Y Z (zoom) meters in Spherical Mercator EPSG:900913
[ "Creates", "a", "point", "from", "X", "Y", "Z", "(", "zoom", ")", "meters", "in", "Spherical", "Mercator", "EPSG", ":", "900913" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/point.py#L30-L39
geometalab/pyGeoTile
pygeotile/point.py
Point.pixels
def pixels(self, zoom=None): """Gets pixels of the EPSG:4326 pyramid by a specific zoom, converted from lat/lon in WGS84""" meter_x, meter_y = self.meters pixel_x = (meter_x + ORIGIN_SHIFT) / resolution(zoom=zoom) pixel_y = (meter_y - ORIGIN_SHIFT) / resolution(zoom=zoom) return ...
python
def pixels(self, zoom=None): """Gets pixels of the EPSG:4326 pyramid by a specific zoom, converted from lat/lon in WGS84""" meter_x, meter_y = self.meters pixel_x = (meter_x + ORIGIN_SHIFT) / resolution(zoom=zoom) pixel_y = (meter_y - ORIGIN_SHIFT) / resolution(zoom=zoom) return ...
[ "def", "pixels", "(", "self", ",", "zoom", "=", "None", ")", ":", "meter_x", ",", "meter_y", "=", "self", ".", "meters", "pixel_x", "=", "(", "meter_x", "+", "ORIGIN_SHIFT", ")", "/", "resolution", "(", "zoom", "=", "zoom", ")", "pixel_y", "=", "(", ...
Gets pixels of the EPSG:4326 pyramid by a specific zoom, converted from lat/lon in WGS84
[ "Gets", "pixels", "of", "the", "EPSG", ":", "4326", "pyramid", "by", "a", "specific", "zoom", "converted", "from", "lat", "/", "lon", "in", "WGS84" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/point.py#L46-L51
geometalab/pyGeoTile
pygeotile/point.py
Point.meters
def meters(self): """Gets the XY meters in Spherical Mercator EPSG:900913, converted from lat/lon in WGS84""" latitude, longitude = self.latitude_longitude meter_x = longitude * ORIGIN_SHIFT / 180.0 meter_y = math.log(math.tan((90.0 + latitude) * math.pi / 360.0)) / (math.pi / 180.0) ...
python
def meters(self): """Gets the XY meters in Spherical Mercator EPSG:900913, converted from lat/lon in WGS84""" latitude, longitude = self.latitude_longitude meter_x = longitude * ORIGIN_SHIFT / 180.0 meter_y = math.log(math.tan((90.0 + latitude) * math.pi / 360.0)) / (math.pi / 180.0) ...
[ "def", "meters", "(", "self", ")", ":", "latitude", ",", "longitude", "=", "self", ".", "latitude_longitude", "meter_x", "=", "longitude", "*", "ORIGIN_SHIFT", "/", "180.0", "meter_y", "=", "math", ".", "log", "(", "math", ".", "tan", "(", "(", "90.0", ...
Gets the XY meters in Spherical Mercator EPSG:900913, converted from lat/lon in WGS84
[ "Gets", "the", "XY", "meters", "in", "Spherical", "Mercator", "EPSG", ":", "900913", "converted", "from", "lat", "/", "lon", "in", "WGS84" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/point.py#L54-L60
geometalab/pyGeoTile
pygeotile/tile.py
Tile.from_quad_tree
def from_quad_tree(cls, quad_tree): """Creates a tile from a Microsoft QuadTree""" assert bool(re.match('^[0-3]*$', quad_tree)), 'QuadTree value can only consists of the digits 0, 1, 2 and 3.' zoom = len(str(quad_tree)) offset = int(math.pow(2, zoom)) - 1 google_x, google_y = [re...
python
def from_quad_tree(cls, quad_tree): """Creates a tile from a Microsoft QuadTree""" assert bool(re.match('^[0-3]*$', quad_tree)), 'QuadTree value can only consists of the digits 0, 1, 2 and 3.' zoom = len(str(quad_tree)) offset = int(math.pow(2, zoom)) - 1 google_x, google_y = [re...
[ "def", "from_quad_tree", "(", "cls", ",", "quad_tree", ")", ":", "assert", "bool", "(", "re", ".", "match", "(", "'^[0-3]*$'", ",", "quad_tree", ")", ")", ",", "'QuadTree value can only consists of the digits 0, 1, 2 and 3.'", "zoom", "=", "len", "(", "str", "("...
Creates a tile from a Microsoft QuadTree
[ "Creates", "a", "tile", "from", "a", "Microsoft", "QuadTree" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L16-L24
geometalab/pyGeoTile
pygeotile/tile.py
Tile.from_tms
def from_tms(cls, tms_x, tms_y, zoom): """Creates a tile from Tile Map Service (TMS) X Y and zoom""" max_tile = (2 ** zoom) - 1 assert 0 <= tms_x <= max_tile, 'TMS X needs to be a value between 0 and (2^zoom) -1.' assert 0 <= tms_y <= max_tile, 'TMS Y needs to be a value between 0 and (2...
python
def from_tms(cls, tms_x, tms_y, zoom): """Creates a tile from Tile Map Service (TMS) X Y and zoom""" max_tile = (2 ** zoom) - 1 assert 0 <= tms_x <= max_tile, 'TMS X needs to be a value between 0 and (2^zoom) -1.' assert 0 <= tms_y <= max_tile, 'TMS Y needs to be a value between 0 and (2...
[ "def", "from_tms", "(", "cls", ",", "tms_x", ",", "tms_y", ",", "zoom", ")", ":", "max_tile", "=", "(", "2", "**", "zoom", ")", "-", "1", "assert", "0", "<=", "tms_x", "<=", "max_tile", ",", "'TMS X needs to be a value between 0 and (2^zoom) -1.'", "assert",...
Creates a tile from Tile Map Service (TMS) X Y and zoom
[ "Creates", "a", "tile", "from", "Tile", "Map", "Service", "(", "TMS", ")", "X", "Y", "and", "zoom" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L27-L32
geometalab/pyGeoTile
pygeotile/tile.py
Tile.from_google
def from_google(cls, google_x, google_y, zoom): """Creates a tile from Google format X Y and zoom""" max_tile = (2 ** zoom) - 1 assert 0 <= google_x <= max_tile, 'Google X needs to be a value between 0 and (2^zoom) -1.' assert 0 <= google_y <= max_tile, 'Google Y needs to be a value betw...
python
def from_google(cls, google_x, google_y, zoom): """Creates a tile from Google format X Y and zoom""" max_tile = (2 ** zoom) - 1 assert 0 <= google_x <= max_tile, 'Google X needs to be a value between 0 and (2^zoom) -1.' assert 0 <= google_y <= max_tile, 'Google Y needs to be a value betw...
[ "def", "from_google", "(", "cls", ",", "google_x", ",", "google_y", ",", "zoom", ")", ":", "max_tile", "=", "(", "2", "**", "zoom", ")", "-", "1", "assert", "0", "<=", "google_x", "<=", "max_tile", ",", "'Google X needs to be a value between 0 and (2^zoom) -1....
Creates a tile from Google format X Y and zoom
[ "Creates", "a", "tile", "from", "Google", "format", "X", "Y", "and", "zoom" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L35-L40
geometalab/pyGeoTile
pygeotile/tile.py
Tile.for_point
def for_point(cls, point, zoom): """Creates a tile for given point""" latitude, longitude = point.latitude_longitude return cls.for_latitude_longitude(latitude=latitude, longitude=longitude, zoom=zoom)
python
def for_point(cls, point, zoom): """Creates a tile for given point""" latitude, longitude = point.latitude_longitude return cls.for_latitude_longitude(latitude=latitude, longitude=longitude, zoom=zoom)
[ "def", "for_point", "(", "cls", ",", "point", ",", "zoom", ")", ":", "latitude", ",", "longitude", "=", "point", ".", "latitude_longitude", "return", "cls", ".", "for_latitude_longitude", "(", "latitude", "=", "latitude", ",", "longitude", "=", "longitude", ...
Creates a tile for given point
[ "Creates", "a", "tile", "for", "given", "point" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L43-L46
geometalab/pyGeoTile
pygeotile/tile.py
Tile.for_pixels
def for_pixels(cls, pixel_x, pixel_y, zoom): """Creates a tile from pixels X Y Z (zoom) in pyramid""" tms_x = int(math.ceil(pixel_x / float(TILE_SIZE)) - 1) tms_y = int(math.ceil(pixel_y / float(TILE_SIZE)) - 1) return cls(tms_x=tms_x, tms_y=(2 ** zoom - 1) - tms_y, zoom=zoom)
python
def for_pixels(cls, pixel_x, pixel_y, zoom): """Creates a tile from pixels X Y Z (zoom) in pyramid""" tms_x = int(math.ceil(pixel_x / float(TILE_SIZE)) - 1) tms_y = int(math.ceil(pixel_y / float(TILE_SIZE)) - 1) return cls(tms_x=tms_x, tms_y=(2 ** zoom - 1) - tms_y, zoom=zoom)
[ "def", "for_pixels", "(", "cls", ",", "pixel_x", ",", "pixel_y", ",", "zoom", ")", ":", "tms_x", "=", "int", "(", "math", ".", "ceil", "(", "pixel_x", "/", "float", "(", "TILE_SIZE", ")", ")", "-", "1", ")", "tms_y", "=", "int", "(", "math", ".",...
Creates a tile from pixels X Y Z (zoom) in pyramid
[ "Creates", "a", "tile", "from", "pixels", "X", "Y", "Z", "(", "zoom", ")", "in", "pyramid" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L49-L53
geometalab/pyGeoTile
pygeotile/tile.py
Tile.for_meters
def for_meters(cls, meter_x, meter_y, zoom): """Creates a tile from X Y meters in Spherical Mercator EPSG:900913""" point = Point.from_meters(meter_x=meter_x, meter_y=meter_y) pixel_x, pixel_y = point.pixels(zoom=zoom) return cls.for_pixels(pixel_x=pixel_x, pixel_y=pixel_y, zoom=zoom)
python
def for_meters(cls, meter_x, meter_y, zoom): """Creates a tile from X Y meters in Spherical Mercator EPSG:900913""" point = Point.from_meters(meter_x=meter_x, meter_y=meter_y) pixel_x, pixel_y = point.pixels(zoom=zoom) return cls.for_pixels(pixel_x=pixel_x, pixel_y=pixel_y, zoom=zoom)
[ "def", "for_meters", "(", "cls", ",", "meter_x", ",", "meter_y", ",", "zoom", ")", ":", "point", "=", "Point", ".", "from_meters", "(", "meter_x", "=", "meter_x", ",", "meter_y", "=", "meter_y", ")", "pixel_x", ",", "pixel_y", "=", "point", ".", "pixel...
Creates a tile from X Y meters in Spherical Mercator EPSG:900913
[ "Creates", "a", "tile", "from", "X", "Y", "meters", "in", "Spherical", "Mercator", "EPSG", ":", "900913" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L56-L60
geometalab/pyGeoTile
pygeotile/tile.py
Tile.for_latitude_longitude
def for_latitude_longitude(cls, latitude, longitude, zoom): """Creates a tile from lat/lon in WGS84""" point = Point.from_latitude_longitude(latitude=latitude, longitude=longitude) pixel_x, pixel_y = point.pixels(zoom=zoom) return cls.for_pixels(pixel_x=pixel_x, pixel_y=pixel_y, zoom=zoo...
python
def for_latitude_longitude(cls, latitude, longitude, zoom): """Creates a tile from lat/lon in WGS84""" point = Point.from_latitude_longitude(latitude=latitude, longitude=longitude) pixel_x, pixel_y = point.pixels(zoom=zoom) return cls.for_pixels(pixel_x=pixel_x, pixel_y=pixel_y, zoom=zoo...
[ "def", "for_latitude_longitude", "(", "cls", ",", "latitude", ",", "longitude", ",", "zoom", ")", ":", "point", "=", "Point", ".", "from_latitude_longitude", "(", "latitude", "=", "latitude", ",", "longitude", "=", "longitude", ")", "pixel_x", ",", "pixel_y", ...
Creates a tile from lat/lon in WGS84
[ "Creates", "a", "tile", "from", "lat", "/", "lon", "in", "WGS84" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L63-L67
geometalab/pyGeoTile
pygeotile/tile.py
Tile.quad_tree
def quad_tree(self): """Gets the tile in the Microsoft QuadTree format, converted from TMS""" value = '' tms_x, tms_y = self.tms tms_y = (2 ** self.zoom - 1) - tms_y for i in range(self.zoom, 0, -1): digit = 0 mask = 1 << (i - 1) if (tms_x & ma...
python
def quad_tree(self): """Gets the tile in the Microsoft QuadTree format, converted from TMS""" value = '' tms_x, tms_y = self.tms tms_y = (2 ** self.zoom - 1) - tms_y for i in range(self.zoom, 0, -1): digit = 0 mask = 1 << (i - 1) if (tms_x & ma...
[ "def", "quad_tree", "(", "self", ")", ":", "value", "=", "''", "tms_x", ",", "tms_y", "=", "self", ".", "tms", "tms_y", "=", "(", "2", "**", "self", ".", "zoom", "-", "1", ")", "-", "tms_y", "for", "i", "in", "range", "(", "self", ".", "zoom", ...
Gets the tile in the Microsoft QuadTree format, converted from TMS
[ "Gets", "the", "tile", "in", "the", "Microsoft", "QuadTree", "format", "converted", "from", "TMS" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L75-L88
geometalab/pyGeoTile
pygeotile/tile.py
Tile.google
def google(self): """Gets the tile in the Google format, converted from TMS""" tms_x, tms_y = self.tms return tms_x, (2 ** self.zoom - 1) - tms_y
python
def google(self): """Gets the tile in the Google format, converted from TMS""" tms_x, tms_y = self.tms return tms_x, (2 ** self.zoom - 1) - tms_y
[ "def", "google", "(", "self", ")", ":", "tms_x", ",", "tms_y", "=", "self", ".", "tms", "return", "tms_x", ",", "(", "2", "**", "self", ".", "zoom", "-", "1", ")", "-", "tms_y" ]
Gets the tile in the Google format, converted from TMS
[ "Gets", "the", "tile", "in", "the", "Google", "format", "converted", "from", "TMS" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L91-L94
geometalab/pyGeoTile
pygeotile/tile.py
Tile.bounds
def bounds(self): """Gets the bounds of a tile represented as the most west and south point and the most east and north point""" google_x, google_y = self.google pixel_x_west, pixel_y_north = google_x * TILE_SIZE, google_y * TILE_SIZE pixel_x_east, pixel_y_south = (google_x + 1) * TILE_S...
python
def bounds(self): """Gets the bounds of a tile represented as the most west and south point and the most east and north point""" google_x, google_y = self.google pixel_x_west, pixel_y_north = google_x * TILE_SIZE, google_y * TILE_SIZE pixel_x_east, pixel_y_south = (google_x + 1) * TILE_S...
[ "def", "bounds", "(", "self", ")", ":", "google_x", ",", "google_y", "=", "self", ".", "google", "pixel_x_west", ",", "pixel_y_north", "=", "google_x", "*", "TILE_SIZE", ",", "google_y", "*", "TILE_SIZE", "pixel_x_east", ",", "pixel_y_south", "=", "(", "goog...
Gets the bounds of a tile represented as the most west and south point and the most east and north point
[ "Gets", "the", "bounds", "of", "a", "tile", "represented", "as", "the", "most", "west", "and", "south", "point", "and", "the", "most", "east", "and", "north", "point" ]
train
https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L97-L105
david-cortes/costsensitive
costsensitive/__init__.py
WeightedAllPairs.fit
def fit(self, X, C): """ Fit one classifier comparing each pair of classes Parameters ---------- X : array (n_samples, n_features) The data on which to fit a cost-sensitive classifier. C : array (n_samples, n_classes) The cost of predictin...
python
def fit(self, X, C): """ Fit one classifier comparing each pair of classes Parameters ---------- X : array (n_samples, n_features) The data on which to fit a cost-sensitive classifier. C : array (n_samples, n_classes) The cost of predictin...
[ "def", "fit", "(", "self", ",", "X", ",", "C", ")", ":", "X", ",", "C", "=", "_check_fit_input", "(", "X", ",", "C", ")", "self", ".", "nclasses", "=", "C", ".", "shape", "[", "1", "]", "ncombs", "=", "int", "(", "self", ".", "nclasses", "*",...
Fit one classifier comparing each pair of classes Parameters ---------- X : array (n_samples, n_features) The data on which to fit a cost-sensitive classifier. C : array (n_samples, n_classes) The cost of predicting each label for each observation (more m...
[ "Fit", "one", "classifier", "comparing", "each", "pair", "of", "classes", "Parameters", "----------", "X", ":", "array", "(", "n_samples", "n_features", ")", "The", "data", "on", "which", "to", "fit", "a", "cost", "-", "sensitive", "classifier", ".", "C", ...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L98-L123
david-cortes/costsensitive
costsensitive/__init__.py
WeightedAllPairs.decision_function
def decision_function(self, X, method='most-wins'): """ Calculate a 'goodness' distribution over labels Note ---- Predictions can be calculated either by counting which class wins the most pairwise comparisons (as in [1] and [2]), or - for classifiers with a 'pre...
python
def decision_function(self, X, method='most-wins'): """ Calculate a 'goodness' distribution over labels Note ---- Predictions can be calculated either by counting which class wins the most pairwise comparisons (as in [1] and [2]), or - for classifiers with a 'pre...
[ "def", "decision_function", "(", "self", ",", "X", ",", "method", "=", "'most-wins'", ")", ":", "X", "=", "_check_2d_inp", "(", "X", ",", "reshape", "=", "True", ")", "if", "method", "==", "'most-wins'", ":", "return", "self", ".", "_decision_function_winn...
Calculate a 'goodness' distribution over labels Note ---- Predictions can be calculated either by counting which class wins the most pairwise comparisons (as in [1] and [2]), or - for classifiers with a 'predict_proba' method - by taking into account also the margins of ...
[ "Calculate", "a", "goodness", "distribution", "over", "labels", "Note", "----", "Predictions", "can", "be", "calculated", "either", "by", "counting", "which", "class", "wins", "the", "most", "pairwise", "comparisons", "(", "as", "in", "[", "1", "]", "and", "...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L137-L184
david-cortes/costsensitive
costsensitive/__init__.py
WeightedAllPairs.predict
def predict(self, X, method = 'most-wins'): """ Predict the less costly class for a given observation Note ---- Predictions can be calculated either by counting which class wins the most pairwise comparisons (as in [1] and [2]), or - for classifiers with a 'predi...
python
def predict(self, X, method = 'most-wins'): """ Predict the less costly class for a given observation Note ---- Predictions can be calculated either by counting which class wins the most pairwise comparisons (as in [1] and [2]), or - for classifiers with a 'predi...
[ "def", "predict", "(", "self", ",", "X", ",", "method", "=", "'most-wins'", ")", ":", "X", "=", "_check_2d_inp", "(", "X", ",", "reshape", "=", "True", ")", "if", "method", "==", "'most-wins'", ":", "return", "self", ".", "_predict_winners", "(", "X", ...
Predict the less costly class for a given observation Note ---- Predictions can be calculated either by counting which class wins the most pairwise comparisons (as in [1] and [2]), or - for classifiers with a 'predict_proba' method - by taking into account also the margi...
[ "Predict", "the", "less", "costly", "class", "for", "a", "given", "observation", "Note", "----", "Predictions", "can", "be", "calculated", "either", "by", "counting", "which", "class", "wins", "the", "most", "pairwise", "comparisons", "(", "as", "in", "[", "...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L186-L228
david-cortes/costsensitive
costsensitive/__init__.py
FilterTree.fit
def fit(self, X, C): """ Fit a filter tree classifier Note ---- Shifting the order of the classes within the cost array will produce different results, as it will build a different binary tree comparing different classes at each node. Par...
python
def fit(self, X, C): """ Fit a filter tree classifier Note ---- Shifting the order of the classes within the cost array will produce different results, as it will build a different binary tree comparing different classes at each node. Par...
[ "def", "fit", "(", "self", ",", "X", ",", "C", ")", ":", "X", ",", "C", "=", "_check_fit_input", "(", "X", ",", "C", ")", "C", "=", "np", ".", "asfortranarray", "(", "C", ")", "nclasses", "=", "C", ".", "shape", "[", "1", "]", "self", ".", ...
Fit a filter tree classifier Note ---- Shifting the order of the classes within the cost array will produce different results, as it will build a different binary tree comparing different classes at each node. Parameters ---------- X : ar...
[ "Fit", "a", "filter", "tree", "classifier", "Note", "----", "Shifting", "the", "order", "of", "the", "classes", "within", "the", "cost", "array", "will", "produce", "different", "results", "as", "it", "will", "build", "a", "different", "binary", "tree", "com...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L387-L462
david-cortes/costsensitive
costsensitive/__init__.py
FilterTree.predict
def predict(self, X): """ Predict the less costly class for a given observation Note ---- The implementation here happens in a Python loop rather than in some NumPy array operations, thus it will be slower than the other algorithms here, even though in th...
python
def predict(self, X): """ Predict the less costly class for a given observation Note ---- The implementation here happens in a Python loop rather than in some NumPy array operations, thus it will be slower than the other algorithms here, even though in th...
[ "def", "predict", "(", "self", ",", "X", ")", ":", "X", "=", "_check_2d_inp", "(", "X", ",", "reshape", "=", "True", ")", "if", "X", ".", "shape", "[", "0", "]", "==", "1", ":", "return", "self", ".", "_predict", "(", "X", ")", "else", ":", "...
Predict the less costly class for a given observation Note ---- The implementation here happens in a Python loop rather than in some NumPy array operations, thus it will be slower than the other algorithms here, even though in theory it implies fewer comparisons. ...
[ "Predict", "the", "less", "costly", "class", "for", "a", "given", "observation", "Note", "----", "The", "implementation", "here", "happens", "in", "a", "Python", "loop", "rather", "than", "in", "some", "NumPy", "array", "operations", "thus", "it", "will", "b...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L464-L494
david-cortes/costsensitive
costsensitive/__init__.py
CostProportionateClassifier.fit
def fit(self, X, y, sample_weight=None): """ Fit a binary classifier with sample weights to data. Note ---- Examples at each sample are accepted with probability = weight/Z, where Z = max(weight) + extra_rej_const. Larger values for extra_rej_const ensure...
python
def fit(self, X, y, sample_weight=None): """ Fit a binary classifier with sample weights to data. Note ---- Examples at each sample are accepted with probability = weight/Z, where Z = max(weight) + extra_rej_const. Larger values for extra_rej_const ensure...
[ "def", "fit", "(", "self", ",", "X", ",", "y", ",", "sample_weight", "=", "None", ")", ":", "assert", "self", ".", "extra_rej_const", ">=", "0", "if", "sample_weight", "is", "None", ":", "sample_weight", "=", "np", ".", "ones", "(", "y", ".", "shape"...
Fit a binary classifier with sample weights to data. Note ---- Examples at each sample are accepted with probability = weight/Z, where Z = max(weight) + extra_rej_const. Larger values for extra_rej_const ensure that no example gets selected in every single sample...
[ "Fit", "a", "binary", "classifier", "with", "sample", "weights", "to", "data", ".", "Note", "----", "Examples", "at", "each", "sample", "are", "accepted", "with", "probability", "=", "weight", "/", "Z", "where", "Z", "=", "max", "(", "weight", ")", "+", ...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L551-L588
david-cortes/costsensitive
costsensitive/__init__.py
CostProportionateClassifier.decision_function
def decision_function(self, X, aggregation = 'raw'): """ Calculate how preferred is positive class according to classifiers Note ---- If passing aggregation = 'raw', it will output the proportion of the classifiers that voted for the positive class. If pa...
python
def decision_function(self, X, aggregation = 'raw'): """ Calculate how preferred is positive class according to classifiers Note ---- If passing aggregation = 'raw', it will output the proportion of the classifiers that voted for the positive class. If pa...
[ "def", "decision_function", "(", "self", ",", "X", ",", "aggregation", "=", "'raw'", ")", ":", "if", "aggregation", "==", "'weighted'", ":", "if", "'predict_proba'", "not", "in", "dir", "(", "self", ".", "classifiers", "[", "0", "]", ")", ":", "raise", ...
Calculate how preferred is positive class according to classifiers Note ---- If passing aggregation = 'raw', it will output the proportion of the classifiers that voted for the positive class. If passing aggregation = 'weighted', it will output the average predicted prob...
[ "Calculate", "how", "preferred", "is", "positive", "class", "according", "to", "classifiers", "Note", "----", "If", "passing", "aggregation", "=", "raw", "it", "will", "output", "the", "proportion", "of", "the", "classifiers", "that", "voted", "for", "the", "p...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L594-L631
david-cortes/costsensitive
costsensitive/__init__.py
WeightedOneVsRest.fit
def fit(self, X, C): """ Fit one weighted classifier per class Parameters ---------- X : array (n_samples, n_features) The data on which to fit a cost-sensitive classifier. C : array (n_samples, n_classes) The cost of predicting each label...
python
def fit(self, X, C): """ Fit one weighted classifier per class Parameters ---------- X : array (n_samples, n_features) The data on which to fit a cost-sensitive classifier. C : array (n_samples, n_classes) The cost of predicting each label...
[ "def", "fit", "(", "self", ",", "X", ",", "C", ")", ":", "X", ",", "C", "=", "_check_fit_input", "(", "X", ",", "C", ")", "C", "=", "np", ".", "asfortranarray", "(", "C", ")", "self", ".", "nclasses", "=", "C", ".", "shape", "[", "1", "]", ...
Fit one weighted classifier per class Parameters ---------- X : array (n_samples, n_features) The data on which to fit a cost-sensitive classifier. C : array (n_samples, n_classes) The cost of predicting each label for each observation (more means worse).
[ "Fit", "one", "weighted", "classifier", "per", "class", "Parameters", "----------", "X", ":", "array", "(", "n_samples", "n_features", ")", "The", "data", "on", "which", "to", "fit", "a", "cost", "-", "sensitive", "classifier", ".", "C", ":", "array", "(",...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L722-L741
david-cortes/costsensitive
costsensitive/__init__.py
WeightedOneVsRest.decision_function
def decision_function(self, X): """ Calculate a 'goodness' distribution over labels Parameters ---------- X : array (n_samples, n_features) Data for which to predict the cost of each label. Returns ------- pred : array (n_samp...
python
def decision_function(self, X): """ Calculate a 'goodness' distribution over labels Parameters ---------- X : array (n_samples, n_features) Data for which to predict the cost of each label. Returns ------- pred : array (n_samp...
[ "def", "decision_function", "(", "self", ",", "X", ")", ":", "X", "=", "_check_2d_inp", "(", "X", ")", "preds", "=", "np", ".", "empty", "(", "(", "X", ".", "shape", "[", "0", "]", ",", "self", ".", "nclasses", ")", ")", "available_methods", "=", ...
Calculate a 'goodness' distribution over labels Parameters ---------- X : array (n_samples, n_features) Data for which to predict the cost of each label. Returns ------- pred : array (n_samples, n_classes) A goodness score (more i...
[ "Calculate", "a", "goodness", "distribution", "over", "labels", "Parameters", "----------", "X", ":", "array", "(", "n_samples", "n_features", ")", "Data", "for", "which", "to", "predict", "the", "cost", "of", "each", "label", ".", "Returns", "-------", "pred"...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L757-L791
david-cortes/costsensitive
costsensitive/__init__.py
WeightedOneVsRest.predict
def predict(self, X): """ Predict the less costly class for a given observation Parameters ---------- X : array (n_samples, n_features) Data for which to predict minimum cost label. Returns ------- y_hat : array (n_samples,) ...
python
def predict(self, X): """ Predict the less costly class for a given observation Parameters ---------- X : array (n_samples, n_features) Data for which to predict minimum cost label. Returns ------- y_hat : array (n_samples,) ...
[ "def", "predict", "(", "self", ",", "X", ")", ":", "X", "=", "_check_2d_inp", "(", "X", ")", "return", "np", ".", "argmax", "(", "self", ".", "decision_function", "(", "X", ")", ",", "axis", "=", "1", ")" ]
Predict the less costly class for a given observation Parameters ---------- X : array (n_samples, n_features) Data for which to predict minimum cost label. Returns ------- y_hat : array (n_samples,) Label with expected minimum cos...
[ "Predict", "the", "less", "costly", "class", "for", "a", "given", "observation", "Parameters", "----------", "X", ":", "array", "(", "n_samples", "n_features", ")", "Data", "for", "which", "to", "predict", "minimum", "cost", "label", ".", "Returns", "-------",...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L802-L817
david-cortes/costsensitive
costsensitive/__init__.py
RegressionOneVsRest.fit
def fit(self, X, C): """ Fit one regressor per class Parameters ---------- X : array (n_samples, n_features) The data on which to fit a cost-sensitive classifier. C : array (n_samples, n_classes) The cost of predicting each label for each ...
python
def fit(self, X, C): """ Fit one regressor per class Parameters ---------- X : array (n_samples, n_features) The data on which to fit a cost-sensitive classifier. C : array (n_samples, n_classes) The cost of predicting each label for each ...
[ "def", "fit", "(", "self", ",", "X", ",", "C", ")", ":", "X", ",", "C", "=", "_check_fit_input", "(", "X", ",", "C", ")", "C", "=", "np", ".", "asfortranarray", "(", "C", ")", "self", ".", "nclasses", "=", "C", ".", "shape", "[", "1", "]", ...
Fit one regressor per class Parameters ---------- X : array (n_samples, n_features) The data on which to fit a cost-sensitive classifier. C : array (n_samples, n_classes) The cost of predicting each label for each observation (more means worse).
[ "Fit", "one", "regressor", "per", "class", "Parameters", "----------", "X", ":", "array", "(", "n_samples", "n_features", ")", "The", "data", "on", "which", "to", "fit", "a", "cost", "-", "sensitive", "classifier", ".", "C", ":", "array", "(", "n_samples",...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L854-L870
david-cortes/costsensitive
costsensitive/__init__.py
RegressionOneVsRest.decision_function
def decision_function(self, X, apply_softmax = True): """ Get cost estimates for each observation Note ---- If called with apply_softmax = False, this will output the predicted COST rather than the 'goodness' - meaning, more is worse. If called w...
python
def decision_function(self, X, apply_softmax = True): """ Get cost estimates for each observation Note ---- If called with apply_softmax = False, this will output the predicted COST rather than the 'goodness' - meaning, more is worse. If called w...
[ "def", "decision_function", "(", "self", ",", "X", ",", "apply_softmax", "=", "True", ")", ":", "X", "=", "_check_2d_inp", "(", "X", ",", "reshape", "=", "True", ")", "preds", "=", "np", ".", "empty", "(", "(", "X", ".", "shape", "[", "0", "]", "...
Get cost estimates for each observation Note ---- If called with apply_softmax = False, this will output the predicted COST rather than the 'goodness' - meaning, more is worse. If called with apply_softmax = True, it will output one minus the softmax on the cost...
[ "Get", "cost", "estimates", "for", "each", "observation", "Note", "----", "If", "called", "with", "apply_softmax", "=", "False", "this", "will", "output", "the", "predicted", "COST", "rather", "than", "the", "goodness", "-", "meaning", "more", "is", "worse", ...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L875-L910
david-cortes/costsensitive
costsensitive/__init__.py
RegressionOneVsRest.predict
def predict(self, X): """ Predict the less costly class for a given observation Parameters ---------- X : array (n_samples, n_features) Data for which to predict minimum cost labels. Returns ------- y_hat : array (n_samples,) ...
python
def predict(self, X): """ Predict the less costly class for a given observation Parameters ---------- X : array (n_samples, n_features) Data for which to predict minimum cost labels. Returns ------- y_hat : array (n_samples,) ...
[ "def", "predict", "(", "self", ",", "X", ")", ":", "X", "=", "_check_2d_inp", "(", "X", ")", "return", "np", ".", "argmin", "(", "self", ".", "decision_function", "(", "X", ",", "False", ")", ",", "axis", "=", "1", ")" ]
Predict the less costly class for a given observation Parameters ---------- X : array (n_samples, n_features) Data for which to predict minimum cost labels. Returns ------- y_hat : array (n_samples,) Label with expected minimum co...
[ "Predict", "the", "less", "costly", "class", "for", "a", "given", "observation", "Parameters", "----------", "X", ":", "array", "(", "n_samples", "n_features", ")", "Data", "for", "which", "to", "predict", "minimum", "cost", "labels", ".", "Returns", "-------"...
train
https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L915-L930
IAMconsortium/pyam
pyam/read_ixmp.py
read_ix
def read_ix(ix, **kwargs): """Read timeseries data from an ixmp object Parameters ---------- ix: ixmp.TimeSeries or ixmp.Scenario this option requires the ixmp package as a dependency kwargs: arguments passed to ixmp.TimeSeries.timeseries() """ if not isinstance(ix, ixmp.TimeSeries)...
python
def read_ix(ix, **kwargs): """Read timeseries data from an ixmp object Parameters ---------- ix: ixmp.TimeSeries or ixmp.Scenario this option requires the ixmp package as a dependency kwargs: arguments passed to ixmp.TimeSeries.timeseries() """ if not isinstance(ix, ixmp.TimeSeries)...
[ "def", "read_ix", "(", "ix", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "ix", ",", "ixmp", ".", "TimeSeries", ")", ":", "error", "=", "'not recognized as valid ixmp class: {}'", ".", "format", "(", "ix", ")", "raise", "ValueError", ...
Read timeseries data from an ixmp object Parameters ---------- ix: ixmp.TimeSeries or ixmp.Scenario this option requires the ixmp package as a dependency kwargs: arguments passed to ixmp.TimeSeries.timeseries()
[ "Read", "timeseries", "data", "from", "an", "ixmp", "object" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/read_ixmp.py#L8-L24
IAMconsortium/pyam
pyam/utils.py
requires_package
def requires_package(pkg, msg, error_type=ImportError): """Decorator when a function requires an optional dependency Parameters ---------- pkg : imported package object msg : string Message to show to user with error_type error_type : python error class """ def _requires_package...
python
def requires_package(pkg, msg, error_type=ImportError): """Decorator when a function requires an optional dependency Parameters ---------- pkg : imported package object msg : string Message to show to user with error_type error_type : python error class """ def _requires_package...
[ "def", "requires_package", "(", "pkg", ",", "msg", ",", "error_type", "=", "ImportError", ")", ":", "def", "_requires_package", "(", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "pkg", "is", "None", "...
Decorator when a function requires an optional dependency Parameters ---------- pkg : imported package object msg : string Message to show to user with error_type error_type : python error class
[ "Decorator", "when", "a", "function", "requires", "an", "optional", "dependency" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L36-L52
IAMconsortium/pyam
pyam/utils.py
write_sheet
def write_sheet(writer, name, df, index=False): """Write a pandas DataFrame to an ExcelWriter, auto-formatting column width depending on maxwidth of data and colum header Parameters ---------- writer: pandas.ExcelWriter an instance of a pandas ExcelWriter name: string name of th...
python
def write_sheet(writer, name, df, index=False): """Write a pandas DataFrame to an ExcelWriter, auto-formatting column width depending on maxwidth of data and colum header Parameters ---------- writer: pandas.ExcelWriter an instance of a pandas ExcelWriter name: string name of th...
[ "def", "write_sheet", "(", "writer", ",", "name", ",", "df", ",", "index", "=", "False", ")", ":", "if", "index", ":", "df", "=", "df", ".", "reset_index", "(", ")", "df", ".", "to_excel", "(", "writer", ",", "name", ",", "index", "=", "False", "...
Write a pandas DataFrame to an ExcelWriter, auto-formatting column width depending on maxwidth of data and colum header Parameters ---------- writer: pandas.ExcelWriter an instance of a pandas ExcelWriter name: string name of the sheet to be written df: pandas.DataFrame ...
[ "Write", "a", "pandas", "DataFrame", "to", "an", "ExcelWriter", "auto", "-", "formatting", "column", "width", "depending", "on", "maxwidth", "of", "data", "and", "colum", "header" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L70-L96
IAMconsortium/pyam
pyam/utils.py
read_pandas
def read_pandas(fname, *args, **kwargs): """Read a file and return a pd.DataFrame""" if not os.path.exists(fname): raise ValueError('no data file `{}` found!'.format(fname)) if fname.endswith('csv'): df = pd.read_csv(fname, *args, **kwargs) else: xl = pd.ExcelFile(fname) ...
python
def read_pandas(fname, *args, **kwargs): """Read a file and return a pd.DataFrame""" if not os.path.exists(fname): raise ValueError('no data file `{}` found!'.format(fname)) if fname.endswith('csv'): df = pd.read_csv(fname, *args, **kwargs) else: xl = pd.ExcelFile(fname) ...
[ "def", "read_pandas", "(", "fname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "fname", ")", ":", "raise", "ValueError", "(", "'no data file `{}` found!'", ".", "format", "(", "fname", ")", ...
Read a file and return a pd.DataFrame
[ "Read", "a", "file", "and", "return", "a", "pd", ".", "DataFrame" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L99-L110
IAMconsortium/pyam
pyam/utils.py
read_file
def read_file(fname, *args, **kwargs): """Read data from a file saved in the standard IAMC format or a table with year/value columns """ if not isstr(fname): raise ValueError('reading multiple files not supported, ' 'please use `pyam.IamDataFrame.append()`') logger()...
python
def read_file(fname, *args, **kwargs): """Read data from a file saved in the standard IAMC format or a table with year/value columns """ if not isstr(fname): raise ValueError('reading multiple files not supported, ' 'please use `pyam.IamDataFrame.append()`') logger()...
[ "def", "read_file", "(", "fname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isstr", "(", "fname", ")", ":", "raise", "ValueError", "(", "'reading multiple files not supported, '", "'please use `pyam.IamDataFrame.append()`'", ")", "logger",...
Read data from a file saved in the standard IAMC format or a table with year/value columns
[ "Read", "data", "from", "a", "file", "saved", "in", "the", "standard", "IAMC", "format", "or", "a", "table", "with", "year", "/", "value", "columns" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L113-L125
IAMconsortium/pyam
pyam/utils.py
format_data
def format_data(df, **kwargs): """Convert a `pd.Dataframe` or `pd.Series` to the required format""" if isinstance(df, pd.Series): df = df.to_frame() # Check for R-style year columns, converting where necessary def convert_r_columns(c): try: first = c[0] second = ...
python
def format_data(df, **kwargs): """Convert a `pd.Dataframe` or `pd.Series` to the required format""" if isinstance(df, pd.Series): df = df.to_frame() # Check for R-style year columns, converting where necessary def convert_r_columns(c): try: first = c[0] second = ...
[ "def", "format_data", "(", "df", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "df", ",", "pd", ".", "Series", ")", ":", "df", "=", "df", ".", "to_frame", "(", ")", "# Check for R-style year columns, converting where necessary", "def", "convert...
Convert a `pd.Dataframe` or `pd.Series` to the required format
[ "Convert", "a", "pd", ".", "Dataframe", "or", "pd", ".", "Series", "to", "the", "required", "format" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L128-L255
IAMconsortium/pyam
pyam/utils.py
sort_data
def sort_data(data, cols): """Sort `data` rows and order columns""" return data.sort_values(cols)[cols + ['value']].reset_index(drop=True)
python
def sort_data(data, cols): """Sort `data` rows and order columns""" return data.sort_values(cols)[cols + ['value']].reset_index(drop=True)
[ "def", "sort_data", "(", "data", ",", "cols", ")", ":", "return", "data", ".", "sort_values", "(", "cols", ")", "[", "cols", "+", "[", "'value'", "]", "]", ".", "reset_index", "(", "drop", "=", "True", ")" ]
Sort `data` rows and order columns
[ "Sort", "data", "rows", "and", "order", "columns" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L258-L260
IAMconsortium/pyam
pyam/utils.py
find_depth
def find_depth(data, s='', level=None): """ return or assert the depth (number of `|`) of variables Parameters ---------- data : pd.Series of strings IAMC-style variables s : str, default '' remove leading `s` from any variable in `data` level : int or str, default None ...
python
def find_depth(data, s='', level=None): """ return or assert the depth (number of `|`) of variables Parameters ---------- data : pd.Series of strings IAMC-style variables s : str, default '' remove leading `s` from any variable in `data` level : int or str, default None ...
[ "def", "find_depth", "(", "data", ",", "s", "=", "''", ",", "level", "=", "None", ")", ":", "# remove wildcard as last character from string, escape regex characters", "_s", "=", "re", ".", "compile", "(", "'^'", "+", "_escape_regexp", "(", "s", ".", "rstrip", ...
return or assert the depth (number of `|`) of variables Parameters ---------- data : pd.Series of strings IAMC-style variables s : str, default '' remove leading `s` from any variable in `data` level : int or str, default None if None, return depth (number of `|`); else, ret...
[ "return", "or", "assert", "the", "depth", "(", "number", "of", "|", ")", "of", "variables" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L263-L304
IAMconsortium/pyam
pyam/utils.py
pattern_match
def pattern_match(data, values, level=None, regexp=False, has_nan=True): """ matching of model/scenario names, variables, regions, and meta columns to pseudo-regex (if `regexp == False`) for filtering (str, int, bool) """ matches = np.array([False] * len(data)) if not isinstance(values, collecti...
python
def pattern_match(data, values, level=None, regexp=False, has_nan=True): """ matching of model/scenario names, variables, regions, and meta columns to pseudo-regex (if `regexp == False`) for filtering (str, int, bool) """ matches = np.array([False] * len(data)) if not isinstance(values, collecti...
[ "def", "pattern_match", "(", "data", ",", "values", ",", "level", "=", "None", ",", "regexp", "=", "False", ",", "has_nan", "=", "True", ")", ":", "matches", "=", "np", ".", "array", "(", "[", "False", "]", "*", "len", "(", "data", ")", ")", "if"...
matching of model/scenario names, variables, regions, and meta columns to pseudo-regex (if `regexp == False`) for filtering (str, int, bool)
[ "matching", "of", "model", "/", "scenario", "names", "variables", "regions", "and", "meta", "columns", "to", "pseudo", "-", "regex", "(", "if", "regexp", "==", "False", ")", "for", "filtering", "(", "str", "int", "bool", ")" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L307-L329
IAMconsortium/pyam
pyam/utils.py
_escape_regexp
def _escape_regexp(s): """escape characters with specific regexp use""" return ( str(s) .replace('|', '\\|') .replace('.', '\.') # `.` has to be replaced before `*` .replace('*', '.*') .replace('+', '\+') .replace('(', '\(') .replace(')', '\)') .r...
python
def _escape_regexp(s): """escape characters with specific regexp use""" return ( str(s) .replace('|', '\\|') .replace('.', '\.') # `.` has to be replaced before `*` .replace('*', '.*') .replace('+', '\+') .replace('(', '\(') .replace(')', '\)') .r...
[ "def", "_escape_regexp", "(", "s", ")", ":", "return", "(", "str", "(", "s", ")", ".", "replace", "(", "'|'", ",", "'\\\\|'", ")", ".", "replace", "(", "'.'", ",", "'\\.'", ")", "# `.` has to be replaced before `*`", ".", "replace", "(", "'*'", ",", "'...
escape characters with specific regexp use
[ "escape", "characters", "with", "specific", "regexp", "use" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L332-L343
IAMconsortium/pyam
pyam/utils.py
years_match
def years_match(data, years): """ matching of year columns for data filtering """ years = [years] if isinstance(years, int) else years dt = datetime.datetime if isinstance(years, dt) or isinstance(years[0], dt): error_msg = "`year` can only be filtered with ints or lists of ints" ...
python
def years_match(data, years): """ matching of year columns for data filtering """ years = [years] if isinstance(years, int) else years dt = datetime.datetime if isinstance(years, dt) or isinstance(years[0], dt): error_msg = "`year` can only be filtered with ints or lists of ints" ...
[ "def", "years_match", "(", "data", ",", "years", ")", ":", "years", "=", "[", "years", "]", "if", "isinstance", "(", "years", ",", "int", ")", "else", "years", "dt", "=", "datetime", ".", "datetime", "if", "isinstance", "(", "years", ",", "dt", ")", ...
matching of year columns for data filtering
[ "matching", "of", "year", "columns", "for", "data", "filtering" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L346-L355
IAMconsortium/pyam
pyam/utils.py
hour_match
def hour_match(data, hours): """ matching of days in time columns for data filtering """ hours = [hours] if isinstance(hours, int) else hours return data.isin(hours)
python
def hour_match(data, hours): """ matching of days in time columns for data filtering """ hours = [hours] if isinstance(hours, int) else hours return data.isin(hours)
[ "def", "hour_match", "(", "data", ",", "hours", ")", ":", "hours", "=", "[", "hours", "]", "if", "isinstance", "(", "hours", ",", "int", ")", "else", "hours", "return", "data", ".", "isin", "(", "hours", ")" ]
matching of days in time columns for data filtering
[ "matching", "of", "days", "in", "time", "columns", "for", "data", "filtering" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L372-L377
IAMconsortium/pyam
pyam/utils.py
datetime_match
def datetime_match(data, dts): """ matching of datetimes in time columns for data filtering """ dts = dts if islistable(dts) else [dts] if any([not isinstance(i, datetime.datetime) for i in dts]): error_msg = ( "`time` can only be filtered by datetimes" ) raise Ty...
python
def datetime_match(data, dts): """ matching of datetimes in time columns for data filtering """ dts = dts if islistable(dts) else [dts] if any([not isinstance(i, datetime.datetime) for i in dts]): error_msg = ( "`time` can only be filtered by datetimes" ) raise Ty...
[ "def", "datetime_match", "(", "data", ",", "dts", ")", ":", "dts", "=", "dts", "if", "islistable", "(", "dts", ")", "else", "[", "dts", "]", "if", "any", "(", "[", "not", "isinstance", "(", "i", ",", "datetime", ".", "datetime", ")", "for", "i", ...
matching of datetimes in time columns for data filtering
[ "matching", "of", "datetimes", "in", "time", "columns", "for", "data", "filtering" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L422-L432
IAMconsortium/pyam
pyam/utils.py
to_int
def to_int(x, index=False): """Formatting series or timeseries columns to int and checking validity. If `index=False`, the function works on the `pd.Series x`; else, the function casts the index of `x` to int and returns x with a new index. """ _x = x.index if index else x cols = list(map(int, _...
python
def to_int(x, index=False): """Formatting series or timeseries columns to int and checking validity. If `index=False`, the function works on the `pd.Series x`; else, the function casts the index of `x` to int and returns x with a new index. """ _x = x.index if index else x cols = list(map(int, _...
[ "def", "to_int", "(", "x", ",", "index", "=", "False", ")", ":", "_x", "=", "x", ".", "index", "if", "index", "else", "x", "cols", "=", "list", "(", "map", "(", "int", ",", "_x", ")", ")", "error", "=", "_x", "[", "cols", "!=", "_x", "]", "...
Formatting series or timeseries columns to int and checking validity. If `index=False`, the function works on the `pd.Series x`; else, the function casts the index of `x` to int and returns x with a new index.
[ "Formatting", "series", "or", "timeseries", "columns", "to", "int", "and", "checking", "validity", ".", "If", "index", "=", "False", "the", "function", "works", "on", "the", "pd", ".", "Series", "x", ";", "else", "the", "function", "casts", "the", "index",...
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L435-L449
IAMconsortium/pyam
pyam/utils.py
concat_with_pipe
def concat_with_pipe(x, cols=None): """Concatenate a `pd.Series` separated by `|`, drop `None` or `np.nan`""" cols = cols or x.index return '|'.join([x[i] for i in cols if x[i] not in [None, np.nan]])
python
def concat_with_pipe(x, cols=None): """Concatenate a `pd.Series` separated by `|`, drop `None` or `np.nan`""" cols = cols or x.index return '|'.join([x[i] for i in cols if x[i] not in [None, np.nan]])
[ "def", "concat_with_pipe", "(", "x", ",", "cols", "=", "None", ")", ":", "cols", "=", "cols", "or", "x", ".", "index", "return", "'|'", ".", "join", "(", "[", "x", "[", "i", "]", "for", "i", "in", "cols", "if", "x", "[", "i", "]", "not", "in"...
Concatenate a `pd.Series` separated by `|`, drop `None` or `np.nan`
[ "Concatenate", "a", "pd", ".", "Series", "separated", "by", "|", "drop", "None", "or", "np", ".", "nan" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L452-L455
IAMconsortium/pyam
pyam/utils.py
reduce_hierarchy
def reduce_hierarchy(x, depth): """Reduce the hierarchy (depth by `|`) string to the specified level""" _x = x.split('|') depth = len(_x) + depth - 1 if depth < 0 else depth return '|'.join(_x[0:(depth + 1)])
python
def reduce_hierarchy(x, depth): """Reduce the hierarchy (depth by `|`) string to the specified level""" _x = x.split('|') depth = len(_x) + depth - 1 if depth < 0 else depth return '|'.join(_x[0:(depth + 1)])
[ "def", "reduce_hierarchy", "(", "x", ",", "depth", ")", ":", "_x", "=", "x", ".", "split", "(", "'|'", ")", "depth", "=", "len", "(", "_x", ")", "+", "depth", "-", "1", "if", "depth", "<", "0", "else", "depth", "return", "'|'", ".", "join", "("...
Reduce the hierarchy (depth by `|`) string to the specified level
[ "Reduce", "the", "hierarchy", "(", "depth", "by", "|", ")", "string", "to", "the", "specified", "level" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/utils.py#L458-L462
IAMconsortium/pyam
pyam/core.py
_aggregate
def _aggregate(df, by): """Aggregate `df` by specified column(s), return indexed `pd.Series`""" by = [by] if isstr(by) else by cols = [c for c in list(df.columns) if c not in ['value'] + by] return df.groupby(cols).sum()['value']
python
def _aggregate(df, by): """Aggregate `df` by specified column(s), return indexed `pd.Series`""" by = [by] if isstr(by) else by cols = [c for c in list(df.columns) if c not in ['value'] + by] return df.groupby(cols).sum()['value']
[ "def", "_aggregate", "(", "df", ",", "by", ")", ":", "by", "=", "[", "by", "]", "if", "isstr", "(", "by", ")", "else", "by", "cols", "=", "[", "c", "for", "c", "in", "list", "(", "df", ".", "columns", ")", "if", "c", "not", "in", "[", "'val...
Aggregate `df` by specified column(s), return indexed `pd.Series`
[ "Aggregate", "df", "by", "specified", "column", "(", "s", ")", "return", "indexed", "pd", ".", "Series" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1334-L1338
IAMconsortium/pyam
pyam/core.py
_check_rows
def _check_rows(rows, check, in_range=True, return_test='any'): """Check all rows to be in/out of a certain range and provide testing on return values based on provided conditions Parameters ---------- rows: pd.DataFrame data rows check: dict dictionary with possible values of '...
python
def _check_rows(rows, check, in_range=True, return_test='any'): """Check all rows to be in/out of a certain range and provide testing on return values based on provided conditions Parameters ---------- rows: pd.DataFrame data rows check: dict dictionary with possible values of '...
[ "def", "_check_rows", "(", "rows", ",", "check", ",", "in_range", "=", "True", ",", "return_test", "=", "'any'", ")", ":", "valid_checks", "=", "set", "(", "[", "'up'", ",", "'lo'", ",", "'year'", "]", ")", "if", "not", "set", "(", "check", ".", "k...
Check all rows to be in/out of a certain range and provide testing on return values based on provided conditions Parameters ---------- rows: pd.DataFrame data rows check: dict dictionary with possible values of 'up', 'lo', and 'year' in_range: bool, optional check if val...
[ "Check", "all", "rows", "to", "be", "in", "/", "out", "of", "a", "certain", "range", "and", "provide", "testing", "on", "return", "values", "based", "on", "provided", "conditions" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1345-L1385
IAMconsortium/pyam
pyam/core.py
_apply_criteria
def _apply_criteria(df, criteria, **kwargs): """Apply criteria individually to every model/scenario instance""" idxs = [] for var, check in criteria.items(): _df = df[df['variable'] == var] for group in _df.groupby(META_IDX): grp_idxs = _check_rows(group[-1], check, **kwargs) ...
python
def _apply_criteria(df, criteria, **kwargs): """Apply criteria individually to every model/scenario instance""" idxs = [] for var, check in criteria.items(): _df = df[df['variable'] == var] for group in _df.groupby(META_IDX): grp_idxs = _check_rows(group[-1], check, **kwargs) ...
[ "def", "_apply_criteria", "(", "df", ",", "criteria", ",", "*", "*", "kwargs", ")", ":", "idxs", "=", "[", "]", "for", "var", ",", "check", "in", "criteria", ".", "items", "(", ")", ":", "_df", "=", "df", "[", "df", "[", "'variable'", "]", "==", ...
Apply criteria individually to every model/scenario instance
[ "Apply", "criteria", "individually", "to", "every", "model", "/", "scenario", "instance" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1388-L1397
IAMconsortium/pyam
pyam/core.py
_make_index
def _make_index(df, cols=META_IDX): """Create an index from the columns of a dataframe""" return pd.MultiIndex.from_tuples( pd.unique(list(zip(*[df[col] for col in cols]))), names=tuple(cols))
python
def _make_index(df, cols=META_IDX): """Create an index from the columns of a dataframe""" return pd.MultiIndex.from_tuples( pd.unique(list(zip(*[df[col] for col in cols]))), names=tuple(cols))
[ "def", "_make_index", "(", "df", ",", "cols", "=", "META_IDX", ")", ":", "return", "pd", ".", "MultiIndex", ".", "from_tuples", "(", "pd", ".", "unique", "(", "list", "(", "zip", "(", "*", "[", "df", "[", "col", "]", "for", "col", "in", "cols", "...
Create an index from the columns of a dataframe
[ "Create", "an", "index", "from", "the", "columns", "of", "a", "dataframe" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1400-L1403
IAMconsortium/pyam
pyam/core.py
validate
def validate(df, criteria={}, exclude_on_fail=False, **kwargs): """Validate scenarios using criteria on timeseries values Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.validate()` for details kwargs: passed to `df.filter()` """ fdf = df.filter(**kwargs) if ...
python
def validate(df, criteria={}, exclude_on_fail=False, **kwargs): """Validate scenarios using criteria on timeseries values Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.validate()` for details kwargs: passed to `df.filter()` """ fdf = df.filter(**kwargs) if ...
[ "def", "validate", "(", "df", ",", "criteria", "=", "{", "}", ",", "exclude_on_fail", "=", "False", ",", "*", "*", "kwargs", ")", ":", "fdf", "=", "df", ".", "filter", "(", "*", "*", "kwargs", ")", "if", "len", "(", "fdf", ".", "data", ")", ">"...
Validate scenarios using criteria on timeseries values Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.validate()` for details kwargs: passed to `df.filter()`
[ "Validate", "scenarios", "using", "criteria", "on", "timeseries", "values" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1406-L1419
IAMconsortium/pyam
pyam/core.py
require_variable
def require_variable(df, variable, unit=None, year=None, exclude_on_fail=False, **kwargs): """Check whether all scenarios have a required variable Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.require_variable()` for details kwargs: passed to `df.f...
python
def require_variable(df, variable, unit=None, year=None, exclude_on_fail=False, **kwargs): """Check whether all scenarios have a required variable Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.require_variable()` for details kwargs: passed to `df.f...
[ "def", "require_variable", "(", "df", ",", "variable", ",", "unit", "=", "None", ",", "year", "=", "None", ",", "exclude_on_fail", "=", "False", ",", "*", "*", "kwargs", ")", ":", "fdf", "=", "df", ".", "filter", "(", "*", "*", "kwargs", ")", "if",...
Check whether all scenarios have a required variable Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.require_variable()` for details kwargs: passed to `df.filter()`
[ "Check", "whether", "all", "scenarios", "have", "a", "required", "variable" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1422-L1437
IAMconsortium/pyam
pyam/core.py
categorize
def categorize(df, name, value, criteria, color=None, marker=None, linestyle=None, **kwargs): """Assign scenarios to a category according to specific criteria or display the category assignment Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.categorize()` ...
python
def categorize(df, name, value, criteria, color=None, marker=None, linestyle=None, **kwargs): """Assign scenarios to a category according to specific criteria or display the category assignment Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.categorize()` ...
[ "def", "categorize", "(", "df", ",", "name", ",", "value", ",", "criteria", ",", "color", "=", "None", ",", "marker", "=", "None", ",", "linestyle", "=", "None", ",", "*", "*", "kwargs", ")", ":", "fdf", "=", "df", ".", "filter", "(", "*", "*", ...
Assign scenarios to a category according to specific criteria or display the category assignment Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.categorize()` for details kwargs: passed to `df.filter()`
[ "Assign", "scenarios", "to", "a", "category", "according", "to", "specific", "criteria", "or", "display", "the", "category", "assignment" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1440-L1459
IAMconsortium/pyam
pyam/core.py
check_aggregate
def check_aggregate(df, variable, components=None, exclude_on_fail=False, multiplier=1, **kwargs): """Check whether the timeseries values match the aggregation of sub-categories Parameters ---------- df: IamDataFrame instance args: see IamDataFrame.check_aggregate() for deta...
python
def check_aggregate(df, variable, components=None, exclude_on_fail=False, multiplier=1, **kwargs): """Check whether the timeseries values match the aggregation of sub-categories Parameters ---------- df: IamDataFrame instance args: see IamDataFrame.check_aggregate() for deta...
[ "def", "check_aggregate", "(", "df", ",", "variable", ",", "components", "=", "None", ",", "exclude_on_fail", "=", "False", ",", "multiplier", "=", "1", ",", "*", "*", "kwargs", ")", ":", "fdf", "=", "df", ".", "filter", "(", "*", "*", "kwargs", ")",...
Check whether the timeseries values match the aggregation of sub-categories Parameters ---------- df: IamDataFrame instance args: see IamDataFrame.check_aggregate() for details kwargs: passed to `df.filter()`
[ "Check", "whether", "the", "timeseries", "values", "match", "the", "aggregation", "of", "sub", "-", "categories" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1462-L1479
IAMconsortium/pyam
pyam/core.py
filter_by_meta
def filter_by_meta(data, df, join_meta=False, **kwargs): """Filter by and join meta columns from an IamDataFrame to a pd.DataFrame Parameters ---------- data: pd.DataFrame instance DataFrame to which meta columns are to be joined, index or columns must include `['model', 'scenario']` ...
python
def filter_by_meta(data, df, join_meta=False, **kwargs): """Filter by and join meta columns from an IamDataFrame to a pd.DataFrame Parameters ---------- data: pd.DataFrame instance DataFrame to which meta columns are to be joined, index or columns must include `['model', 'scenario']` ...
[ "def", "filter_by_meta", "(", "data", ",", "df", ",", "join_meta", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "not", "set", "(", "META_IDX", ")", ".", "issubset", "(", "data", ".", "index", ".", "names", "+", "list", "(", "data", ".", ...
Filter by and join meta columns from an IamDataFrame to a pd.DataFrame Parameters ---------- data: pd.DataFrame instance DataFrame to which meta columns are to be joined, index or columns must include `['model', 'scenario']` df: IamDataFrame instance IamDataFrame from which meta...
[ "Filter", "by", "and", "join", "meta", "columns", "from", "an", "IamDataFrame", "to", "a", "pd", ".", "DataFrame" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1482-L1534
IAMconsortium/pyam
pyam/core.py
compare
def compare(left, right, left_label='left', right_label='right', drop_close=True, **kwargs): """Compare the data in two IamDataFrames and return a pd.DataFrame Parameters ---------- left, right: IamDataFrames the IamDataFrames to be compared left_label, right_label: str, default...
python
def compare(left, right, left_label='left', right_label='right', drop_close=True, **kwargs): """Compare the data in two IamDataFrames and return a pd.DataFrame Parameters ---------- left, right: IamDataFrames the IamDataFrames to be compared left_label, right_label: str, default...
[ "def", "compare", "(", "left", ",", "right", ",", "left_label", "=", "'left'", ",", "right_label", "=", "'right'", ",", "drop_close", "=", "True", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "pd", ".", "concat", "(", "{", "right_label", ":", "righ...
Compare the data in two IamDataFrames and return a pd.DataFrame Parameters ---------- left, right: IamDataFrames the IamDataFrames to be compared left_label, right_label: str, default `left`, `right` column names of the returned dataframe drop_close: bool, default True remov...
[ "Compare", "the", "data", "in", "two", "IamDataFrames", "and", "return", "a", "pd", ".", "DataFrame" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1537-L1556
IAMconsortium/pyam
pyam/core.py
concat
def concat(dfs): """Concatenate a series of `pyam.IamDataFrame`-like objects together""" if isstr(dfs) or not hasattr(dfs, '__iter__'): msg = 'Argument must be a non-string iterable (e.g., list or tuple)' raise TypeError(msg) _df = None for df in dfs: df = df if isinstance(df, I...
python
def concat(dfs): """Concatenate a series of `pyam.IamDataFrame`-like objects together""" if isstr(dfs) or not hasattr(dfs, '__iter__'): msg = 'Argument must be a non-string iterable (e.g., list or tuple)' raise TypeError(msg) _df = None for df in dfs: df = df if isinstance(df, I...
[ "def", "concat", "(", "dfs", ")", ":", "if", "isstr", "(", "dfs", ")", "or", "not", "hasattr", "(", "dfs", ",", "'__iter__'", ")", ":", "msg", "=", "'Argument must be a non-string iterable (e.g., list or tuple)'", "raise", "TypeError", "(", "msg", ")", "_df", ...
Concatenate a series of `pyam.IamDataFrame`-like objects together
[ "Concatenate", "a", "series", "of", "pyam", ".", "IamDataFrame", "-", "like", "objects", "together" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L1559-L1572
IAMconsortium/pyam
pyam/core.py
IamDataFrame.variables
def variables(self, include_units=False): """Get a list of variables Parameters ---------- include_units: boolean, default False include the units """ if include_units: return self.data[['variable', 'unit']].drop_duplicates()\ .res...
python
def variables(self, include_units=False): """Get a list of variables Parameters ---------- include_units: boolean, default False include the units """ if include_units: return self.data[['variable', 'unit']].drop_duplicates()\ .res...
[ "def", "variables", "(", "self", ",", "include_units", "=", "False", ")", ":", "if", "include_units", ":", "return", "self", ".", "data", "[", "[", "'variable'", ",", "'unit'", "]", "]", ".", "drop_duplicates", "(", ")", ".", "reset_index", "(", "drop", ...
Get a list of variables Parameters ---------- include_units: boolean, default False include the units
[ "Get", "a", "list", "of", "variables" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L161-L173
IAMconsortium/pyam
pyam/core.py
IamDataFrame.append
def append(self, other, ignore_meta_conflict=False, inplace=False, **kwargs): """Append any castable object to this IamDataFrame. Columns in `other.meta` that are not in `self.meta` are always merged, duplicate region-variable-unit-year rows raise a ValueError. Parameters...
python
def append(self, other, ignore_meta_conflict=False, inplace=False, **kwargs): """Append any castable object to this IamDataFrame. Columns in `other.meta` that are not in `self.meta` are always merged, duplicate region-variable-unit-year rows raise a ValueError. Parameters...
[ "def", "append", "(", "self", ",", "other", ",", "ignore_meta_conflict", "=", "False", ",", "inplace", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "other", ",", "IamDataFrame", ")", ":", "other", "=", "IamDataFrame", ...
Append any castable object to this IamDataFrame. Columns in `other.meta` that are not in `self.meta` are always merged, duplicate region-variable-unit-year rows raise a ValueError. Parameters ---------- other: pyam.IamDataFrame, ixmp.TimeSeries, ixmp.Scenario, pd.DataFra...
[ "Append", "any", "castable", "object", "to", "this", "IamDataFrame", ".", "Columns", "in", "other", ".", "meta", "that", "are", "not", "in", "self", ".", "meta", "are", "always", "merged", "duplicate", "region", "-", "variable", "-", "unit", "-", "year", ...
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L175-L246
IAMconsortium/pyam
pyam/core.py
IamDataFrame.pivot_table
def pivot_table(self, index, columns, values='value', aggfunc='count', fill_value=None, style=None): """Returns a pivot table Parameters ---------- index: str or list of strings rows for Pivot table columns: str or list of strings colu...
python
def pivot_table(self, index, columns, values='value', aggfunc='count', fill_value=None, style=None): """Returns a pivot table Parameters ---------- index: str or list of strings rows for Pivot table columns: str or list of strings colu...
[ "def", "pivot_table", "(", "self", ",", "index", ",", "columns", ",", "values", "=", "'value'", ",", "aggfunc", "=", "'count'", ",", "fill_value", "=", "None", ",", "style", "=", "None", ")", ":", "index", "=", "[", "index", "]", "if", "isstr", "(", ...
Returns a pivot table Parameters ---------- index: str or list of strings rows for Pivot table columns: str or list of strings columns for Pivot table values: str, default 'value' dataframe column to aggregate or count aggfunc: str or ...
[ "Returns", "a", "pivot", "table" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L248-L290
IAMconsortium/pyam
pyam/core.py
IamDataFrame.interpolate
def interpolate(self, year): """Interpolate missing values in timeseries (linear interpolation) Parameters ---------- year: int year to be interpolated """ df = self.pivot_table(index=IAMC_IDX, columns=['year'], values='value', ...
python
def interpolate(self, year): """Interpolate missing values in timeseries (linear interpolation) Parameters ---------- year: int year to be interpolated """ df = self.pivot_table(index=IAMC_IDX, columns=['year'], values='value', ...
[ "def", "interpolate", "(", "self", ",", "year", ")", ":", "df", "=", "self", ".", "pivot_table", "(", "index", "=", "IAMC_IDX", ",", "columns", "=", "[", "'year'", "]", ",", "values", "=", "'value'", ",", "aggfunc", "=", "np", ".", "sum", ")", "# d...
Interpolate missing values in timeseries (linear interpolation) Parameters ---------- year: int year to be interpolated
[ "Interpolate", "missing", "values", "in", "timeseries", "(", "linear", "interpolation", ")" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L292-L310
IAMconsortium/pyam
pyam/core.py
IamDataFrame.as_pandas
def as_pandas(self, with_metadata=False): """Return this as a pd.DataFrame Parameters ---------- with_metadata : bool, default False or dict if True, join data with all meta columns; if a dict, discover meaningful meta columns from values (in key-value) """...
python
def as_pandas(self, with_metadata=False): """Return this as a pd.DataFrame Parameters ---------- with_metadata : bool, default False or dict if True, join data with all meta columns; if a dict, discover meaningful meta columns from values (in key-value) """...
[ "def", "as_pandas", "(", "self", ",", "with_metadata", "=", "False", ")", ":", "if", "with_metadata", ":", "cols", "=", "self", ".", "_discover_meta_cols", "(", "*", "*", "with_metadata", ")", "if", "isinstance", "(", "with_metadata", ",", "dict", ")", "el...
Return this as a pd.DataFrame Parameters ---------- with_metadata : bool, default False or dict if True, join data with all meta columns; if a dict, discover meaningful meta columns from values (in key-value)
[ "Return", "this", "as", "a", "pd", ".", "DataFrame" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L312-L331
IAMconsortium/pyam
pyam/core.py
IamDataFrame._discover_meta_cols
def _discover_meta_cols(self, **kwargs): """Return the subset of `kwargs` values (not keys!) matching a `meta` column name""" cols = set(['exclude']) for arg, value in kwargs.items(): if isstr(value) and value in self.meta.columns: cols.add(value) retu...
python
def _discover_meta_cols(self, **kwargs): """Return the subset of `kwargs` values (not keys!) matching a `meta` column name""" cols = set(['exclude']) for arg, value in kwargs.items(): if isstr(value) and value in self.meta.columns: cols.add(value) retu...
[ "def", "_discover_meta_cols", "(", "self", ",", "*", "*", "kwargs", ")", ":", "cols", "=", "set", "(", "[", "'exclude'", "]", ")", "for", "arg", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "if", "isstr", "(", "value", ")", "and", "...
Return the subset of `kwargs` values (not keys!) matching a `meta` column name
[ "Return", "the", "subset", "of", "kwargs", "values", "(", "not", "keys!", ")", "matching", "a", "meta", "column", "name" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L333-L340
IAMconsortium/pyam
pyam/core.py
IamDataFrame.timeseries
def timeseries(self, iamc_index=False): """Returns a pd.DataFrame in wide format (years or timedate as columns) Parameters ---------- iamc_index: bool, default False if True, use `['model', 'scenario', 'region', 'variable', 'unit']`; else, use all `data` columns ...
python
def timeseries(self, iamc_index=False): """Returns a pd.DataFrame in wide format (years or timedate as columns) Parameters ---------- iamc_index: bool, default False if True, use `['model', 'scenario', 'region', 'variable', 'unit']`; else, use all `data` columns ...
[ "def", "timeseries", "(", "self", ",", "iamc_index", "=", "False", ")", ":", "index", "=", "IAMC_IDX", "if", "iamc_index", "else", "IAMC_IDX", "+", "self", ".", "extra_cols", "df", "=", "(", "self", ".", "data", ".", "pivot_table", "(", "index", "=", "...
Returns a pd.DataFrame in wide format (years or timedate as columns) Parameters ---------- iamc_index: bool, default False if True, use `['model', 'scenario', 'region', 'variable', 'unit']`; else, use all `data` columns
[ "Returns", "a", "pd", ".", "DataFrame", "in", "wide", "format", "(", "years", "or", "timedate", "as", "columns", ")" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L342-L361
IAMconsortium/pyam
pyam/core.py
IamDataFrame.set_meta
def set_meta(self, meta, name=None, index=None): """Add metadata columns as pd.Series, list or value (int/float/str) Parameters ---------- meta: pd.Series, list, int, float or str column to be added to metadata (by `['model', 'scenario']` index if possible) ...
python
def set_meta(self, meta, name=None, index=None): """Add metadata columns as pd.Series, list or value (int/float/str) Parameters ---------- meta: pd.Series, list, int, float or str column to be added to metadata (by `['model', 'scenario']` index if possible) ...
[ "def", "set_meta", "(", "self", ",", "meta", ",", "name", "=", "None", ",", "index", "=", "None", ")", ":", "# check that name is valid and doesn't conflict with data columns", "if", "(", "name", "or", "(", "hasattr", "(", "meta", ",", "'name'", ")", "and", ...
Add metadata columns as pd.Series, list or value (int/float/str) Parameters ---------- meta: pd.Series, list, int, float or str column to be added to metadata (by `['model', 'scenario']` index if possible) name: str, optional meta column name (default...
[ "Add", "metadata", "columns", "as", "pd", ".", "Series", "list", "or", "value", "(", "int", "/", "float", "/", "str", ")" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L367-L429
IAMconsortium/pyam
pyam/core.py
IamDataFrame.categorize
def categorize(self, name, value, criteria, color=None, marker=None, linestyle=None): """Assign scenarios to a category according to specific criteria or display the category assignment Parameters ---------- name: str category column name v...
python
def categorize(self, name, value, criteria, color=None, marker=None, linestyle=None): """Assign scenarios to a category according to specific criteria or display the category assignment Parameters ---------- name: str category column name v...
[ "def", "categorize", "(", "self", ",", "name", ",", "value", ",", "criteria", ",", "color", "=", "None", ",", "marker", "=", "None", ",", "linestyle", "=", "None", ")", ":", "# add plotting run control", "for", "kind", ",", "arg", "in", "[", "(", "'col...
Assign scenarios to a category according to specific criteria or display the category assignment Parameters ---------- name: str category column name value: str category identifier criteria: dict dictionary with variables mapped to app...
[ "Assign", "scenarios", "to", "a", "category", "according", "to", "specific", "criteria", "or", "display", "the", "category", "assignment" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L431-L472
IAMconsortium/pyam
pyam/core.py
IamDataFrame._new_meta_column
def _new_meta_column(self, name): """Add a column to meta if it doesn't exist, set to value `np.nan`""" if name is None: raise ValueError('cannot add a meta column `{}`'.format(name)) if name not in self.meta: self.meta[name] = np.nan
python
def _new_meta_column(self, name): """Add a column to meta if it doesn't exist, set to value `np.nan`""" if name is None: raise ValueError('cannot add a meta column `{}`'.format(name)) if name not in self.meta: self.meta[name] = np.nan
[ "def", "_new_meta_column", "(", "self", ",", "name", ")", ":", "if", "name", "is", "None", ":", "raise", "ValueError", "(", "'cannot add a meta column `{}`'", ".", "format", "(", "name", ")", ")", "if", "name", "not", "in", "self", ".", "meta", ":", "sel...
Add a column to meta if it doesn't exist, set to value `np.nan`
[ "Add", "a", "column", "to", "meta", "if", "it", "doesn", "t", "exist", "set", "to", "value", "np", ".", "nan" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L474-L479
IAMconsortium/pyam
pyam/core.py
IamDataFrame.require_variable
def require_variable(self, variable, unit=None, year=None, exclude_on_fail=False): """Check whether all scenarios have a required variable Parameters ---------- variable: str required variable unit: str, default None name of unit ...
python
def require_variable(self, variable, unit=None, year=None, exclude_on_fail=False): """Check whether all scenarios have a required variable Parameters ---------- variable: str required variable unit: str, default None name of unit ...
[ "def", "require_variable", "(", "self", ",", "variable", ",", "unit", "=", "None", ",", "year", "=", "None", ",", "exclude_on_fail", "=", "False", ")", ":", "criteria", "=", "{", "'variable'", ":", "variable", "}", "if", "unit", ":", "criteria", ".", "...
Check whether all scenarios have a required variable Parameters ---------- variable: str required variable unit: str, default None name of unit (optional) year: int or list, default None years (optional) exclude_on_fail: bool, default ...
[ "Check", "whether", "all", "scenarios", "have", "a", "required", "variable" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L481-L519
IAMconsortium/pyam
pyam/core.py
IamDataFrame.validate
def validate(self, criteria={}, exclude_on_fail=False): """Validate scenarios using criteria on timeseries values Parameters ---------- criteria: dict dictionary with variable keys and check values ('up' and 'lo' for respective bounds, 'year' for years) ex...
python
def validate(self, criteria={}, exclude_on_fail=False): """Validate scenarios using criteria on timeseries values Parameters ---------- criteria: dict dictionary with variable keys and check values ('up' and 'lo' for respective bounds, 'year' for years) ex...
[ "def", "validate", "(", "self", ",", "criteria", "=", "{", "}", ",", "exclude_on_fail", "=", "False", ")", ":", "df", "=", "_apply_criteria", "(", "self", ".", "data", ",", "criteria", ",", "in_range", "=", "False", ")", "if", "not", "df", ".", "empt...
Validate scenarios using criteria on timeseries values Parameters ---------- criteria: dict dictionary with variable keys and check values ('up' and 'lo' for respective bounds, 'year' for years) exclude_on_fail: bool, default False flag scenarios faili...
[ "Validate", "scenarios", "using", "criteria", "on", "timeseries", "values" ]
train
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L521-L541