# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function)

import numpy as np

from ..util import import_
import pytest

from .. import ODESys
from ..core import integrate_chained
from ..symbolic import SymbolicSys, PartiallySolvedSystem, symmetricsys
from ..util import requires, pycvodes_double
from ._robertson import run_integration, get_ode_exprs

_yref_1e11 = (0.2083340149701255e-7, 0.8333360770334713e-13, 0.9999999791665050)


@requires('sym', 'sympy', 'pyodeint')
def test_run_integration():
    xout, yout, info = run_integration(integrator='odeint')[:3]
    assert info['success'] is True


@requires('sym', 'sympy', 'pycvodes')
@pycvodes_double
def test_run_integration__atol_dict():
    xout, yout, info = run_integration(
        integrator='cvode', atol={'A': 1e-10, 'B': 1e-11, 'C': 1e-6}, nsteps=1500)[:3]
    assert info['success'] is True


@requires('sym', 'sympy', 'pycvodes')
@pycvodes_double
def test_run_integration__atol_list():
    xout, yout, info = run_integration(
        integrator='cvode', atol=[1e-10, 1e-11, 1e-6], nsteps=1500)[:3]
    assert info['success'] is True


def _test_goe(symbolic=False, reduced=0, extra_forgive=1, logc=False,
              logt=False, zero_conc=0, zero_time=0, nonnegative=None,
              atol=1e-14, rtol=1e-10, integrator='cvode', nsteps=7000, **kwargs):
    sympy = import_('sympy')

    ny, nk = 3, 3
    k = (.04, 1e4, 3e7)
    y0 = (1, zero_conc, zero_conc)