# Path: celerite/terms.py
# @property
# def terms(self):
#     """A list of all the terms included in a sum of terms"""
#     return [self]


import pytest
import numpy as np
from itertools import product
from celerite import terms
        coeffs = np.concatenate(k.coefficients)

        v[i] = pval - eps
        k.set_parameter_vector(v)
        coeffs -= np.concatenate(k.coefficients)

        jac0[i] = 0.5 * coeffs / eps
        v[i] = pval
    assert np.allclose(jac, jac0)

@pytest.mark.parametrize(
    "k",
    [
        terms.JitterTerm(log_sigma=0.5),
        terms.RealTerm(log_a=0.5, log_c=0.1),
        terms.RealTerm(log_a=0.5, log_c=0.1) + terms.JitterTerm(log_sigma=0.3),
        terms.JitterTerm(log_sigma=0.5) + terms.JitterTerm(log_sigma=0.1),
    ]
)
def test_jitter_jacobian(k, eps=1.34e-7):
    if not terms.HAS_AUTOGRAD:
        with pytest.raises(ImportError):
            jac = k.get_jitter_jacobian()
        return

    v = k.get_parameter_vector()
    jac = k.get_jitter_jacobian()
    assert len(jac) == len(v)
    jac0 = np.empty_like(jac)
    for i, pval in enumerate(v):

# Path: celerite/terms.py
# @property
# def terms(self):
#     """A list of all the terms included in a sum of terms"""
#     return [self]


# Path: tests/test_terms.py
import pytest
import numpy as np
from itertools import product
from celerite import terms

        coeffs = np.concatenate(k.coefficients)

        v[i] = pval - eps
        k.set_parameter_vector(v)
        coeffs -= np.concatenate(k.coefficients)

        jac0[i] = 0.5 * coeffs / eps
        v[i] = pval
    assert np.allclose(jac, jac0)

@pytest.mark.parametrize(
    "k",
    [
        terms.JitterTerm(log_sigma=0.5),
        terms.RealTerm(log_a=0.5, log_c=0.1),
        terms.RealTerm(log_a=0.5, log_c=0.1) + terms.JitterTerm(log_sigma=0.3),
        terms.JitterTerm(log_sigma=0.5) + terms.JitterTerm(log_sigma=0.1),
    ]
)
def test_jitter_jacobian(k, eps=1.34e-7):
    if not terms.HAS_AUTOGRAD:
        with pytest.raises(ImportError):
            jac = k.get_jitter_jacobian()
        return

    v = k.get_parameter_vector()
    jac = k.get_jitter_jacobian()
    assert len(jac) == len(v)
    jac0 = np.empty_like(jac)
    for i, pval in enumerate(v):

        v[i] = pval + eps