Skip to content

Commit

Permalink
Fix escape sequence (#108)
Browse files Browse the repository at this point in the history
* Fix escape sequence

* Fix remaining invalid escape sequence

* Tweaks to extend_by_integration

* try using newer CI image

* Add boost to path

* msbj and stab_lim_det

* max_num_steps_between_jac

* CI: fix boost include path

* handle array

* bump pycvodes req. version & CI: suppress notebook output
  • Loading branch information
bjodah authored Oct 1, 2019
1 parent 0be9b09 commit 5dfb63f
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .ci/test_py2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ done
python2 -m pip install --user virtualenv
python2 -m virtualenv /tmp/test_py2
sed -i -E -e "/python_requires/d" setup.py
bash -c "source /tmp/test_py2/bin/activate; pip install pytest '.[all]' && pytest -rs --pyargs ${PKG_NAME}"
bash -c "source /tmp/test_py2/bin/activate; pip install 'numpy<1.17' pytest '.[all]' && pytest -rs --pyargs ${PKG_NAME}"
14 changes: 7 additions & 7 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ pipeline:

test-sund-3.2.1-klu:
group: testing
image: bjodah/bjodahimg18:v1.5
image: bjodah/bjodahimg18:v3.0
environment:
- OMP_NUM_THREADS=1
- ANYODE_NUM_THREADS=2
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_71_0/include
- LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
commands:
Expand All @@ -39,11 +39,11 @@ pipeline:

test-sund-4.1.0-nolapack-noklu-extended:
group: testing
image: bjodah/bjodahimg18:v1.5
image: bjodah/bjodahimg18:v3.0
environment:
- OMP_NUM_THREADS=1
- ANYODE_NUM_THREADS=2
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_71_0/include
- LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
commands:
Expand All @@ -59,11 +59,11 @@ pipeline:
- bash -c "ulimit -v 2048000; .ci/run_ci.sh pyodesys $SUNDBASE"

test-py2:
image: bjodah/bjodahimg18:v1.5
image: bjodah/bjodahimg18:v3.0
environment:
- OMP_NUM_THREADS=1
- ANYODE_NUM_THREADS=2
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse
- CPLUS_INCLUDE_PATH=/usr/include/suitesparse:/opt/boost_1_71_0/include
- LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
- LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
commands:
Expand All @@ -72,7 +72,7 @@ pipeline:

test-conda-recipe:
group: testing
image: bjodah/bjodahimg18dev:v1.5
image: bjodah/bjodahimg18dev:v3.0
commands:
- export CONDA_PKGS_DIRS=$(pwd)/ci_cache/conda_packages
- PATH=/opt/miniconda3/bin:$PATH conda update conda-build
Expand Down
2 changes: 1 addition & 1 deletion pyodesys/convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def integrate_tolerance_series(odesys, atols, rtols, x, y0, params=(),
Passed on to ``odesys.integrate``.
fit : callable
val : callable
\*\*kwargs:
\\*\\*kwargs:
Passed on to ``odesys.integrate``.
Returns
Expand Down
14 changes: 7 additions & 7 deletions pyodesys/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def adaptive(self, y0, x0, xend, params=(), **kwargs):
Final value of the independent variable.
params : array_like
See :meth:`integrate`.
\*\*kwargs :
\\*\\*kwargs :
See :meth:`integrate`.
Returns
Expand All @@ -332,7 +332,7 @@ def predefined(self, y0, xout, params=(), **kwargs):
xout : array_like
params : array_like
See :meth:`integrate`.
\*\*kwargs:
\\*\\*kwargs:
See :meth:`integrate`
Returns
Expand Down Expand Up @@ -461,11 +461,11 @@ def _integrate_scipy(self, intern_xout, intern_y0, intern_p,
Parameters
----------
\*args :
\\*args :
See :meth:`integrate`.
name : str (default: 'lsoda'/'dopri5' when jacobian is available/not)
What integrator wrapped in scipy.integrate.ode to use.
\*\*kwargs :
\\*\\*kwargs :
Keyword arguments passed onto `set_integrator(...) <
http://docs.scipy.org/doc/scipy/reference/generated/
scipy.integrate.ode.set_integrator.html#scipy.integrate.ode.set_integrator>`_
Expand Down Expand Up @@ -671,11 +671,11 @@ def _integrate_gsl(self, *args, **kwargs):
Parameters
----------
\*args :
\\*args :
see :meth:`integrate`
method : str (default: 'bsimp')
what stepper to use, see :py:attr:`gslodeiv2.steppers`
\*\*kwargs :
\\*\\*kwargs :
keyword arguments passed onto
:py:func:`gslodeiv2.integrate_adaptive`/:py:func:`gslodeiv2.integrate_predefined`
Expand Down Expand Up @@ -834,7 +834,7 @@ def integrate_auto_switch(odes, kw, x, y0, params=(), **kwargs):
x : array_like
y0 : array_like
params : array_like
\*\*kwargs:
\\*\\*kwargs:
See :meth:`ODESys.integrate`
Notes
Expand Down
11 changes: 7 additions & 4 deletions pyodesys/native/sources/_cvode_wrapper.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def integrate_adaptive(floating [:, ::1] y0,
realtype get_dx_max_factor=0.0, bool error_outside_bounds=False,
realtype max_invariant_violation=0.0, special_settings=None,
bool autonomous_exprs=False, int nprealloc=500, bool ew_ele=False,
vector[realtype] constraints=[]):
vector[realtype] constraints=[], long int max_num_steps_between_jac=0,
bool stab_lim_det=False):
cdef:
realtype ** xyout = <realtype **>malloc(y0.shape[0]*sizeof(realtype *))
realtype [:,::1] xyout_view
Expand Down Expand Up @@ -192,7 +193,7 @@ def integrate_adaptive(floating [:, ::1] y0,
&_dx0[0], &_dx_min[0], &_dx_max[0], with_jacobian, iter_type_from_name(_iter_t),
linear_solver_from_name(linear_solver.lower().encode('UTF-8')),
maxl, eps_lin, nderiv, return_on_root, autorestart, return_on_error, with_jtimes,
tidx, ew_ele_arr if ew_ele else NULL, constraints
tidx, ew_ele_arr if ew_ele else NULL, constraints, max_num_steps_between_jac, stab_lim_det
)
xout, yout = [], []
for idx in range(y0.shape[0]):
Expand Down Expand Up @@ -250,7 +251,8 @@ def integrate_predefined(floating [:, ::1] y0,
bool record_order=False, bool record_fpe=False,
realtype get_dx_max_factor=0.0, bool error_outside_bounds=False,
realtype max_invariant_violation=0.0, special_settings=None,
bool autonomous_exprs=False, ew_ele=False, vector[realtype] constraints=[]):
bool autonomous_exprs=False, ew_ele=False, vector[realtype] constraints=[],
long int max_num_steps_between_jac=0, bool stab_lim_det=False):
cdef:
vector[CvodesOdeSys *] systems
list nfos = []
Expand Down Expand Up @@ -339,7 +341,8 @@ def integrate_predefined(floating [:, ::1] y0,
<realtype *> xout_arr.data, <realtype *> yout_arr.data, mxsteps, &_dx0[0], &_dx_min[0],
&_dx_max[0], with_jacobian, iter_type_from_name(_iter_t),
linear_solver_from_name(linear_solver.lower().encode('UTF-8')),
maxl, eps_lin, nderiv, autorestart, return_on_error, with_jtimes, ew_ele_arr if ew_ele else NULL, constraints)
maxl, eps_lin, nderiv, autorestart, return_on_error, with_jtimes,
ew_ele_arr if ew_ele else NULL, constraints, max_num_steps_between_jac, stab_lim_det)

