Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/Unit_Tests.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 10 additions & 3 deletions tests/test_Combined_Solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import yroots as yr
import yroots.ChebyshevSubdivisionSolver as ChebyshevSubdivisionSolver
import pytest
from pathlib import Path

# These are tests from Combined

Expand Down Expand Up @@ -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])
Expand All @@ -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)
Expand Down Expand Up @@ -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
assert box.__contains__(root) == True