Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

import numpy as np 

import pytest 

 

from chemreac.util.analysis import ( 

    solver_linear_error, solver_linear_error_from_integration 

) 

 

 

def test_solver_linear_error(): 

    assert np.allclose(solver_linear_error(1.0, 1.0, 1.0), [-1, 3]) 

 

 

@pytest.mark.parametrize("atol", (1.0, [1.0])) 

def test_solver_linear_error_from_integration(atol): 

    class Dummy: 

        def with_units(self, value, key): 

            return value 

    integr = Dummy() 

    integr.yout = np.array([1.0]).reshape((1, 1, 1)) 

    print(integr.yout[slice(None), 0, 0]) 

    integr.info = {'rtol': 1.0, 'atol': atol} 

    integr.rd = Dummy() 

    integr.rd.logy = False 

    assert np.allclose(solver_linear_error_from_integration(integr), 

                       [[-1], [3]])