Skip to content

Commit 20d770e

Browse files
authored
Merge pull request #28 from ese-msc/release
release
2 parents e474b1c + f3f8f8b commit 20d770e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2223
-1829
lines changed

LICENSE

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Copyright 2022, Imperial College London
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Introduction to Python
22

3-
Welcome to **Introduction to Python**! Python is one of the most popular and powerful programming languages. It is used extensively in computational and data science, and you will use it in almost all modules during your MSc studies. This self-guided course will help you to learn the basics of Python before your MSc journey.
3+
Welcome to **Introduction to Python**! Python is one of the most popular and powerful programming languages. It is used extensively in computational and data science, and you will use it in almost all modules during your MSc studies. This self-guided course will help you to learn the basics of Python.
4+
5+
This course consists of four lectures (1, 2, 3, and 4), and we strongly recommend completing them in that order.
46

57
## How to run this course
68

7-
There are three possibilities for how you can learn Python with our self-guided course. **JupyterHub** and **Binder** options allow you to run tutorials in the cloud - you do not need to install anything, and no files will be created on your machine. All you need is a web browser and internet connection. However, you need to download Jupyter notebooks you worked in to ensure your work is not lost at the end of each session. The third option is to create a small Python environment and run all tutorials on your machine. There is no difference in what you will learn, and we give you complete freedom to choose how you want to run tutorials.
9+
There are three possibilities for how you can learn Python with our self-guided course. **JupyterHub** and **Binder** options allow you to run tutorials in the cloud - you do not need to install anything, and no files will be created on your machine. All you need is a web browser and internet connection. However, you need to download Jupyter notebooks you worked in to ensure your work is not lost at the end of each session. The third option is to create a Python environment and run all tutorials on your machine. There is no difference in what you will learn, and we give you complete freedom to choose how you want to run tutorials.
810

911
### 1. JupyterHub (ESE students)
1012

11-
1. **Create a GitHub account**. In the email you received, we sent you the unique username we generated for you. Create a GitHub account and make sure your GitHub account uses that username.
13+
1. **Create a GitHub account**. In the email you received, we sent you your unique username. Create a GitHub account and make sure your GitHub account uses that username.
1214

1315
2. **Login to JupyterHub**. By clicking the following badge, you can access our JupyterHub server and log in using the GitHub account you just created:
1416

