-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d46817c
commit 06a98fb
Showing
3 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |