Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement equation_of_line and setup CI testing #9

Merged
merged 3 commits into from
Jun 25, 2024
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
47 changes: 47 additions & 0 deletions .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Test suite workflow
name: Test suite

# Controls when the workflow will run
on:

# Triggers the workflow on pushes to the 'main' branch
push:
branches: ["main"]

# Triggers the workflow on pushes to pull requests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for the detailed comments. It's clear to see what each bit of the workflow yml does

pull_request:

# Enables running workflows manually from the Actions tab
workflow_dispatch:

# Details of the workflow run
jobs:

# This workflow contains a single job called 'test_suite'
test_suite:

# The type of runner the job will run on
runs-on: ubuntu-latest

# Sequence of tasks to execute in the job
steps:

# Checkout the repository
- name: Checkout code
uses: actions/checkout@v4

# Install Python 3
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the benefit of '3.x' vs '3.12' for example?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses the latest available minor release of Python 3, rather than pinning to a particular version. (See https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#using-a-specific-python-version.)


# Install dependencies of the repository
- name: Install dependencies
run: |
python3 -m pip install -r requirements.txt

# Run the tests
- name: Run tests
run: |
pytest -v
18 changes: 17 additions & 1 deletion maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,20 @@ def equation_of_line(a, b):
:arg b: the second point the line passes through
:return: function of two variables defining the line
"""
raise NotImplementedError # TODO
x0, y0 = a
x1, y1 = b

if (x0 == x1):
# Special case of a vertical line

def f(x, y):
return x - x0

else:

def f(x, y):
m = (y1 - y0) / (x1 - x0)
c = y0 - m * x0
return y - m * x - c

return f