Skip to content

Jupytext updates #80

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

Merged
merged 6 commits into from
Jun 16, 2022
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
28 changes: 10 additions & 18 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,50 +34,42 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Test complex notebooks in parallel
run: |
export PKG_CONFIG_PATH=/usr/local/dolfinx-complex/lib/pkgconfig:$PKG_CONFIG_PATH
export PETSC_ARCH=linux-gnu-complex-32
export PYTHONPATH=/usr/local/dolfinx-complex/lib/python3.9/dist-packages:$PYTHONPATH
export LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH
cd chapter1
mpirun -n 2 python3 complex_mode.py


- name: Install dependencies
run: pip3 install notebook nbconvert jupyter-book --upgrade
- name: Test notebooks in parallel
run: |
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
cd chapter1
jupyter-nbconvert --to python fundamentals_code.ipynb
mpirun -n 2 python3 fundamentals_code.py
jupyter-nbconvert --to python membrane_code.ipynb
mpirun -n 2 python3 membrane_code.py
cd ../chapter2
jupyter-nbconvert --to python diffusion_code.ipynb
mpirun -n 2 python3 diffusion_code.py
jupyter-nbconvert --to python heat_code.ipynb
mpirun -n 2 python3 heat_code.py
jupyter-nbconvert --to python linearelasticity_code.ipynb
mpirun -n 2 python3 linearelasticity_code.py
jupyter-nbconvert --to python hyperelasticity.ipynb
mpirun -n 2 python3 hyperelasticity.py
jupyter-nbconvert --to python nonlinpoisson_code.ipynb
mpirun -n 2 python3 nonlinpoisson_code.py
jupyter-nbconvert --to python ns_code1.ipynb
mpirun -n 2 python3 ns_code1.py
jupyter-nbconvert --to python ns_code2.ipynb
mpirun -n 2 python3 ns_code2.py
cd ../chapter3
jupyter-nbconvert --to python neumann_dirichlet_code.ipynb
mpirun -n 3 python3 neumann_dirichlet_code.py
jupyter-nbconvert --to python multiple_dirichlet.ipynb
mpirun -n 3 python3 multiple_dirichlet.py
jupyter-nbconvert --to python subdomains.ipynb
mpirun -n 3 python3 subdomains.py
jupyter-nbconvert --to python robin_neumann_dirichlet.ipynb
mpirun -n 3 python3 robin_neumann_dirichlet.py
jupyter-nbconvert --to python component_bc.ipynb
mpirun -n 3 python3 component_bc.py
jupyter-nbconvert --to python em.ipynb
mpirun -n 3 python3 em.py
cd ../chapter4
jupyter-nbconvert --to python solvers.ipynb
mpirun -n 3 python3 solvers.py
jupyter-nbconvert --to python convergence.ipynb
mpirun -n 3 python3 convergence.py
jupyter-nbconvert --to python compiler_parameters.ipynb
mpirun -n 3 python3 compiler_parameters.py

# Runs a single command using the runners shell
Expand Down
39 changes: 15 additions & 24 deletions .github/workflows/main-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
test-against-master:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container: dolfinx/dolfinx
container: dolfinx/lab

