diff --git a/.github/workflows/Unit_Tests.yml b/.github/workflows/Unit_Tests.yml new file mode 100644 index 00000000..3d57fb53 --- /dev/null +++ b/.github/workflows/Unit_Tests.yml @@ -0,0 +1,33 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Unit_Tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Test with pytest + run: | + pytest tests --ignore=tests/_old_unit_tests diff --git a/tests/test_Combined_Solver.py b/tests/test_Combined_Solver.py index aade17a5..f685a34f 100644 --- a/tests/test_Combined_Solver.py +++ b/tests/test_Combined_Solver.py @@ -2,6 +2,7 @@ import yroots as yr import yroots.ChebyshevSubdivisionSolver as ChebyshevSubdivisionSolver import pytest +from pathlib import Path # These are tests from Combined @@ -222,6 +223,12 @@ def test_exact_option(): We find the roots using the exact method and non-exact method. Then we make sure we got the same roots between the two, and that those roots are correct. """ + + THIS_DIR = Path(__file__).resolve().parent # .../tests + ROOT_DIR = THIS_DIR.parent # repo root (if tests/ is at root) + actual_roots_path = ROOT_DIR / "Polished_results" / "polished_2.3.npy" + chebfun_roots_path = ROOT_DIR / "Chebfun_results" / "test_roots_2.3.csv" + f = lambda x,y: np.sin(4*(x + y/10 + np.pi/10)) g = lambda x,y: np.cos(2*(x-2*y+ np.pi/7)) a,b = np.array([-1,-1]),np.array([1,1]) @@ -230,8 +237,8 @@ def test_exact_option(): yroots_non_exact = yr.solve(funcs,a,b,exact=False) yroots_exact = yr.solve(funcs,a,b,exact=True) - actual_roots = np.load('../Polished_results/polished_2.3.npy') - chebfun_roots = np.loadtxt('../Chebfun_results/test_roots_2.3.csv', delimiter=',') + actual_roots = np.load(actual_roots_path) + chebfun_roots = np.loadtxt(chebfun_roots_path, delimiter=',') assert len(yroots_non_exact) == len(actual_roots) assert len(yroots_exact) == len(actual_roots) @@ -275,4 +282,4 @@ def testoutside_neg1_pos1(): yroots, boxes = yr.solve(funcs, a, b, returnBoundingBoxes=True) for root, box in zip(yroots,boxes): box = ChebyshevSubdivisionSolver.TrackedInterval(box) - assert box.__contains__(root) == True \ No newline at end of file + assert box.__contains__(root) == True