Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix markdown and jupyter generation #50

Merged
merged 4 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/update-pychaste-tutorials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Download pychaste-tutorials markdown
- name: Download pychaste-tutorials-markdown
uses: actions/download-artifact@v3
with:
name: pychaste-tutorials markdown
name: pychaste-tutorials-markdown

- name: Checkout website repository
uses: actions/checkout@v4
Expand Down
105 changes: 47 additions & 58 deletions doc/tutorials/TestCellSortingTutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
"cells": [
{
"cell_type": "markdown",
"id": "296c5d00",
"metadata": {},
"source": [
"This tutorial is automatically generated from the file test/python/cell_based/tutorials/TestCellSortingTutorial.py.\n",
"This tutorial is automatically generated from the file ../test/python/cell_based/tutorials/TestCellSortingTutorial.py.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "85518493",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -22,6 +24,7 @@
},
{
"cell_type": "markdown",
"id": "425c7509",
"metadata": {},
"source": [
"\n",
Expand All @@ -37,7 +40,8 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "ad3b4b3d",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -52,6 +56,7 @@
},
{
"cell_type": "markdown",
"id": "0859ed0f",
"metadata": {},
"source": [
"## Test 1 - Cell sorting\n",
Expand All @@ -62,7 +67,8 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "914c5dbe",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -72,6 +78,7 @@
},
{
"cell_type": "markdown",
"id": "6b89b200",
"metadata": {},
"source": [
"First, we generate a `Potts` mesh. To create a `PottsMesh`, we can use the `PottsMeshGenerator`.\n",
Expand All @@ -82,7 +89,8 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "53498c64",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -92,6 +100,7 @@
},
{
"cell_type": "markdown",
"id": "55826799",
"metadata": {},
"source": [
"Having created a mesh, we now create some cells. To do this, we the `CellsGenerator` helper class,\n",
Expand All @@ -101,7 +110,8 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "83100d25",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -112,6 +122,7 @@
},
{
"cell_type": "markdown",
"id": "ab73135c",
"metadata": {},
"source": [
"Before we make a CellPopulation we make a cell label and then assign this label to some randomly chosen cells.\n",
Expand All @@ -120,7 +131,8 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "4c965778",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -132,6 +144,7 @@
},
{
"cell_type": "markdown",
"id": "63891d61",
"metadata": {},
"source": [
"Now we have a mesh and a set of cells to go with it, we can create a `CellPopulation`.\n",
Expand All @@ -140,7 +153,8 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "56507a69",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -149,6 +163,7 @@
},
{
"cell_type": "markdown",
"id": "84a90a0d",
"metadata": {},
"source": [
"In order to visualize labelled cells we need to use the following command.\n",
Expand All @@ -157,7 +172,8 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "46963d23",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -166,6 +182,7 @@
},
{
"cell_type": "markdown",
"id": "6571a038",
"metadata": {},
"source": [
"PyChaste can do simple 3D rendering with VTK. We set up a VtkScene so that we can\n",
Expand All @@ -175,19 +192,21 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "13078a02",
"metadata": {},
"outputs": [],
"source": [
"scene= chaste.visualization.VtkScene2()\n",
"scene.SetCellPopulation(cell_population)\n",
"scene.GetCellPopulationActorGenerator().SetShowPottsMeshEdges(True)\n",
"nb_manager = chaste.visualization.JupyterNotebookManager()\n",
"#nb_manager.vtk_show(scene, height=600)"
"nb_manager.vtk_show(scene, height=600)"
]
},
{
"cell_type": "markdown",
"id": "73bf51b5",
"metadata": {},
"source": [
"We then pass in the cell population into an `OffLatticeSimulation`, and set the output directory and end time\n",
Expand All @@ -196,7 +215,8 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"id": "4c4b7723",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -208,6 +228,7 @@
},
{
"cell_type": "markdown",
"id": "9a2f7393",
"metadata": {},
"source": [
"We must now create one or more update rules, which determine the Hamiltonian in the Potts simulation.\n",
Expand All @@ -219,7 +240,8 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "4e6905d0",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -231,6 +253,7 @@
},
{
"cell_type": "markdown",
"id": "ce8333cb",
"metadata": {},
"source": [
"We repeat the process for any other update rules.\n",
Expand All @@ -239,7 +262,8 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "85b15aac",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -254,6 +278,7 @@
},
{
"cell_type": "markdown",
"id": "0c443ccd",
"metadata": {},
"source": [
"Set up plotting\n",
Expand All @@ -262,7 +287,8 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"id": "0ccc598e",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -274,6 +300,7 @@
},
{
"cell_type": "markdown",
"id": "ac2f8034",
"metadata": {},
"source": [
"To run the simulation, we call `Solve()`.\n",
Expand All @@ -282,57 +309,19 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": null,
"id": "aad50aa1",
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "Unable to convert function return value to a Python type! The signature was\n\t(self: chaste.visualization._chaste_project_PyChaste_visualization.VtkScene2) -> vtkSmartPointer<vtkRenderer>",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-15-44e7981dfade>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mscene\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mStart\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0msimulator\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSolve\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;31m# Tear down the test\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mchaste\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcell_based\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mTearDownNotebookTest\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/Code/chaste-build/projects/PyChaste/python/chaste/visualization/fortests.py\u001b[0m in \u001b[0;36mUpdateAtEndOfTimeStep\u001b[0;34m(self, cell_population)\u001b[0m\n\u001b[1;32m 179\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 180\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0moutput_format\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'png'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 181\u001b[0;31m \u001b[0mIPython\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdisplay\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdisplay\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplotting_manager\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvtk_show\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mGetVtkScene\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moutput_format\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0moutput_format\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 182\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 183\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mplotting_manager\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvtk_show\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mGetVtkScene\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moutput_format\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0moutput_format\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/Code/chaste-build/projects/PyChaste/python/chaste/visualization/fortests.py\u001b[0m in \u001b[0;36mvtk_show\u001b[0;34m(self, scene, width, height, output_format, increment)\u001b[0m\n\u001b[1;32m 132\u001b[0m \u001b[0mrenderWindow\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvtk\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvtkRenderWindow\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 133\u001b[0m \u001b[0mrenderWindow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSetOffScreenRendering\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 134\u001b[0;31m \u001b[0mrenderWindow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mAddRenderer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mscene\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mGetRenderer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 135\u001b[0m \u001b[0mrenderWindow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSetSize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwidth\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mheight\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 136\u001b[0m \u001b[0mrenderWindow\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mRender\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mTypeError\u001b[0m: Unable to convert function return value to a Python type! The signature was\n\t(self: chaste.visualization._chaste_project_PyChaste_visualization.VtkScene2) -> vtkSmartPointer<vtkRenderer>"
]
}
],
"outputs": [],
"source": [
"scene.Start()\n",
"simulator.Solve()\n",
"# Tear down the test \n",
"chaste.cell_based.TearDownNotebookTest()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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.6.9"
}
},
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 5
}
13 changes: 9 additions & 4 deletions doc/tutorials/TestCellSortingTutorial.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@

---
layout: page-full-width
title: Test Cell Sorting Tutorial
title : "Test Cell Sorting Tutorial"
summary: ""
draft: false
images: []
toc: true
layout: "single"
---
This tutorial is automatically generated from the file test/python/cell_based/tutorials/TestCellSortingTutorial.py.
[Go to the Jupyter Notebook version.]({{ site.baseurl}}/documentation/md_tutorials/TestCellSortingTutorial_nb.html)

This tutorial is automatically generated from the file ../test/python/cell_based/tutorials/TestCellSortingTutorial.py .
Note that the code is given in full at the bottom of the page.


Expand Down
Loading