Skip to content

Commit

Permalink
feat: add matplotlib notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreCameron committed May 8, 2020
1 parent 49b34ff commit 2988f39
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 deletions.
6 changes: 3 additions & 3 deletions USAGE.md
Expand Up @@ -103,13 +103,13 @@ This is not the best way to put code in production but it can help out in some o

### Limits

* Only the graphic package `matplotlib.pyplot` as been tested. Use other graphic option at your on risk.
* Only the graphic package `matplotlib.pyplot` as been tested. Other graphic package may not give back the hand.

* Only python code can be executed, donnot try to use the package on notebook with julia or R.
* Only python code can be executed. The package will **not** work on julia or R notebooks.

* When executing a notebook via `boar` make sure the environment has all the package to run the notebook.

* The package has not been developped to work recursively. Use at your own risk.
* The package has not been developped to work recursively.

### Forbidden synthax

Expand Down
2 changes: 1 addition & 1 deletion notebook/00-test-tutorial.ipynb
Expand Up @@ -93,7 +93,7 @@
" test_error_str = test_path.name.replace(\".ipynb\", \"\").split(\"-\")[0]\n",
" \n",
" test_error = None\n",
" if test_error_str!=\"OK\":\n",
" if test_error_str not in [\"OK\", \"Matplotlib\"]:\n",
" temp = {}\n",
" exec(f\"error = {test_error_str}\", temp)\n",
" test_error = temp[\"error\"] \n",
Expand Down
69 changes: 69 additions & 0 deletions notebook/00-test/Matplotlib.ipynb
@@ -0,0 +1,69 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Matplotlib graph"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x_vals = np.arange(1, 10, 0.5)\n",
"y_vals = (x_vals) * (x_vals - 5) * (x_vals - 7.5) \n",
"\n",
"\n",
"plt.figure()\n",
"\n",
"plt.plot(x_vals, y_vals)\n",
"plt.scatter(x_vals, y_vals, color=\"r\", marker=\"x\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
8 changes: 6 additions & 2 deletions tests/test_testing_e2e.py
Expand Up @@ -6,10 +6,14 @@


@pytest.mark.e2e
def test_assert_notebook_runs_without_error() -> None:
@pytest.mark.parametrize("notebook_name", [
"OK.ipynb",
"Matplotlib.ipynb",
])
def test_assert_notebook_runs_without_error(notebook_name) -> None:
# Given
from boar.testing import assert_notebook
notebook_path = Path(Notebook._00.value, "OK.ipynb")
notebook_path = Path(Notebook._00.value, notebook_name)
verbose = True

# When / Then
Expand Down

0 comments on commit 2988f39

Please sign in to comment.