# Licensed under a 3-clause BSD style license - see LICENSE.rst

from __future__ import (absolute_import, unicode_literals, division,
                        print_function)

from ...tests.helper import pytest

from ..core import Model
from ..models import Const1D


@pytest.mark.parametrize(('expr', 'result'),
                         [(lambda x, y: x + y, 5.0),
                          (lambda x, y: x - y, -1.0),
                          (lambda x, y: x * y, 6.0),
                          (lambda x, y: x / y, 2.0 / 3.0),
                          (lambda x, y: x ** y, 8.0)])
def test_two_model_class_arithmetic_1d(expr, result):
    # Const1D is perhaps the simplest model to test basic arithmetic with.
    # TODO: Should define more tests later on for more complicated
    # combinations of models

    S = expr(Const1D, Const1D)

    assert issubclass(S, Model)
    assert S.n_inputs == 1
    assert S.n_outputs == 1

    # Initialize an instance of the model, providing values for the two
    # "amplitude" parameters
    s = S(2, 3)

    # It shouldn't matter what input we evaluate on since this is a constant
    # function
    assert s(0) == result

@@ -257,16 +257,30 @@
  Const1D
+, Shift, Scale
 %0A%0A%0A@pyte
@@ -1175,8 +1175,577 @@
  result%0A
+%0A%0Adef test_two_model_class_compose_1d():%0A    %22%22%22%0A    Shift and Scale are two of the simplest models to test model composition%0A    with.%0A    %22%22%22%0A%0A    S1 = Shift %7C Scale  # First shift then scale%0A    assert issubclass(S1, Model)%0A    assert S1.n_inputs == 1%0A    assert S1.n_outputs == 1%0A%0A    s1 = S1(2, 3)  # Shift by 2 and scale by 3%0A    assert s1(1) == 9.0%0A%0A    S2 = Scale %7C Shift  # First scale then shift%0A    assert issubclass(S2, Model)%0A    assert S2.n_inputs == 1%0A    assert S2.n_outputs == 1%0A%0A    s2 = S2(2, 3)  # Scale by 2 then shift by 3%0A    assert s2(1) == 5.0%0A

Add a very simple test for model composition