diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml new file mode 100644 index 0000000..386b047 --- /dev/null +++ b/.github/workflows/python-package-conda.yml @@ -0,0 +1,33 @@ +name: Python Package using Conda +on: [push] + +jobs: + test: + name: Test python ${{ matrix.python-version }} on ${{ matrix.os }} + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest] + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: install mamba + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: CNN.yml + environment-name: CNN + - name: Install test packages + shell: bash -l {0} + run: | + pip install pytest nbconvert nbformat + - name: which python + shell: bash -l {0} + run: | + which python + - name: Test with pytest + shell: bash -l {0} + run: | + pytest .github/workflows/test_CNN_notebooks.py diff --git a/.github/workflows/test_CNN_notebooks.py b/.github/workflows/test_CNN_notebooks.py new file mode 100644 index 0000000..2480951 --- /dev/null +++ b/.github/workflows/test_CNN_notebooks.py @@ -0,0 +1,47 @@ +""" +Tests for checking that all Jupyter notebooks in repository execute without errors. +Based on https://github.com/mcullan/jupyter-actions/blob/master/test/test_notebooks.py +Leif Denby - MIT License 2021 +""" +import os +import subprocess +import pytest +from pathlib import Path + +import nbformat +from nbconvert.preprocessors import ExecutePreprocessor + +TEST_DIR = os.path.dirname(os.path.abspath(__file__)) +PARENT_DIR = os.path.join(TEST_DIR, "../") + + +def _find_notebooks(): + # Get all files included in the git repository + git_files = ( + subprocess.check_output( + "git ls-tree --full-tree --name-only -r HEAD", shell=True + ) + .decode("utf-8") + .splitlines() + ) + + # Get just the notebooks from the git files + notebooks_files = [Path(fn) for fn in git_files if fn.endswith("CNN_Volcanic_deformation_test.ipynb")] + + # remove all notebooks that haven't been checked + notebooks_files = [p for p in notebooks_files if p.parent.name != "unchecked"] + return [str(p) for p in notebooks_files] + + +@pytest.mark.parametrize("notebook_filename", _find_notebooks()) +def test_notebook(notebook_filename, html_directory="notebook-html"): + """ + Checks if an IPython notebook runs without error from start to finish. + """ + with open(notebook_filename) as f: + nb = nbformat.read(f, as_version=4) + + ep = ExecutePreprocessor(timeout=600) + + # Check that the notebook runs + ep.preprocess(nb, {"metadata": {"path": Path(notebook_filename).parent }}) diff --git a/.github/workflows/windows_python_package.yml b/.github/workflows/windows_python_package.yml new file mode 100644 index 0000000..75bfc7d --- /dev/null +++ b/.github/workflows/windows_python_package.yml @@ -0,0 +1,33 @@ +name: Python Package using Conda +on: [push] + +jobs: + test: + name: Test python ${{ matrix.python-version }} on ${{ matrix.os }} + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [windows-latest] + python-version: [3.7] + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: install mamba + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: CNN_windows.yml + environment-name: CNN + - name: Install test packages + shell: bash -l {0} + run: | + pip install pytest nbconvert nbformat + - name: which python + shell: bash -l {0} + run: | + which python + - name: Test with pytest + shell: bash -l {0} + run: | + pytest .github/workflows/test_CNN_notebooks.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2249e08 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +ConvolutionalNeuralNetworks/**/*.npz +**/.ipynb_checkpoints/ +**/__pycache__ +ConvolutionalNeuralNetworks/data/real/ +ConvolutionalNeuralNetworks/data/train_full_model/ +ConvolutionalNeuralNetworks/data/train_fully_connected_model/ +ConvolutionalNeuralNetworks/vgg16_2head.png \ No newline at end of file diff --git a/Data/README.md b/Data/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Data/Stenosis2D.mat b/Data/Stenosis2D.mat deleted file mode 100644 index 9c3c0da..0000000 --- a/Data/Stenosis2D.mat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:febc66b4ab832d3ce12547b681ea374f77f5cb59d617764d912be875cc08ca3b -size 316169595 diff --git a/Data/cylinder_nektar_t0_vorticity.mat b/Data/cylinder_nektar_t0_vorticity.mat deleted file mode 100644 index 1284373..0000000 --- a/Data/cylinder_nektar_t0_vorticity.mat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f7de5b15317b677cceaeae1fd85170b217b9e7ca2caa800c7f87bd4f4e796769 -size 1073687 diff --git a/Data/cylinder_nektar_wake.mat b/Data/cylinder_nektar_wake.mat deleted file mode 100644 index 4ac3ea7..0000000 --- a/Data/cylinder_nektar_wake.mat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:99d9e1f9da7d2dff113ff2723373237b455e2de6c6747ac681846fe86fbba3d0 -size 24081984 diff --git a/Data/heatEquation_data.mat b/Data/heatEquation_data.mat deleted file mode 100644 index 1720200..0000000 --- a/Data/heatEquation_data.mat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:21c9f316aa67c1ef9f845dd4dd9f3a7b2b2f8034807f6aa97c472bcac746377c -size 39521 diff --git a/Data/heatEquation_data_coarse.mat b/Data/heatEquation_data_coarse.mat deleted file mode 100644 index 6b2eb1f..0000000 --- a/Data/heatEquation_data_coarse.mat +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:834716e66387ff0027696f084d1b5b78da171d6ac7041c8631ae80444ebbd371 -size 1280 diff --git a/PINNs_NavierStokes_HFM.md b/PINNs_NavierStokes_HFM.md deleted file mode 100644 index b0cecc2..0000000 --- a/PINNs_NavierStokes_HFM.md +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9f58f3d9f793b330def4fecb8eb8020630e7218200f708c8f224f628c90ab39d -size 53436