diff --git a/polyrat/aaa.py b/polyrat/aaa.py index 585f6f1..3a2fb19 100644 --- a/polyrat/aaa.py +++ b/polyrat/aaa.py @@ -130,6 +130,9 @@ def __init__(self, degree = None, tol = None, verbose = True): self.tol = tol self.verbose = verbose + if self.degree is None and self.tol is None: + self.tol = 1e-12 + def fit(self, X, y): X = np.array(X) self.y = np.array(y) diff --git a/tests/test_aaa.py b/tests/test_aaa.py index 36266a6..a9b8556 100644 --- a/tests/test_aaa.py +++ b/tests/test_aaa.py @@ -1,6 +1,6 @@ import numpy from polyrat.aaa import * - +import pytest def eval_aaa_slow(xeval, x, y, I, b): reval = [] @@ -56,7 +56,8 @@ def test_eval_aaa(): def test_aaa(): - + r""" Functionality testing + """ M = int(1e2) x = np.linspace(-1,1, M).reshape(-1,1) y = np.abs(x).flatten() @@ -67,6 +68,25 @@ def test_aaa(): I, b = aaa(x, y, degree = 10) # Use matrix valued data + Y = np.vstack([y for i in range(5)]).T + I, b = aaa(x, Y, degree = 10) + + +@pytest.mark.parametrize("M", [1000]) +@pytest.mark.parametrize("degree", [5, 10, None]) +@pytest.mark.parametrize("tol", [1e-5, 1e-10, None]) +@pytest.mark.parametrize("verbose", [True, False]) +def test_AAARationalApproximation(M,degree, tol, verbose): + r""" Integration tests for AAARationalApproximation + """ + X = np.random.randn(M,1) + y = np.abs(X).flatten() + + aaa = AAARationalApproximation(degree= degree, tol = tol, verbose = verbose) + aaa.fit(X, y) + + res_norm = np.linalg.norm(aaa(X) - y) + print(res_norm) if __name__ == '__main__': test_eval_aaa()