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_documentation_string
stringlengths
1
47.2k
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...
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.
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...
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...
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 ...
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...
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 ...
Derives the jacobian from ``self.exprs`` and ``self.dep``.
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)) ...
Derive the jacobian-vector product from ``self.exprs`` and ``self.dep``
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
Returns True if Jacobian is singular, else False.
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...
Calculates 2nd derivatives of ``self.exprs``
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): ...
Generates a callback for evaluating ``self.exprs``.
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...
Generates a callback for evaluating the jacobian.
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)
Generate a callback for evaluating derivative of ``self.exprs``
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, ...
Generate a callback fro evaluating the jacobian-vector product.
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 ...
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...
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[...
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 (...
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. ...
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 ...
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...
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 ...
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 ...
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). ...
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)]
Transforms input to internal values, used internally.
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
Transforms internal values to output, used internally.
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...
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...
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 ...
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...
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: ...
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: ...
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...
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...
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...
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 ...
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...
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.
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...
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.
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...
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`
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...
[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...
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...
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.
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 ...
Check if the user has permission to edit any of the registered NewsItem types.
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
Check if the user has permission to edit a particular NewsItem type.
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
Try to make a date from the given inputs, raising Http404 on error
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 =...
A helper that takes some news items and returns an HttpResponse
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...
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.
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.' ...
Creates a point from lat/lon in WGS84
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...
Creates a point from pixels X Y Z (zoom) in pyramid
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...
Creates a point from X Y Z (zoom) meters in Spherical Mercator EPSG:900913
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 ...
Gets pixels of the EPSG:4326 pyramid by a specific zoom, converted from lat/lon in WGS84
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) ...
Gets the XY meters in Spherical Mercator EPSG:900913, converted from lat/lon in WGS84
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...
Creates a tile from a Microsoft QuadTree
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...
Creates a tile from Tile Map Service (TMS) X Y and zoom
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...
Creates a tile from Google format X Y and zoom
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)
Creates a tile for given point
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)
Creates a tile from pixels X Y Z (zoom) in pyramid
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)
Creates a tile from X Y meters in Spherical Mercator EPSG:900913
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...
Creates a tile from lat/lon in WGS84
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...
Gets the tile in the Microsoft QuadTree format, converted from TMS
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
Gets the tile in the Google format, converted from TMS
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...
Gets the bounds of a tile represented as the most west and south point and the most east and north point
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...
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...
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...
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 ...
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...
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...
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...
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...
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...
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. ...
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...
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...
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...
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...
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...
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).
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...
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...
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,) ...
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...
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 ...
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).
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...
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...
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,) ...
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...
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)...
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()
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...
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
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...
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 ...
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) ...
Read a file and return a pd.DataFrame
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()...
Read data from a file saved in the standard IAMC format or a table with year/value columns
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 = ...
Convert a `pd.Dataframe` or `pd.Series` to the required format
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)
Sort `data` rows and order columns
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 ...
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...
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...
matching of model/scenario names, variables, regions, and meta columns to pseudo-regex (if `regexp == False`) for filtering (str, int, bool)
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...
escape characters with specific regexp use
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" ...
matching of year columns for data filtering
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)
matching of days in time columns for data filtering
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...
matching of datetimes in time columns for data filtering
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, _...
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.
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]])
Concatenate a `pd.Series` separated by `|`, drop `None` or `np.nan`
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)])
Reduce the hierarchy (depth by `|`) string to the specified level
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']
Aggregate `df` by specified column(s), return indexed `pd.Series`
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 '...
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...
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) ...
Apply criteria individually to every model/scenario instance
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))
Create an index from the columns of a dataframe
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 ...
Validate scenarios using criteria on timeseries values Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.validate()` for details kwargs: passed to `df.filter()`
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...
Check whether all scenarios have a required variable Parameters ---------- df: IamDataFrame instance args: see `IamDataFrame.require_variable()` for details kwargs: passed to `df.filter()`
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()` ...
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()`
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...
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()`
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']` ...
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...
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...
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...
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...
Concatenate a series of `pyam.IamDataFrame`-like objects together
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...
Get a list of variables Parameters ---------- include_units: boolean, default False include the units
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...
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...
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...
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 ...
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', ...
Interpolate missing values in timeseries (linear interpolation) Parameters ---------- year: int year to be interpolated
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) """...
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)
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...
Return the subset of `kwargs` values (not keys!) matching a `meta` column name
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 ...
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
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) ...
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...
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...
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...
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
Add a column to meta if it doesn't exist, set to value `np.nan`
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 ...
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 ...
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...
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...
https://github.com/IAMconsortium/pyam/blob/4077929ca6e7be63a0e3ecf882c5f1da97b287bf/pyam/core.py#L521-L541