Skip to content

Commit

Permalink
Add summary of 2024-02-{23, 27}
Browse files Browse the repository at this point in the history
  • Loading branch information
drvinceknight committed Feb 27, 2024
1 parent d46817c commit 06a98fb
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
19 changes: 19 additions & 0 deletions _posts/2024-02-23-testing-and-latex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
layout: post
title: "Testing and LaTeX"
tags:
- testing
- writing
---

On Friday we discussed testing and writing with LaTeX

You can see a recording of the classes here:

- Automated testing: [https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=d2ca1bdf-74d8-4f75-8862-b11a00c65cd9](https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=d2ca1bdf-74d8-4f75-8862-b11a00c65cd9)
- LaTeX: [https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=f0c65427-7543-4068-9798-b11a0118b985](https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=f0c65427-7543-4068-9798-b11a0118b985)

I wrote tests for the `tsp` library. You can find the file
[here]({{site.baseurl}}/assets/nbs/2023-2024/test_tsp.py)

You can see other examples in the python for mathematics text.
11 changes: 11 additions & 0 deletions _posts/2024-02-27-research.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
layout: post
title: "Finding sources for your work"
tags:
- writing
---

On Tuesday the subject librarian Cathy Parker took our class to discuss
research, sources and plagiarism.

You can see a recording of the class here: [https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=43806a5e-f912-4561-b5df-b11e01085bf7](https://cardiff.cloud.panopto.eu/Panopto/Pages/Viewer.aspx?id=43806a5e-f912-4561-b5df-b11e01085bf7).
61 changes: 61 additions & 0 deletions assets/nbs/2023-2024/test_tsp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import numpy as np
import matplotlib.pyplot as plt

import tsp


def test_get_tour_with_no_seed():
number_of_stops = 4
tour = tsp.get_tour(number_of_stops=number_of_stops)
assert tour == [0, 1, 2, 3, 0], f"The value of tour is {tour}"


def test_get_tour_with_no_seed_and_6_stops():
number_of_stops = 6
tour = tsp.get_tour(number_of_stops=number_of_stops)
assert tour == [0, 1, 2, 3, 4, 5, 0], f"The value of tour is {tour}"



def test_get_tour_with_seed_5_and_6_stops():
number_of_stops = 6
seed = 5
tour = tsp.get_tour(number_of_stops=number_of_stops, seed=seed)
assert len(tour) == number_of_stops + 1
assert tour == [0, 5, 1, 2, 3, 4, 0], f"The value of tour is {tour}"


def test_get_tour_with_seed_10_and_6_stops():
number_of_stops = 6
seed = 10
tour = tsp.get_tour(number_of_stops=number_of_stops, seed=seed)
assert len(tour) == number_of_stops + 1
assert tour == [0, 3, 4, 1, 5, 2, 0], f"The value of tour is {tour}"

def test_swap_cities():
tour = [0, 1, 3, 2, 4, 0]
steps = 4, 1
new_tour = tsp.swap_cities(tour=tour, steps=steps)
assert new_tour == [0, 4, 2, 3, 1, 0], f"Obtained tour was: {new_tour}"


def test_plot_tour():
"""
This tests the plotting functionality.
NOTE it only tests that the code is run and no unexpected output or
errors are raised
"""
x = np.array((2, 3))
y = np.array((2, 3))
tour = np.array((0, 1, 0))
plot = tsp.plot_tour(tour=tour, x=x, y=y)
assert plot is None


test_get_tour_with_no_seed()
test_get_tour_with_no_seed_and_6_stops()
test_get_tour_with_seed_5_and_6_stops()
test_get_tour_with_seed_10_and_6_stops()
test_swap_cities()
test_plot_tour()

0 comments on commit 06a98fb

Please sign in to comment.