Skip to content

Commit 20052a9

Browse files
committed
Refinements following initial feedback; add AI tooling
1 parent 2216cb5 commit 20052a9

File tree

11 files changed

+456
-61
lines changed

11 files changed

+456
-61
lines changed

img/linter.png

-34 KB
Binary file not shown.

img/numpy-versions.png

25.9 KB
Loading

img/tdd.png

16.5 KB
Loading

modules/collaborative-coding.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class: "gap-4"
9292
- Cost-effective error removal
9393
- Enhances team learning and collaboration
9494
- Improves overall team software development process
95+
- Increasingly, AI 'reviewers' are able to check your code for common issues, _but_ human review is still essential to provide context and understanding
9596

9697
::right::
9798

modules/continuous-integration.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,6 @@ layout: instruction
142142

143143
::left::
144144

145-
<div class="text-sm">
146-
<i>Example:</i>
147-
</div>
148-
149-
<div class="text-sm w-full max-w-[80%] mx-auto leading-none table-tight">
150-
151-
| | ubuntu | windows | macos |
152-
|--|:--:|:--:|:--:|
153-
| python 3.9 ||||
154-
| python 3.10 ||||
155-
| python 3.11 ||||
156-
| python 3.12 ||||
157-
158-
<div class="h-5" />
159-
160-
</div>
161145

162146
```yaml
163147
jobs:
@@ -166,22 +150,39 @@ jobs:
166150
strategy:
167151
matrix:
168152
os: [ubuntu-latest, windows-latest, macos-latest]
169-
python-version: [3.9, 3.10, 3.11, 3.12]
153+
python-version: ["3.9", "3.10", "3.11", "3.12"]
154+
steps:
155+
- uses: actions/checkout@v4
156+
- name: Set up Python ${{ matrix.python-version }}
157+
uses: actions/setup-python@v4
158+
with:
159+
python-version: ${{ matrix.python-version }}
170160
```
171161
172-
<div class="absolute border border-gray-400 left-85 top-90">
162+
and
163+
173164
```yaml
174-
on:
175-
workflow_dispatch:
165+
- name: Install dependencies
166+
shell: bash # add this line
167+
run: |
176168
```
177-
</div>
178169
179170
::right::
180171
181-
Task:
182172
- Add test matrix
183-
- Add `workflow_dispatch` trigger to your workflow (this allows you to run the action manually)
184-
- Re-run your tests
173+
174+
_Example_
175+
176+
<div class="text-sm w-full max-w-[80%] mx-auto leading-none table-tight">
177+
178+
| | ubuntu | windows | macos |
179+
|--|:--:|:--:|:--:|
180+
| python 3.9 | ❌ | ❌ | ❌ |
181+
| python 3.10 | ✅ | ❌ | ✅ |
182+
| python 3.11 | ✅ | ❌ | ✅ |
183+
| python 3.12 | ✅ | ❌ | ✅ |
184+
185+
</div>
185186
186187
<!-- You now have the foundation of any Python package! -->
187188

modules/dependency-management.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ rightClass: "items-center justify-center gap-10"
5555
<small>(year.month)</small>
5656
</div>
5757

58+
<!---
59+
- Explain major, minor, patch version numbers here
60+
- Explain calendar versioning
61+
- Explain why we would use one over the other
62+
-->
63+
5864
---
5965
layout: two-cols-header
6066
---
@@ -101,16 +107,27 @@ def main():
101107
**numpy** is a top-20 downloaded package on PyPI<br>
102108
which in June 2024 released a new major version.
103109

110+
<v-click>
111+
104112
Numpy v1 and v2 were no longer entirely compatible.
105113

114+
</v-click>
115+
116+
<v-click>
117+
106118
The official release notes included the phrase:
107119

108-
_“This major release includes <span v-mark.circle.red="1">breaking changes</span>…<br>
109-
including an ABI break …<br>
110-
and API changes …”_
120+
_“This major release includes <span v-mark.circle.red="3">breaking changes</span>…<br>
121+
including API changes …”_
122+
123+
</v-click>
111124

