From 88de086b139f69787bd9f61dbf6dda8daed4ea2a Mon Sep 17 00:00:00 2001 From: Fruzsina Agocs Date: Wed, 20 Nov 2024 13:55:25 -0700 Subject: [PATCH 1/9] Adds requirements for setting up CI --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1cc18fc --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +numpy +pytest From 8ba9773e5944667e9c7c60e890cbb6bd56165fb3 Mon Sep 17 00:00:00 2001 From: Fruzsina Agocs <19972401+fruzsinaagocs@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:07:30 -0700 Subject: [PATCH 2/9] Set up auto CI with python-package.yml --- .github/workflows/python-package.yml | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/python-package.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..00389de --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + branches: [ "main", "gh-actions-demo" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest From cb7612c91238ce9d3544cff6439ea4bb0b5dad08 Mon Sep 17 00:00:00 2001 From: Fruzsina Agocs Date: Wed, 20 Nov 2024 14:17:34 -0700 Subject: [PATCH 3/9] Fix syntax --- tests/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index 9fe6776..e65fd01 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -7,5 +7,5 @@ def test_quadroots_1(): roots = quadroots(a, b, c) x1_exact = 2.0 x2_exact = 1.0 - assert np.abs(roots[0] - x1_exact) < 1e-14 && np.abs(roots[0] - x2_exact) < 1e-14 + assert (np.abs(roots[0] - x1_exact) < 1e-14) and (np.abs(roots[1] - x2_exact)) < 1e-14 From 97a65d385307c0468fc674c841bf340c53467999 Mon Sep 17 00:00:00 2001 From: Fruzsina Agocs Date: Wed, 20 Nov 2024 14:48:53 -0700 Subject: [PATCH 4/9] Set up CI correctly --- quadutils/__init__.py | 0 quadutils/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 153 bytes quadutils/__pycache__/quadroots.cpython-310.pyc | Bin 0 -> 895 bytes quadroots.py => quadutils/quadroots.py | 0 tests/test_utils.py | 3 ++- 5 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 quadutils/__init__.py create mode 100644 quadutils/__pycache__/__init__.cpython-310.pyc create mode 100644 quadutils/__pycache__/quadroots.cpython-310.pyc rename quadroots.py => quadutils/quadroots.py (100%) diff --git a/quadutils/__init__.py b/quadutils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/quadutils/__pycache__/__init__.cpython-310.pyc b/quadutils/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..df1acae9c5f32b7c6c2dad7d1ac7e33dbb7770a6 GIT binary patch literal 153 zcmd1j<>g`k0{;-ZbP)X*L?8o3AjbiSi&=m~3PUi1CZpd>q!p<7Z~l3$dWn4@1IaY0i)Dstkijb-vkR02aTJo;9wpUH1<;JlO zQI0$aFR@onk$3`5j2%dW5M`tpdw#zedrY^x14v)bXN%he;9F3(32pES+4WEe5JbZT z5s64Y!9^m-I~cT9=z%vp4aYBPfH z&6sD~pZELA)-$cbO0HTc21%0?Wz%w3)(_eZVGWr#gg43Z5PA9q>@G(AIGMb6_`H*h zEev-PUX8fPOK*&Jlf~u8SKe5~^d#&^ Date: Wed, 20 Nov 2024 14:50:31 -0700 Subject: [PATCH 5/9] Adds quadutils to reqs --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 1cc18fc..f7833fc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ numpy pytest +quadutils From fb238836f432372ff6e7fa8351a5000739e02d27 Mon Sep 17 00:00:00 2001 From: Fruzsina Agocs Date: Wed, 20 Nov 2024 14:51:56 -0700 Subject: [PATCH 6/9] Undo add quadutils to reqs --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f7833fc..1cc18fc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,2 @@ numpy pytest -quadutils From cf82c5444bb53273dbf630edfbde4b803a1d1d56 Mon Sep 17 00:00:00 2001 From: Fruzsina Agocs Date: Wed, 20 Nov 2024 14:56:50 -0700 Subject: [PATCH 7/9] Run pytest as module --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 00389de..6a80aed 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -37,4 +37,4 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | - pytest + python -m pytest From acc2dc76d0bca262b6f14f042ab870afda9751c9 Mon Sep 17 00:00:00 2001 From: Fruzsina Agocs Date: Wed, 20 Nov 2024 15:00:47 -0700 Subject: [PATCH 8/9] Remove pycache --- quadutils/__pycache__/__init__.cpython-310.pyc | Bin 153 -> 0 bytes quadutils/__pycache__/quadroots.cpython-310.pyc | Bin 895 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 quadutils/__pycache__/__init__.cpython-310.pyc delete mode 100644 quadutils/__pycache__/quadroots.cpython-310.pyc diff --git a/quadutils/__pycache__/__init__.cpython-310.pyc b/quadutils/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index df1acae9c5f32b7c6c2dad7d1ac7e33dbb7770a6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 153 zcmd1j<>g`k0{;-ZbP)X*L?8o3AjbiSi&=m~3PUi1CZpd>q!p<7Z~l3$dWn4@1IaY0i)Dstkijb-vkR02aTJo;9wpUH1<;JlO zQI0$aFR@onk$3`5j2%dW5M`tpdw#zedrY^x14v)bXN%he;9F3(32pES+4WEe5JbZT z5s64Y!9^m-I~cT9=z%vp4aYBPfH z&6sD~pZELA)-$cbO0HTc21%0?Wz%w3)(_eZVGWr#gg43Z5PA9q>@G(AIGMb6_`H*h zEev-PUX8fPOK*&Jlf~u8SKe5~^d#&^ Date: Wed, 20 Nov 2024 16:16:00 -0700 Subject: [PATCH 9/9] created new branch with fixed code --- quadutils/quadroots.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quadutils/quadroots.py b/quadutils/quadroots.py index 5b6a2fb..beb5c82 100644 --- a/quadutils/quadroots.py +++ b/quadutils/quadroots.py @@ -21,6 +21,6 @@ def quadroots(a, b, c): Roots of the equation. """ - x1 = (-b + np.sqrt(b**2 - 4*a*c))/2*a - x2 = (-b - np.sqrt(b**2 - 4*a*c))/2*a + x1 = (-b + np.sqrt(b**2 - 4*a*c))/(2*a) + x2 = (-b - np.sqrt(b**2 - 4*a*c))/(2*a) return (x1, x2)