Skip to content

Commit

Permalink
Merge pull request #36 from MAMBA-python/dev
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
OnnoEbbens committed Apr 10, 2024
2 parents 46c87ff + 7d1b686 commit ea662ba
Show file tree
Hide file tree
Showing 69 changed files with 1,721 additions and 19,545 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
141 changes: 64 additions & 77 deletions Exercise_notebooks/Basic/basic1_use_jupyter/use_Jupyter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
" \n",
"# Use Jupyter\n",
"\n",
"In this notebook you will learn how to use the Jupyter interface to run Python code in notebooks. This notebook covers the following topics:\n",
"In this notebook you will learn how to use the JupyterLab interface to run Python code in notebooks. This notebook covers the following topics:\n",
"\n",
"- run code\n",
"- the kernel\n",
Expand All @@ -21,7 +21,7 @@
"- keyboard shortcuts\n",
"- cell type\n",
"\n",
"The notebook can be used as a quick introduction when you start working with the Jupyter Notebook interface and as a reference to look up how to do specific tasks in Jupyter.\n",
"The notebook can be used as a quick introduction when you start working with the JupyterLa interface and as a reference to look up how to do specific tasks in Jupyter.\n",
"\n",
"<br>\n",
"<div style=\"text-align: right\"> developed by MAMBA </div>\n"
Expand All @@ -38,7 +38,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Run a code cell using `Shift-Enter` or pressing the <button class='btn btn-default btn-xs'><i class=\"icon-step-forward fa fa-step-forward\"></i></button> button in the toolbar above:"
"Run a code cell using `Shift-Enter`, by pressing the play button ![kernel](images/play_arrow.png) in the toolbar above or by selecting \"Run\" -> \"Run Selected Cells\" from the menu bar."
]
},
{
Expand Down Expand Up @@ -67,20 +67,20 @@
}
},
"source": [
"### Cell menu"
"### Run menu"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The \"Cell\" menu has a number of menu items for running code in different ways. These includes:\n",
"The \"Run\" menu has a number of items for running code cells in different ways. These includes:\n",
"\n",
"* Run and Select Below\n",
"* Run and Insert Below\n",
"* Run All\n",
"* Run All Above\n",
"* Run All Below"
"* Run Selected Cells\n",
"* Run Selected Cells and Insert Below\n",
"* Run All Above Selected Cell\n",
"* Run Selected Cell and All Below\n",
"* Run All cells"
]
},
{
Expand All @@ -102,9 +102,9 @@
"metadata": {},
"source": [
"The kernel has different states:\n",
"- <button class='kernel_idle_icon'><i class=\"kernel_idle_icon::before\"></i></button> The kernel is idle, if you run a cell the code will be run immediately.\n",
"- <button class='kernel_busy_icon'><i class=\"kernel_busy_icon::before\"></i></button> The kernel is busy, it is still running code of a previous cell. If you run a cell while the kernel is busy, you have to wait for the previous proces to finish before your cell is run. \n",
"- <button class='kernel_disconnected_icon'><i class=\"kernel_disconnected_icon::before\"></i></button> The kernel is disconnected, this can happen when you close the black 'jupyter-notebook.exe' screen. You cannot run code with a disconnected kernel.\n"
"- ![kernel](images/idle.png) The kernel is idle, if you run a cell the code will be run immediately.\n",
"- ![kernel](images/busy.png) The kernel is busy, it is still running code of a previous cell. If you run a cell while the kernel is busy, you have to wait for the previous proces to finish before your cell is run. \n",
"- ![kernel](images/disconnected.png) The kernel is disconnected, this can happen when you close the black 'jupyter-notebook.exe' screen. You cannot run code with a disconnected kernel."
]
},
{
Expand All @@ -118,14 +118,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### interrupt the kernel"
"### Interrupt the kernel"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Try running the following cell and then interrupt the kernel by clicking the <button class='btn btn-default btn-xs'><i class='icon-stop fa fa-stop'></i></button> button in the toolbar above. You should see a `KeyboardInterrupt:` error in the output area. This error indicates that the output could not be generated succesfully due to an interruption of the running proces."
"Try running the following cell and then interrupt the kernel by clicking the <i class='icon-stop fa fa-stop'></i> button in the toolbar above. You should see a `KeyboardInterrupt:` error in the output area. This error indicates that the output could not be generated succesfully due to an interruption of the running proces."
]
},
{
Expand Down Expand Up @@ -156,7 +156,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If the Kernel dies you cannot run Python code and need to restart it. This is done by clicking on the <button class='btn btn-default btn-xs'><i class='fa fa-repeat icon-repeat'></i></button> in the toolbar above. Remember that if you restart the kernel, all the assigned variables are lost. Meaning you have to rerun cells to assign the variables to their values. "
"If the Kernel dies you cannot run Python code and need to restart it. This is done by clicking on the <i class='fa fa-repeat icon-repeat'></i> in the toolbar above. Remember that if you restart the kernel, all the assigned variables are lost. Meaning you have to rerun cells to assign the variables to their values. "
]
},
{
Expand Down Expand Up @@ -196,13 +196,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"When you are working on big data sets output can become annoyingly large. To better handle large outputs, the output area can be collapsed. Run the following cell and then single- or double- click on the active area to the left of the output."
"When you are working on big data sets output can become annoyingly large. To better handle large outputs, the output area can be collapsed. Run the following cell and then click on the Blue bar the appears if you hoover left of the output area."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"for i in range(50):\n",
Expand All @@ -220,7 +222,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"There are two different modes in Jupyter notebooks: edit mode and command mode. In the edit mode you can type code in the cells. In the command mode you can make general adjustments to the notebook, e.g. copy a cell. Keyboard commands do different things depending on which mode the Notebook is in."
"There are two different modes in JupyterLab: edit mode and command mode. In the edit mode you can type code in the cells. In the command mode you can make general adjustments to the notebook, e.g. copy a cell. Keyboard commands do different things depending on which mode the Notebook is in."
]
},
{
Expand All @@ -235,20 +237,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Edit mode is indicated by a green cell border and a prompt showing in the editor area.\n",
"\n",
"![Jupyter cell with green border](images/edit_mode.png)\n",
"\n",
"When a cell is in edit mode, you can type into the cell, like a normal text editor."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-success\">\n",
"Enter edit mode by pressing `Enter` or using the mouse to click on a cell's editor area.\n",
"</div>"
"When a cell is in edit mode, you can type into the cell, like in a normal text editor. You can enter edit mode by pressing `Enter` or using the mouse to double click on a cell's editor area."
]
},
{
Expand All @@ -262,31 +251,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Command mode is indicated by a grey cell border with a blue left margin:\n",
"\n",
"![Jupyter cell with blue & grey border](images/command_mode.png)\n",
"\n",
"When you are in command mode, you are able to edit the notebook as a whole, but not type into individual cells. Most importantly, in command mode, the keyboard is mapped to a set of shortcuts that let you perform notebook and cell actions efficiently. For example, if you are in command mode and you press `c`, you will copy the current cell - no modifier is needed.\n",
"\n"
"When you are in command mode, you are able to edit the notebook as a whole, but not type into individual cells. Most importantly, in command mode, the keyboard is mapped to a set of shortcuts that let you perform notebook and cell actions efficiently. For example, if you are in command mode and you press `a`, a cell is added above the selected cell. Enter command mode by pressing `Esc` or using the mouse to click *outside* a cell's editor area."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"<div class=\"alert alert-success\">\n",
"Enter command mode by pressing `Esc` or using the mouse to click *outside* a cell's editor area.\n",
"</div>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"tags": []
},
"source": [
"#### Exercise 1<a name=\"ex1\"></a>\n",
"\n",
"Try typing `f=1` while in command mode. Can you understand what happened?"
"Try typing `b` while in command mode. Can you understand what happened?"
]
},
{
Expand All @@ -300,9 +276,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
" \n",
"__Remember: Don't try to type into a cell in command mode; unexpected things will happen!__"
" \n",
"__Remember: If you try to type into a cell while in command mode; unexpected things can happen!__"
]
},
{
Expand Down Expand Up @@ -332,17 +307,21 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"tags": []
},
"source": [
"### function help\n",
"### unction help\n",
"if you click with your cursor between the bracket's `()` below and press `Shift-tab` a window pops-up with the function help. It should look like the function below.\n",
"![kernel](images/function_help.JPG)\n",
"\n",
"In the pop-up window you can choose to use these icons:\n",
"\n",
"- <button class='ui-icon ui-icon-plus'><i class=\"ui-icon ui-icon-plus\"></i></button> to expand the pop-up window\n",
"- <button class='ui-icon ui-icon-arrowstop-l-n'><i class=\"ui-icon ui-icon-arrowstop-l-n\"></i></button> to open the help in a pop-up in the bottom of the screen.\n",
"- <button class='ui-icon ui-icon-close'><i class=\"ui-icon ui-icon-close\"></i></button> to close the pop-up window."
"<img style=\"float: left;\" src=\"images/function_help.JPG\"></img>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can try here yourself:"
]
},
{
Expand All @@ -356,7 +335,10 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"### code completion\n",
"\n",
Expand Down Expand Up @@ -402,36 +384,34 @@
"2. MarkDown\n",
"3. Raw NBConvert\n",
"\n",
"You can change the cell type in the \"Cell\" menu under \"Cell Type\". Or you can use the dropdown menu <select id=\"cell_type\" class=\"form-control select-xs\" style=\"width: auto; display: inline\"></select> in the toolbar\n",
"You can change the cell type in the toolbar <select id=\"cell_type\" class=\"form-control select-xs\" style=\"width: auto; display: inline\"></select>.\n",
"\n",
"### Code\n",
"A code cell contains Python code and can be run (`Shift-Enter`) with the kernel\n",
"\n",
"### MarkDown\n",
"A MarkDown cell contains text with code for the formatting of this text. These cells can be run (`Shift-Enter`) to display the formatted text.\n",
"\n",
"### Raw NBConvert\n",
"This is the raw display of text. When you run (`Shift-Enter`) a Raw NBConvert cell it still looks the same (so there is no need to run it). \n",
"\n",
"<small><nowiki>*</nowiki> in the drop down menu there is also the option \"Heading\". This is just a fast way to create a MarkDown cell with a heading but it is not different from a MarkDown cell</small>"
"### Raw\n",
"This is the raw display of text. When you run (`Shift-Enter`) a Raw cell it still looks the same (so there is no need to run it). "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 7. answers"
"## 7. Answers"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### answer Exercise 1 <a name=\"ans1\"></a>\n",
"#### Answer Exercise 1 <a name=\"ans1\"></a>\n",
"\n",
"If you were in command mode a 'Find and Replace' window must have popped up when you started typing. `f` is a keyboard shortcut to use 'Find and Replace' while in command mode. \n",
"If you were in command mode and typed 'b' a cell below the current cell must have appeared. `b` is a keyboard shortcut to create a new cell below the current one. This will only happen when you are in command mode. \n",
"\n",
"In this case the impact of typing in command mode is relatively small, you can simply close the 'Find and Replace' window. Some other keyboard shortcuts in command mode have a bigger impact, e.g. `x` will cut the cell and `dd` will delete the cell. There is also `z` to undo previous commands. However it is good to be aware of these modes and to remember:"
"In this case the impact of typing in command mode is relatively small, you can simply remove the new cell you created. Some other keyboard shortcuts in command mode have a bigger impact, e.g. `x` will cut the cell and `dd` will delete the cell. There is also `z` to undo previous commands. However it is good to be aware of these modes and remember to be in edit mode when you try to edit a cell."
]
},
{
Expand All @@ -445,16 +425,23 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## 8. acknowledgement\n",
"## 8. Acknowledgement\n",
"\n",
"the following sources were used to create this notebook:\n",
"The following sources were used to create this notebook:\n",
"- https://nbviewer.jupyter.org/github/jupyter/notebook/blob/master/docs/source/examples/Notebook/Running%20Code.ipynb\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -468,9 +455,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
"version": "3.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%run_pytest[clean]\n",
"%%ipytest\n",
"# Mention this at the top of cells which contain test(s)\n",
"# This is only required for running pytest in Jupyter notebooks\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions Exercise_notebooks/Intermediate/07_testing/03-testing3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%run_pytest[clean]\n",
"%%ipytest\n",
"\n",
"# These would be in test_person.py\n",
"def test_full_name(default_person): # Note: we use fixture as an argument of the test case\n",
Expand Down Expand Up @@ -164,7 +164,7 @@
"metadata": {},
"outputs": [],
"source": [
"%%run_pytest[clean]\n",
"%%ipytest\n",
"\n",
"# This would be in your test module\n",
"@pytest.mark.parametrize(\"original,new_name,expected\", [\n",
Expand Down
Loading

0 comments on commit ea662ba

Please sign in to comment.