112125
<!--
113-
In the example given an informative error is provided to the user. However, some changes may be more surruptitious, such as rules over type promotion (float32 may be returned instead of float64 now when mixing types in expressions).
126+
In the example given an informative error is provided to the user. However, some changes may be more surreptitious, such as rules over type promotion (float32 may be returned instead of float64 now when mixing types in expressions).
127+
128+
API = Application Programming Interface, the function signature, how you interact with the library.
129+
130+
Code written in one major may not work in another major version. How do we manage old and new codebases that rely on different versions of the same library?
114131
-->
115132

116133
::

modules/github.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,18 @@ Create a new repository, clone and push changes
191191

192192
::right::
193193

194+
::small
195+
194196
Instructor follow-along:
195197

196198
- Create a new repository (Github interface)
197199
- Add a README.md, .gitignore and select a license
198-
- Open the repository in Codespaces
199-
- This mimics `git clone` on your local machine (see <Link to="reference-material" title="Reference material" />)
200-
- Add a file, stage and commit
201-
- Push changes to Github: `git push`
202-
- Explore commit history (Github interface)
203-
- (Optional) Practice creating and pushing a new branch
200+
- Open the repository in Codespaces (this mimics `git clone` on your local machine, see <Link to="reference-material" title="Reference material" />)
201+
- Add a file, stage and commit
202+
- Push changes to Github: `git push`
203+
- On the Github interface:
204+
- Explore the commit history
205+
- Create an Issue and assign yourself to work on it
206+
- (Optional) Create and push a new branch from codespaces, then switch between branches on Github
207+
208+
::

modules/testing.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,39 +282,65 @@ transition: "none"
282282
::center
283283

284284
<v-click>
285-
<i>
286285
When working with a <b>legacy</b> codebase,
287286
<br />start with a few <b>regression tests</b> to ensure
288287
<br />that the output is not changing.
289-
</i>
290288
</v-click>
291289

292290
<br />
293291

294292
<v-click>
295-
<i>
296293
<br />Then, start adding <b>unit tests</b> for
297294
<br />new features or bug fixes.
298-
</i>
295+
</v-click>
296+
297+
---
298+
transition: "none"
299+
---
300+
301+
# Automated Testing
302+
303+
<div class="text-gray-400">
304+
<b>Unit tests</b>: Test specific units of functionality, ensuring expected outputs from given inputs.
305+
306+
<b>Integration (functional) tests</b>: Test functional paths through the code, especially useful for exposing faults in unit interactions.
307+
</div>
308+
309+
<b>Regression tests</b>: Ensure unchanged program output despite code modifications.
310+
311+
::center
312+
313+
<br />When working with <b>AI</b>, verify the code
314+
<br />behaves as expected with <b>tests</b>.
315+
316+
<v-click>
317+
<br />When relying heavily on AI,
318+
<br />allow it to write <i><b>either</b></i> code <b><i>or</i></b> some tests.
319+
<br />Not both - this defeats the purpose of testing!
299320
</v-click>
300321

301322
::
302323

324+
<!--
325+
AI-generated tests can be trivial or miss important edge cases
326+
-->
327+
303328
---
304329

305330
# PyTest
306331

307332
pytest: a framework for automated testing
308333
- Automatically finds any function starting in `test_` or ends in `_test`
309334
- Produces a report indicating test status
310-
- Many advanced features (e.g. mocks, fixtures)
335+
- Many advanced features (e.g. exception testing, mocks, fixtures)
311336
- Install with `pip install pytest`
312337
- Run with `pytest` (or `pytest -v` for an itemised view)
313338

314339
Testing investment should match the software's complexity and usage
315340

316341
<!--
317-
PyTest provides a convenient report across all tests
342+
Rather than managing tests manually, PyTest provides a convenient package to collate
343+
and run tests across a codebase, producing a reports with their status.
318344
-->
319345

320346
---

modules/version-control.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ routeAlias: "version-control"
88

99
::left::
1010

11+
<div class="h-5" />
12+
1113
- *Version control* provides a full history of your project's software and other assets
1214
- Makes for easy:
1315
- Backups
@@ -36,7 +38,7 @@ routeAlias: "version-control"
3638
whatever else you might be doing with a computer,<br>
3739
it’s not science."</i><br>
3840
<br>
39-
Greg Wilson, SWC
41+
Greg Wilson, SWC<br/><div style="font-size: 0.8rem;"><i>First Executive Director of Software Carpentry</i></div>
4042

4143
::
4244

0 commit comments

Comments
 (0)