env:
HDF5_MPI: "ON"
Expand All @@ -45,51 +45,42 @@ jobs:
jupyter nbextension enable --py --sys-prefix ipygany
rm -rf /usr/local/share/.cache/*
jupyter-book -h
- name: Test building the book
run:
PYVISTA_JUPYTER_BACKEND=static PYVISTA_OFF_SCREEN=false jupyter-book build -W .
- name: Test notebooks in parallel
- name: Test complex notebooks in parallel
run: |
export PKG_CONFIG_PATH=/usr/local/dolfinx-complex/lib/pkgconfig:$PKG_CONFIG_PATH
export PETSC_ARCH=linux-gnu-complex-32
export PYTHONPATH=/usr/local/dolfinx-complex/lib/python3.10/dist-packages:$PYTHONPATH
export LD_LIBRARY_PATH=/usr/local/dolfinx-complex/lib:$LD_LIBRARY_PATH
cd chapter1
mpirun -n 2 python3 complex_mode.py

- name: Test real notebooks in parallel
run: |
cd chapter1
python3 -c "from pyvista import start_xvfb; start_xvfb(0.1)"
jupyter-nbconvert --to python fundamentals_code.ipynb
mpirun -n 2 python3 fundamentals_code.py
jupyter-nbconvert --to python nitsche.ipynb
mpirun -n 2 python3 nitsche.py
jupyter-nbconvert --to python membrane_code.ipynb
mpirun -n 2 python3 membrane_code.py
cd ../chapter2
jupyter-nbconvert --to python diffusion_code.ipynb
mpirun -n 2 python3 diffusion_code.py
jupyter-nbconvert --to python heat_code.ipynb
mpirun -n 2 python3 heat_code.py
jupyter-nbconvert --to python linearelasticity_code.ipynb
mpirun -n 2 python3 linearelasticity_code.py
jupyter-nbconvert --to python hyperelasticity.ipynb
mpirun -n 2 python3 hyperelasticity.py
jupyter-nbconvert --to python nonlinpoisson_code.ipynb
mpirun -n 2 python3 nonlinpoisson_code.py
jupyter-nbconvert --to python ns_code1.ipynb
mpirun -n 2 python3 ns_code1.py
jupyter-nbconvert --to python ns_code2.ipynb
mpirun -n 2 python3 ns_code2.py
cd ../chapter3
jupyter-nbconvert --to python neumann_dirichlet_code.ipynb
mpirun -n 3 python3 neumann_dirichlet_code.py
jupyter-nbconvert --to python multiple_dirichlet.ipynb
mpirun -n 3 python3 multiple_dirichlet.py
jupyter-nbconvert --to python subdomains.ipynb
mpirun -n 3 python3 subdomains.py
jupyter-nbconvert --to python robin_neumann_dirichlet.ipynb
mpirun -n 3 python3 robin_neumann_dirichlet.py
jupyter-nbconvert --to python component_bc.ipynb
mpirun -n 3 python3 component_bc.py
jupyter-nbconvert --to python em.ipynb
mpirun -n 3 python3 em.py
cd ../chapter4
jupyter-nbconvert --to python solvers.ipynb
mpirun -n 3 python3 solvers.py
jupyter-nbconvert --to python convergence.ipynb
mpirun -n 3 python3 convergence.py
jupyter-nbconvert --to python compiler_parameters.ipynb
mpirun -n 3 python3 compiler_parameters.py

- name: Test building the book
run:
PYVISTA_JUPYTER_BACKEND=static PYVISTA_OFF_SCREEN=false jupyter-book build -W .
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ _build
*.vtu
*/.ipynb_checkpoints/*
.ipynb_checkpoints/*
**/.cache
**/.cache
*.png
*.pvtu
*.msh
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog

## Dev
- Change all notebooks to use [jupytext](https://jupytext.readthedocs.io/en/latest/install.html) to automatically sync `.ipynb` with `.py` files.
- Add dummy complex mode test

## 0.4.1
- No changes

## 0.4.0 (05.02.2021)
Expand Down
1 change: 1 addition & 0 deletions _toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ parts:
- file: chapter1/fundamentals
sections:
- file: chapter1/fundamentals_code
- file: chapter1/complex_mode
- file: chapter1/nitsche
- file: chapter1/membrane
sections:
Expand Down
63 changes: 63 additions & 0 deletions chapter1/complex_mode.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "116651d1-d44d-471d-b13c-36855d8464ec",
"metadata": {},
"source": [
"# Running DOLFINx in complex mode\n",
"\n",
"Author: Jørgen S. Dokken\n",
"\n",
"This section will explain how to run DOLFINx in complex mode, and its peculiarities.\n",
"\n",
"## TODO: Add complex example"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "4d5b03e3-4d7f-45b7-95eb-9130a5141f34",
"metadata": {},
"outputs": [],
"source": [
"import dolfinx\n",
"from petsc4py import PETSc\n",
"import numpy as np\n",
"assert np.dtype(PETSc.ScalarType).kind == 'c'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "be8461a0-a089-4ff3-8bc8-61b016407e70",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"jupytext": {
"formats": "ipynb,py:light"
},
"kernelspec": {
"display_name": "Python 3 (DOLFINx complex)",
"language": "python",
"name": "python3-complex"
},
"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.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
29 changes: 29 additions & 0 deletions chapter1/complex_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.13.8
# kernelspec:
# display_name: Python 3 (DOLFINx complex)
# language: python
# name: python3-complex
# ---

# # Running DOLFINx in complex mode
#
# Author: Jørgen S. Dokken
#
# This section will explain how to run DOLFINx in complex mode, and its peculiarities.
#
# ## TODO: Add complex example

import dolfinx
from petsc4py import PETSc
import numpy as np
assert np.dtype(PETSc.ScalarType).kind == 'c'


Loading