@@ -31,30 +33,31 @@ You can access Binder by clicking on the *Binder badge*:
3133
1. **Install Git**. Please follow installation instructions for your operating system on [Git webpage](https://git-scm.com/).
3234

3335
2. **Clone repository**. In Terminal (Linux and MacOS) or Command Prompt (Windows), navigate to the location where you want the course files to be and run
34-
```
36+
```console
3537
$ git clone https://github.com/ese-msc/introduction-to-python
3638
```
37-
1. **Install Anaconda**. We recommend installation using conda package manager. If you do not already have it installed, download [Anaconda](https://www.anaconda.com/products/individual) Python 3 for your operating system and follow the instructions to install it. After the installation is complete, in Terminal (Linux and MacOS) or Anaconda Prompt (Windows), navigate to the course directory, create a new conda environment, and activate it:
38-
```
39+
3. **Install Anaconda**. We recommend installation using conda package manager. If you do not already have it installed, download [Anaconda](https://www.anaconda.com/products/individual) Python 3 for your operating system and follow the instructions to install it. After the installation is complete, in Terminal (Linux and MacOS) or Anaconda Prompt (Windows), navigate to the course directory, create a new conda environment, and activate it:
40+
```console
3941
$ cd path/to/course/directory
4042
$ conda env create -f environment.yml
4143
$ conda activate introduction-to-python
4244
```
43-
4445
4. **Open Jupyter Notebook**. In the environment you just activated, run:
45-
```
46+
```console
4647
$ jupyter notebook &
4748
```
4849

4950
## Testing
5051

51-
In lectures, after (almost) each exercise, you will notice that there are two cells containing some code. In these cells, we test your solution using two different testing packages:
52+
After (almost) each exercise, there are two cells containing some code. In those cells, we test your solution using two different testing packages:
5253

5354
1. **PyBryt** analyses your solution and provides you feedback on what is correct in your implementation, as well as what might be wrong. Please read PyBryt's feedback carefully and address the `ERROR` messages by modifying your solution.
5455
2. **okpy** validates your final solution and provides you a mark for it.
5556

5657
It is important to follow the instructions for each exercise exactly and do not change the names of variables, functions, or classes so that tests can analyse your code. Besides, please do not change the content of any of the testing cells.
5758

59+
Although **PyBryt** provides much more detailed feedback, it is possible it complains about your code even though **okpy** confirms your code is correct. This is because PyBryt testing is based on comparing your solution to reference solutions. Since there is virtually an infinite number of alternative solutions, it is possible that your solution is not in our references. On the other hand, **okpy** looks at the final result of your code and if **okpy** is happy with your result, your code is correct and you do not have to address **PyBryt**'s error messages (if any).
60+
5861
## Support
5962

6063
**We encourage questions!** If you require support, have questions, want to report a bug, or want to suggest an improvement, please raise an issue in the [course repository](https://github.com/ese-msc/introduction-to-python).
@@ -63,7 +66,7 @@ It is important to follow the instructions for each exercise exactly and do not
6366
> **A:** Open an issue in this repository. This is a safe, respectful space to ask questions and open issues.
6467
6568
> **Q:** I've never opened an issue. How do I do it?
66-
> **A:** Click the `Issues` tab next to top of the page, then click the green `New Issue` button. Ask your question in the title and comment fields, then click `Submit new issue`. Congratulations, you submitted your question! We will try to get back to you shortly. Tip: If you provide [helpful and detailed info](https://fangohr.github.io/computing/smartquestion.html), it is easier for us to understand your question.
69+
> **A:** Click the `Issues` tab next to top of the page, then click the green `New Issue` button. Ask your question in the title and comment fields, then click `Submit new issue`. Congratulations, you submitted your question! We will try to get back to you shortly.
6770
6871
> **Q:** How can I see if somebody else had the same or similar question?
6972
> **A:** When you click the `Issues` tab next to top of the page, you can see all issues that are currently open and are being addressed. In addition to them, you can also check the issues that have been resolved in [closed issues](https://github.com/ese-msc/introduction-to-python/issues?q=is%3Aissue+is%3Aclosed).

environment.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# Testing libraries (nbval, flake8, and flake8-nb)
2-
# are not considered dependencies. They are pip-installed
3-
# separately on CI.
1+
# Testing packages (nbval, flake8, and flake8-nb) are not considered
2+
# dependencies. They are pip-installed on CI.
43

54
name: introduction-to-python
65

@@ -9,14 +8,11 @@ channels:
98

109
dependencies:
1110
- pip
12-
- python=3.8 # Python 3.9 also works, but we are being a bit conservative here.
11+
- python=3.9 # Python 3.10 expected to work as well, but we are being conservative here.
1312
- pip:
14-
- jupyter
13+
- jupyterlab
1514
- numpy
1615
- matplotlib
1716
- pendulum
1817
- okpy
19-
- pybryt>=0.1.8
20-
- ipykernel==5.5.5
21-
# There is a conflict between pybryt and ipykernel>=6.0.0 (released 2 July 2021).
22-
# Because of that, we fix ipykernel version until version 6.* matures.
18+
- pybryt>=0.7.0

index.ipynb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5+
"metadata": {},
56
"source": [
67
"# Introduction to Python\n",
78
"\n",
8-
"Welcome to **Introduction to Python**! Python is one of the most popular and powerful programming languages. It is used extensively in computational and data science, and you will use it in almost all modules during your MSc studies. This self-guided course will help you to learn the basics of Python before your MSc journey.\n",
9+
"Welcome to **Introduction to Python**! Python is one of the most popular and powerful programming languages. It is used extensively in computational and data science, and you will use it in almost all modules during your MSc studies. This self-guided course will help you to learn the basics of Python.\n",
910
"\n",
1011
"## Lectures\n",
1112
"\n",
12-
"This course consists of the four lectures:\n",
13+
"This course consists of four lectures:\n",
1314
"\n",
1415
"* [Lecture 1](./lecture1/lecture1.ipynb)\n",
1516
"* [Lecture 2](./lecture2/lecture2.ipynb)\n",
@@ -20,13 +21,15 @@
2021
"\n",
2122
"## Testing\n",
2223
"\n",
23-
"In lectures, after (almost) each exercise, you will notice that there are two cells containing some code. In these cells, we test your solution using two different testing packages:\n",
24+
"After (almost) each exercise, there are two cells containing some code. In those cells, we test your solution using two different testing packages:\n",
2425
"\n",
2526
"1. **PyBryt** analyses your solution and provides you feedback on what is correct in your implementation, as well as what might be wrong. Please read PyBryt's feedback carefully and address the `ERROR` messages by modifying your solution.\n",
2627
"2. **okpy** validates your final solution and provides you a mark for it.\n",
2728
"\n",
2829
"It is important to follow the instructions for each exercise exactly and do not change the names of variables, functions, or classes so that tests can analyse your code. Besides, please do not change the content of any of the testing cells.\n",
2930
"\n",
31+
"Although **PyBryt** provides much more detailed feedback, it is possible it complains about your code even though **okpy** confirms your code is correct. This is because PyBryt testing is based on comparing your solution to reference solutions. Since there is virtually an infinite number of alternative solutions, it is possible that your solution is not in our references. On the other hand, **okpy** looks at the final result of your code and if **okpy** is happy with your result, your code is correct and you do not have to address **PyBryt**'s error messages (if any).\n",
32+
"\n",
3033
"## Support\n",
3134
"\n",
3235
"**We encourage questions!** If you require support, have questions, want to report a bug, or want to suggest an improvement, please raise an issue in the [course repository](https://github.com/ese-msc/introduction-to-python).\n",
@@ -35,14 +38,13 @@
3538
"> **A:** Open an issue in this repository. This is a safe, respectful space to ask questions and open issues.\n",
3639
"\n",
3740
"> **Q:** I've never opened an issue. How do I do it? \n",
38-
"> **A:** Click the `Issues` tab next to top of the page, then click the green `New Issue` button. Ask your question in the title and comment fields, then click `Submit new issue`. Congratulations, you submitted your question! We will try to get back to you shortly. Tip: If you provide [helpful and detailed info](https://fangohr.github.io/computing/smartquestion.html), it is easier for us to understand your question.\n",
41+
"> **A:** Click the `Issues` tab next to top of the page, then click the green `New Issue` button. Ask your question in the title and comment fields, then click `Submit new issue`. Congratulations, you submitted your question! We will try to get back to you shortly.\n",
3942
"\n",
4043
"> **Q:** How can I see if somebody else had the same or similar question? \n",
4144
"> **A:** When you click the `Issues` tab next to top of the page, you can see all issues that are currently open and are being addressed. In addition to them, you can also check the issues that have been resolved in [closed issues](https://github.com/ese-msc/introduction-to-python/issues?q=is%3Aissue+is%3Aclosed).\n",
4245
"\n",
4346
"Are you a community member that enjoys sharing your knowledge and helping others solve problems? We encourage you to respond to these issues."
44-
],
45-
"metadata": {}
47+
]
4648
}
4749
],
4850
"metadata": {
@@ -66,4 +68,4 @@
6668
},
6769
"nbformat": 4,
6870
"nbformat_minor": 5
69-
}
71+
}

lecture1/lecture.py

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,51 @@
1-
import os
21
import pybryt
2+
import pathlib
33
from client.api.notebook import Notebook
44
from client.api import assignment
55

6-
args = assignment.Settings(
7-
server='clewolffautook21.eastus.cloudapp.azure.com/okpy')
8-
ok = Notebook('./lecture.ok', args)
6+
# OkPy settings
7+
args = assignment.Settings(server="clewolffautook21.eastus.cloudapp.azure.com/okpy")
8+
ok = Notebook("./lecture.ok", args)
99

1010

1111
def pybryt_reference(lecture, exercise):
12-
basename = os.path.join('pybryt-references',
13-
f'exercise-{lecture}_{exercise}')
14-
pyfilename = f'{basename}.py'
15-
pklfilename = f'{basename}.pkl'
12+
"""Function for obtaining the ``.pkl`` PyBryt reference.
1613
17-
if os.path.isfile(pyfilename):
18-
pybryt.ReferenceImplementation.compile(pyfilename).dump(pklfilename)
19-
elif not os.path.isfile(pklfilename):
20-
raise FileNotFoundError('Reference pkl file does not exists.')
14+
If ``.py`` reference is present, it is compiled (and existing ``.pkl``
15+
reference overwritten). Otherwise, an existing ``.pkl`` file is returned.
2116
22-
return pklfilename
17+
Parameters
18+
----------
19+
lecture: int
20+
21+
Lecture number.
22+
23+
exercise: int
24+
25+
Exercise number.
26+
27+
Returns
28+
-------
29+
pathlib.Path
30+
31+
``.pkl`` file path.
32+
33+
Raises
34+
------
35+
FileNotFoundError
36+
37+
Neither ``.py`` nor ``.pkl`` files exist.
38+
39+
"""
40+
dirname = pathlib.Path("pybryt-references")
41+
basename = f"exercise-{lecture}_{exercise}"
42+
pyfilename = dirname / f"{basename}.py"
43+
pklfilename = dirname / f"{basename}.pkl"
44+
45+
if pyfilename.is_file():
46+
pybryt.ReferenceImplementation.compile(str(pyfilename)).dump(str(pklfilename))
47+
elif not pklfilename.is_file():
48+
msg = f"PyBryt reference {pklfilename!r} not found."
49+
raise FileNotFoundError(msg)
50+
51+
return str(pklfilename)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy