# Path: Echobase/Common/errors.py
# def check_dims(arr, nd):
# def check_type(obj, typ):
# def check_function(obj):
# def check_path(path):
# def make_path(path):
# def check_path_overwrite(path):
# def check_has_key(dictionary, key_ref):
# 
# Path: Echobase/Sigproc/ts_surr.py
# def AAFTsur(xV, rand_phase=None):
#     T = np.argsort(xV)
#     T2 = np.argsort(yftV)


import numpy as np
from statsmodels.tsa.api import VAR
from ...Common import errors
from ...Sigproc import ts_surr
    The Granger function adapts a Granger Causality measure from statsmodels
    by fitting an autoregressive model to the data.

    See: <insert a reference or two on this>

    Parameters
    ----------
        data: ndarray, shape (T, N)
            Input signal with T samples over N variates

        lagPar: int
            Number of lags to use in the model fit

        signif_value: float
            The Type I error rate for the causality measure under an
            amplitude adjusted Fourier transform surrogate model

        n_perm: int
            Number of permutations over which to generate amplitude adjusted
            Fourier transform surrogate signals

    Returns
    -------
        adj_filter: ndarray, shape (N, N)
            Causal, adjacency matrix for N variates after permutation-based filtering
    """

    # Standard param checks
    errors.check_type(data, np.ndarray)
    errors.check_dims(data, 2)

# Path: Echobase/Common/errors.py
# def check_dims(arr, nd):
# def check_type(obj, typ):
# def check_function(obj):
# def check_path(path):
# def make_path(path):
# def check_path_overwrite(path):
# def check_has_key(dictionary, key_ref):
# 
# Path: Echobase/Sigproc/ts_surr.py
# def AAFTsur(xV, rand_phase=None):
#     T = np.argsort(xV)
#     T2 = np.argsort(yftV)


# Path: Echobase/Network/Functional/causality.py
import numpy as np
from statsmodels.tsa.api import VAR
from ...Common import errors
from ...Sigproc import ts_surr

    The Granger function adapts a Granger Causality measure from statsmodels
    by fitting an autoregressive model to the data.

    See: <insert a reference or two on this>

    Parameters
    ----------
        data: ndarray, shape (T, N)
            Input signal with T samples over N variates

        lagPar: int
            Number of lags to use in the model fit

        signif_value: float
            The Type I error rate for the causality measure under an
            amplitude adjusted Fourier transform surrogate model

        n_perm: int
            Number of permutations over which to generate amplitude adjusted
            Fourier transform surrogate signals

    Returns
    -------
        adj_filter: ndarray, shape (N, N)
            Causal, adjacency matrix for N variates after permutation-based filtering
    """

    # Standard param checks
    errors.check_type(data, np.ndarray)
    errors.check_dims(data, 2)

    errors.check_type(lagPar, int)