for idx in range(y0.shape[0]):
nreached = result[idx].first
Expand Down
2 changes: 1 addition & 1 deletion pyodesys/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def plot_phase_plane(x, y, indices=None, plot=None, names=None, ax=None, **kwarg
Uses ``matplotlib.pyplot.plot`` if ``None``
names: iterable of strings
Labels for x and y axis.
\*\*kwargs:
\\*\\*kwargs:
Keyword arguemtns passed to ``plot()``.
"""
Expand Down
10 changes: 6 additions & 4 deletions pyodesys/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def plot(self, info_vlines_kw=None, between=None, deriv=False, title_info=0, **k
deriv : bool
Plot derivatives (internal variables).
names : iterable of str
\*\*kwargs:
\\*\\*kwargs:
See :func:`pyodesys.plotting.plot_result`
"""
if between is not None:
Expand Down Expand Up @@ -255,7 +255,7 @@ def plot_phase_plane(self, indices=None, **kwargs):
----------
indices : iterable of int
names : iterable of str
\*\*kwargs:
\\*\\*kwargs:
See :func:`pyodesys.plotting.plot_phase_plane`
"""
Expand Down Expand Up @@ -285,7 +285,7 @@ def extend_by_integration(self, xend, params=None, odesys=None, autonomous=None,
else self.odesys.numpy.linspace(x0, xend, npoints+1)
), self.yout[..., -1, :], params or self.params, **kwargs
)
self.xout = self.odesys.numpy.concatenate((self.xout, res.xout[1:] + (x0 if autonomous else 0)))
self.xout = self.odesys.numpy.concatenate((self.xout, res.xout[1:] + (x0 if autonomous else 0*x0)))
self.yout = self.odesys.numpy.concatenate((self.yout, res.yout[..., 1:, :]))
new_info = {k: v for k, v in self.info.items() if not (
k.startswith('internal') and odesys is not self.odesys)}
Expand All @@ -298,7 +298,9 @@ def extend_by_integration(self, xend, params=None, odesys=None, autonomous=None,
elif k == 'success':
new_info[k] = new_info[k] and v
elif k.endswith('_xvals'):
new_info[k] = self.odesys.numpy.concatenate((new_info[k], v + (x0 if autonomous else 0)))
if len(v) == 0:
continue
new_info[k] = self.odesys.numpy.concatenate((new_info[k], v + (x0 if autonomous else 0*x0)))
elif k.endswith('_indices'):
new_info[k].extend([itm + nx0 - 1 for itm in v])
elif isinstance(v, str):
Expand Down
18 changes: 9 additions & 9 deletions pyodesys/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class SymbolicSys(ODESys):
When ``True``, jacobian will be derived and stored (if ``jac = True``)
in compressed sparse column (CSC) format and the jacobian callback
will return an instance of ``scipy.sparse.csc_matrix``.
\*\*kwargs:
\\*\\*kwargs:
See :py:class:`ODESys`
Attributes
Expand Down Expand Up @@ -405,7 +405,7 @@ def from_callback(cls, rhs, ny=None, nparams=None, first_step_factory=None,
its return value from dict to array.
par_by_name : bool
Make ``p`` passed to ``rhs`` a dict (keys from :attr:`param_names`).
\*\*kwargs :
\\*\\*kwargs :
Keyword arguments passed onto :class:`SymbolicSys`.
Examples
Expand Down Expand Up @@ -818,7 +818,7 @@ class TransformedSys(SymbolicSys):
check_transforms : bool
Passed as keyword argument ``check`` to :func:`.util.transform_exprs_dep` and
:func:`.util.transform_exprs_indep`.
\*\*kwargs :
\\*\\*kwargs :
Keyword arguments passed onto :class:`SymbolicSys`.
"""
Expand Down Expand Up @@ -904,7 +904,7 @@ def from_callback(cls, cb, ny=None, nparams=None, dep_transf_cbs=None,
roots_cb : callable
Callback with signature ``roots(x, y[:], p[:], backend=math) -> r[:]``.
Callback should return untransformed roots.
\*\*kwargs :
\\*\\*kwargs :
Keyword arguments passed onto :class:`TransformedSys`.
"""
Expand Down Expand Up @@ -972,7 +972,7 @@ def symmetricsys(dep_tr=None, indep_tr=None, SuperClass=TransformedSys, **kwargs
Forward and backward transformation to be applied to the
independent variable.
SuperClass : class
\*\*kwargs :
\\*\\*kwargs :
Default keyword arguments for the TransformedSys subclass.
Returns
Expand Down Expand Up @@ -1042,7 +1042,7 @@ class ScaledSys(TransformedSys):
scaling of the independent variable (default: 1)
params :
see :class:`SymbolicSys`
\*\*kwargs :
\\*\\*kwargs :
Keyword arguments passed onto :class:`TransformedSys`.
Examples
Expand Down Expand Up @@ -1102,7 +1102,7 @@ def from_callback(cls, cb, ny=None, nparams=None, dep_scaling=1, indep_scaling=1
scaling of the dependent variables (default: 1)
indep_scaling: number (>0)
scaling of the independent variable (default: 1)
\*\*kwargs :
\\*\\*kwargs :
Keyword arguments passed onto :class:`ScaledSys`.
Examples
Expand Down Expand Up @@ -1143,7 +1143,7 @@ class PartiallySolvedSystem(SymbolicSys):
the signature: ``my_factory(x0, y0, p0, backend) -> dict``, where the returned
dictionary maps dependent variabels (from ``original_system.dep``)
to new expressions in remaining variables and initial conditions.
\*\*kwargs : dict
\\*\\*kwargs : dict
Keyword arguments passed onto :class:`SymbolicSys`.
Attributes
Expand Down Expand Up @@ -1285,7 +1285,7 @@ def from_linear_invariants(cls, ori_sys, preferred=None, **kwargs):
preferred : iterable of preferred dependent variables
Due to numerical rounding it is preferable to choose the variables
which are expected to be of the largest magnitude during integration.
\*\*kwargs :
\\*\\*kwargs :
Keyword arguments passed on to constructor.
"""
_be = ori_sys.be
Expand Down
22 changes: 21 additions & 1 deletion scripts/render_notebooks.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
#!/bin/bash -e
QUIET_EXIT_CODE=0
function quiet_unless_fail {
# suppresses function output unless exit status is != 0
OUTPUT_FILE=$(tempfile)
#/bin/rm --force /tmp/suppress.out 2>/dev/null
EXECMD=${1+"$@"}
$EXECMD > ${OUTPUT_FILE} 2>&1
QUIET_EXIT_CODE=$?
if [ ${QUIET_EXIT_CODE} -ne 0 ]; then
cat ${OUTPUT_FILE}
echo "The following command exited with exit status ${QUIET_EXIT_CODE}: ${EXECMD}"
fi
/bin/rm ${OUTPUT_FILE}
}


cd examples/

PREC=`python3 -c "from pycvodes._config import env; print(env.get('SUNDIALS_PRECISION', 'double'))"`
Expand All @@ -10,6 +26,10 @@ for ipynb in *.ipynb; do
if [[ $PREC != "double" && $ipynb == "_robertson.ipynb" ]]; then
continue
fi
jupyter nbconvert --debug --to=html --ExecutePreprocessor.enabled=True --ExecutePreprocessor.timeout=900 $ipynb
quiet_unless_fail jupyter nbconvert --debug --to=html --ExecutePreprocessor.enabled=True --ExecutePreprocessor.timeout=900 "${ipynb}" \
| grep -v -e "^\[NbConvertApp\] content: {'data':.*'image/png'"
if [ ${QUIET_EXIT_CODE} -ne 0 ]; then
exit ${QUIET_EXIT_CODE}
fi
done
../scripts/render_index.sh *.html
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _path_under_setup(*args):
_author, _author_email = open(_path_under_setup('AUTHORS'), 'rt').readline().split('<')

extras_req = {
'integrators': ['pyodeint>=0.10.1', 'pycvodes>=0.11.12', 'pygslodeiv2>=0.9.1'],
'integrators': ['pyodeint>=0.10.1', 'pycvodes>=0.11.15', 'pygslodeiv2>=0.9.1'],
'native': ['pycompilation>=0.4.3', 'pycodeexport>=0.1.2', 'appdirs'],
'docs': ['Sphinx', 'sphinx_rtd_theme', 'numpydoc'],
'testing': ['pytest', 'pytest-cov', 'pytest-flakes', 'pytest-pep8', 'rstcheck']
Expand Down

0 comments on commit 5dfb63f

Please # to comment.