From 50dcc4e11355ddd960056bb108336a6f0a936b6f Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sat, 9 Sep 2023 12:47:42 +0530 Subject: [PATCH 01/32] Create `docker.yml` --- .github/workflows/docker.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000..e69de29bb2 From 0fc448013d2cf41fc985238825ef5b5ce646de9a Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sun, 10 Sep 2023 02:58:54 +0530 Subject: [PATCH 02/32] Basic config --- .github/workflows/docker.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e69de29bb2..c9ba896425 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -0,0 +1,11 @@ +name: Build & Push Docker Images + +on: + workflow_dispatch: + pull_request: + branches: + - main + +jobs: + pre_job: + runs-on: ubuntu-latest From 20a720a47e56ee358ae857d30f39982ceb7a1a56 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sun, 10 Sep 2023 03:05:06 +0530 Subject: [PATCH 03/32] Add initial Checkout step --- .github/workflows/docker.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c9ba896425..2655007b79 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,11 +1,17 @@ name: Build & Push Docker Images on: - workflow_dispatch: - pull_request: - branches: - - main + workflow_dispatch: + pull_request: + branches: + - main jobs: - pre_job: - runs-on: ubuntu-latest + pre_job: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 From 2be1537dcbce80484cfb188ee23ba6c1c476e829 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sun, 10 Sep 2023 03:14:55 +0530 Subject: [PATCH 04/32] Add docker login step --- .github/workflows/docker.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2655007b79..0a5ec20e73 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,3 +15,13 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: List built images + run: docker images From b611dd1479ef7c1ce3b87f0d9012184cc3006564 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sun, 10 Sep 2023 03:32:58 +0530 Subject: [PATCH 05/32] Build & push `pybamm:latest` --- .github/workflows/docker.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0a5ec20e73..32bc573608 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -25,3 +25,10 @@ jobs: - name: List built images run: docker images + + - name: Build and Push Docker Image (Without Solvers) + env: + IMAGE_NAME: pybamm/pybamm:latest + run: | + docker build -t $IMAGE_NAME -f scripts/Dockerfile . + docker push $IMAGE_NAME From c3991226f0dd5926c88c633d2b136596a4602e4c Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sun, 10 Sep 2023 03:33:26 +0530 Subject: [PATCH 06/32] Build & push `pybamm:jax` --- .github/workflows/docker.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 32bc573608..1caf030b57 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -32,3 +32,11 @@ jobs: run: | docker build -t $IMAGE_NAME -f scripts/Dockerfile . docker push $IMAGE_NAME + + - name: Build and Push Docker Image (With JAX Solver) + env: + IMAGE_NAME: pybamm/pybamm:jax + ARG_NAME: JAX + run: | + docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . + docker push $IMAGE_NAME From 174db815d2b97f6e1f7849d611d1426703c2f805 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sun, 10 Sep 2023 03:33:54 +0530 Subject: [PATCH 07/32] Build & push `pybamm:odes` --- .github/workflows/docker.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1caf030b57..4636385a5a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -40,3 +40,11 @@ jobs: run: | docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . docker push $IMAGE_NAME + + - name: Build and Push Docker Image (With ODES & DAE Solver) + env: + IMAGE_NAME: pybamm/pybamm:odes + ARG_NAME: ODES + run: | + docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . + docker push $IMAGE_NAME From 835a78f8a872fa97b0bb5fa41934ce0dc80758a3 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sun, 10 Sep 2023 03:34:34 +0530 Subject: [PATCH 08/32] Build & push `pybamm:idaklu` --- .github/workflows/docker.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4636385a5a..3e731fe814 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -48,3 +48,11 @@ jobs: run: | docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . docker push $IMAGE_NAME + + - name: Build and Push Docker Image (With IDAKLU Solver) + env: + IMAGE_NAME: pybamm/pybamm:idaklu + ARG_NAME: IDAKLU + run: | + docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . + docker push $IMAGE_NAME From 02f7936d3230a1b957e677a21444c3e9e7845d70 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sun, 10 Sep 2023 03:34:58 +0530 Subject: [PATCH 09/32] Build & push `pybamm:all` --- .github/workflows/docker.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 3e731fe814..2b5c2b764b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -56,3 +56,11 @@ jobs: run: | docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . docker push $IMAGE_NAME + + - name: Build and Push Docker Image (With All Solvers) + env: + IMAGE_NAME: pybamm/pybamm:all + ARG_NAME: ALL + run: | + docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . + docker push $IMAGE_NAME From c15f96ffd8b8795831a79ee420b60ec1bb62be9f Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Sun, 10 Sep 2023 04:05:48 +0530 Subject: [PATCH 10/32] Point to `develop` --- .github/workflows/docker.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2b5c2b764b..aed3fd3d53 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: pull_request: branches: - - main + - develop jobs: pre_job: @@ -13,8 +13,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Login to DockerHub if: github.event_name != 'pull_request' From 193ce5677ed5edf8cf57b52dc2788a9bdaa84b0d Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Fri, 22 Sep 2023 01:16:25 +0530 Subject: [PATCH 11/32] Login on dockerhub to test --- .github/workflows/docker.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index aed3fd3d53..478b18d541 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,7 +15,6 @@ jobs: uses: actions/checkout@v4 - name: Login to DockerHub - if: github.event_name != 'pull_request' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} From f697bfe951145d35f9a236136ec91685b779ff0a Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Thu, 28 Sep 2023 14:19:18 +0530 Subject: [PATCH 12/32] Try pushing with `build-push-action` --- .github/workflows/docker.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 478b18d541..940f2cd072 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -24,11 +24,11 @@ jobs: run: docker images - name: Build and Push Docker Image (Without Solvers) - env: - IMAGE_NAME: pybamm/pybamm:latest - run: | - docker build -t $IMAGE_NAME -f scripts/Dockerfile . - docker push $IMAGE_NAME + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: latest - name: Build and Push Docker Image (With JAX Solver) env: From 0cd648ac8852c72de6ec297e7580a09da16cc7f6 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Thu, 28 Sep 2023 14:22:10 +0530 Subject: [PATCH 13/32] Specify dockerfile path --- .github/workflows/docker.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 940f2cd072..debcf75c20 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -27,8 +27,9 @@ jobs: uses: docker/build-push-action@v5 with: context: . - push: true + file: scripts/Dockerfile tags: latest + push: true - name: Build and Push Docker Image (With JAX Solver) env: From bd740b7691e96ff71ba025cc03958325afe3f1ae Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Thu, 28 Sep 2023 14:29:38 +0530 Subject: [PATCH 14/32] Set up Docker Buildx --- .github/workflows/docker.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index debcf75c20..c6d1ba6885 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,8 +14,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to DockerHub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} From bcf4c608e65e18b7c6723bdc3dab8032f9740819 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Thu, 28 Sep 2023 14:36:51 +0530 Subject: [PATCH 15/32] Try name in tags --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c6d1ba6885..ef6e25745e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -31,7 +31,7 @@ jobs: with: context: . file: scripts/Dockerfile - tags: latest + tags: pybamm/pybamm:latest push: true - name: Build and Push Docker Image (With JAX Solver) From 6f012f73d481acec54d03041489b9309c55270a0 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Thu, 28 Sep 2023 15:02:22 +0530 Subject: [PATCH 16/32] Push all images with `build-push-action` --- .github/workflows/docker.yml | 56 ++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ef6e25745e..2b0cf706ae 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -35,33 +35,41 @@ jobs: push: true - name: Build and Push Docker Image (With JAX Solver) - env: - IMAGE_NAME: pybamm/pybamm:jax - ARG_NAME: JAX - run: | - docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . - docker push $IMAGE_NAME + uses: docker/build-push-action@v5 + with: + context: . + file: scripts/Dockerfile + tags: pybamm/pybamm:jax + push: true + build-args: | + JAX=true - name: Build and Push Docker Image (With ODES & DAE Solver) - env: - IMAGE_NAME: pybamm/pybamm:odes - ARG_NAME: ODES - run: | - docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . - docker push $IMAGE_NAME + uses: docker/build-push-action@v5 + with: + context: . + file: scripts/Dockerfile + tags: pybamm/pybamm:odes + push: true + build-args: | + ODES=true - name: Build and Push Docker Image (With IDAKLU Solver) - env: - IMAGE_NAME: pybamm/pybamm:idaklu - ARG_NAME: IDAKLU - run: | - docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . - docker push $IMAGE_NAME + uses: docker/build-push-action@v5 + with: + context: . + file: scripts/Dockerfile + tags: pybamm/pybamm:idaklu + push: true + build-args: | + IDAKLU=true - name: Build and Push Docker Image (With All Solvers) - env: - IMAGE_NAME: pybamm/pybamm:all - ARG_NAME: ALL - run: | - docker build -t $IMAGE_NAME -f scripts/Dockerfile --build-arg $ARG_NAME=true . - docker push $IMAGE_NAME + uses: docker/build-push-action@v5 + with: + context: . + file: scripts/Dockerfile + tags: pybamm/pybamm:latest + push: true + build-args: | + ALL=true From b0d58020ca655208e6de77e1ad369f81e7ae0d30 Mon Sep 17 00:00:00 2001 From: kratman Date: Thu, 28 Sep 2023 14:40:20 -0400 Subject: [PATCH 17/32] Switch quickplot tests to temp files --- tests/unit/test_batch_study.py | 19 +++++++++++-------- tests/unit/test_plotting/test_quick_plot.py | 11 +++++++---- tests/unit/test_simulation.py | 19 +++++++++++-------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/tests/unit/test_batch_study.py b/tests/unit/test_batch_study.py index 89e6bd62b0..f8762133a6 100644 --- a/tests/unit/test_batch_study.py +++ b/tests/unit/test_batch_study.py @@ -5,6 +5,7 @@ import os import pybamm import unittest +from tempfile import TemporaryDirectory spm = pybamm.lithium_ion.SPM() spm_uniform = pybamm.lithium_ion.SPM({"particle": "uniform profile"}) @@ -90,17 +91,19 @@ def test_solve(self): self.assertIn(output_experiment, experiments_list) def test_create_gif(self): - bs = pybamm.BatchStudy({"spm": pybamm.lithium_ion.SPM()}) - bs.solve([0, 10]) + with TemporaryDirectory() as dir_name: + bs = pybamm.BatchStudy({"spm": pybamm.lithium_ion.SPM()}) + bs.solve([0, 10]) - # create a GIF before calling the plot method - bs.create_gif(number_of_images=3, duration=1) + # Create a temporary file name + test_file = os.path.join(dir_name, "batch_study_test.gif") - # create a GIF after calling the plot method - bs.plot(testing=True) - bs.create_gif(number_of_images=3, duration=1) + # create a GIF before calling the plot method + bs.create_gif(number_of_images=3, duration=1, output_filename=test_file) - os.remove("plot.gif") + # create a GIF after calling the plot method + bs.plot(testing=True) + bs.create_gif(number_of_images=3, duration=1, output_filename=test_file) if __name__ == "__main__": diff --git a/tests/unit/test_plotting/test_quick_plot.py b/tests/unit/test_plotting/test_quick_plot.py index 3415777ee8..670ad3d7f0 100644 --- a/tests/unit/test_plotting/test_quick_plot.py +++ b/tests/unit/test_plotting/test_quick_plot.py @@ -3,6 +3,7 @@ import unittest from tests import TestCase import numpy as np +from tempfile import TemporaryDirectory class TestQuickPlot(TestCase): @@ -290,10 +291,12 @@ def test_spm_simulation(self): quick_plot.plot(0) # test creating a GIF - quick_plot.create_gif(number_of_images=3, duration=3) - assert not os.path.exists("plot*.png") - assert os.path.exists("plot.gif") - os.remove("plot.gif") + with TemporaryDirectory() as dir_name: + test_stub = os.path.join(dir_name, "spm_sim_test") + test_file = f"{test_stub}.gif" + quick_plot.create_gif(number_of_images=3, duration=3, output_filename=test_file) + assert not os.path.exists(f"{test_stub}*.png") + assert os.path.exists(test_file) pybamm.close_plots() diff --git a/tests/unit/test_simulation.py b/tests/unit/test_simulation.py index d0926e5c94..db3bf6f39b 100644 --- a/tests/unit/test_simulation.py +++ b/tests/unit/test_simulation.py @@ -6,6 +6,7 @@ import sys import unittest import uuid +from tempfile import TemporaryDirectory class TestSimulation(TestCase): @@ -340,17 +341,19 @@ def test_plot(self): sim.plot(testing=True) def test_create_gif(self): - sim = pybamm.Simulation(pybamm.lithium_ion.SPM()) - sim.solve(t_eval=[0, 10]) + with TemporaryDirectory() as dir_name: + sim = pybamm.Simulation(pybamm.lithium_ion.SPM()) + sim.solve(t_eval=[0, 10]) - # create a GIF without calling the plot method - sim.create_gif(number_of_images=3, duration=1) + # Create a temporary file name + test_file = os.path.join(dir_name, "test_sim.gif") - # call the plot method before creating the GIF - sim.plot(testing=True) - sim.create_gif(number_of_images=3, duration=1) + # create a GIF without calling the plot method + sim.create_gif(number_of_images=3, duration=1, output_filename=test_file) - os.remove("plot.gif") + # call the plot method before creating the GIF + sim.plot(testing=True) + sim.create_gif(number_of_images=3, duration=1, output_filename=test_file) def test_drive_cycle_interpolant(self): model = pybamm.lithium_ion.SPM() From 05cd6ec3fbc6529b624ca8a40f585d6530e54a4f Mon Sep 17 00:00:00 2001 From: kratman Date: Thu, 28 Sep 2023 15:00:50 -0400 Subject: [PATCH 18/32] Moving save and load tests to temp directories --- tests/unit/test_simulation.py | 111 +++++++------- tests/unit/test_solvers/test_solution.py | 183 ++++++++++++----------- 2 files changed, 153 insertions(+), 141 deletions(-) diff --git a/tests/unit/test_simulation.py b/tests/unit/test_simulation.py index db3bf6f39b..37b58e19c1 100644 --- a/tests/unit/test_simulation.py +++ b/tests/unit/test_simulation.py @@ -249,32 +249,36 @@ def test_step_with_inputs(self): ) def test_save_load(self): - model = pybamm.lead_acid.LOQS() - model.use_jacobian = True - sim = pybamm.Simulation(model) - - sim.save("test.pickle") - sim_load = pybamm.load_sim("test.pickle") - self.assertEqual(sim.model.name, sim_load.model.name) + with TemporaryDirectory() as dir_name: + test_name = os.path.join(dir_name, "tests.pickle") + + model = pybamm.lead_acid.LOQS() + model.use_jacobian = True + sim = pybamm.Simulation(model) + + sim.save(test_name) + sim_load = pybamm.load_sim(test_name) + self.assertEqual(sim.model.name, sim_load.model.name) + + # save after solving + sim.solve([0, 600]) + sim.save(test_name) + sim_load = pybamm.load_sim(test_name) + self.assertEqual(sim.model.name, sim_load.model.name) + + # with python formats + model.convert_to_format = None + sim = pybamm.Simulation(model) + sim.solve([0, 600]) + sim.save(test_name) + model.convert_to_format = "python" + sim = pybamm.Simulation(model) + sim.solve([0, 600]) + with self.assertRaisesRegex( + NotImplementedError, "Cannot save simulation if model format is python" + ): + sim.save(test_name) - # save after solving - sim.solve([0, 600]) - sim.save("test.pickle") - sim_load = pybamm.load_sim("test.pickle") - self.assertEqual(sim.model.name, sim_load.model.name) - - # with python formats - model.convert_to_format = None - sim = pybamm.Simulation(model) - sim.solve([0, 600]) - sim.save("test.pickle") - model.convert_to_format = "python" - sim = pybamm.Simulation(model) - sim.solve([0, 600]) - with self.assertRaisesRegex( - NotImplementedError, "Cannot save simulation if model format is python" - ): - sim.save("test.pickle") def test_load_param(self): # Test load_sim for parameters imports @@ -300,33 +304,36 @@ def test_load_param(self): os.remove(filename) def test_save_load_dae(self): - model = pybamm.lead_acid.LOQS({"surface form": "algebraic"}) - model.use_jacobian = True - sim = pybamm.Simulation(model) - - # save after solving - sim.solve([0, 600]) - sim.save("test.pickle") - sim_load = pybamm.load_sim("test.pickle") - self.assertEqual(sim.model.name, sim_load.model.name) - - # with python format - model.convert_to_format = None - sim = pybamm.Simulation(model) - sim.solve([0, 600]) - sim.save("test.pickle") - - # with Casadi solver & experiment - model.convert_to_format = "casadi" - sim = pybamm.Simulation( - model, - experiment="Discharge at 1C for 20 minutes", - solver=pybamm.CasadiSolver(), - ) - sim.solve([0, 600]) - sim.save("test.pickle") - sim_load = pybamm.load_sim("test.pickle") - self.assertEqual(sim.model.name, sim_load.model.name) + with TemporaryDirectory() as dir_name: + test_name = os.path.join(dir_name, "test.pickle") + + model = pybamm.lead_acid.LOQS({"surface form": "algebraic"}) + model.use_jacobian = True + sim = pybamm.Simulation(model) + + # save after solving + sim.solve([0, 600]) + sim.save(test_name) + sim_load = pybamm.load_sim(test_name) + self.assertEqual(sim.model.name, sim_load.model.name) + + # with python format + model.convert_to_format = None + sim = pybamm.Simulation(model) + sim.solve([0, 600]) + sim.save(test_name) + + # with Casadi solver & experiment + model.convert_to_format = "casadi" + sim = pybamm.Simulation( + model, + experiment="Discharge at 1C for 20 minutes", + solver=pybamm.CasadiSolver(), + ) + sim.solve([0, 600]) + sim.save(test_name) + sim_load = pybamm.load_sim(test_name) + self.assertEqual(sim.model.name, sim_load.model.name) def test_plot(self): sim = pybamm.Simulation(pybamm.lithium_ion.SPM()) diff --git a/tests/unit/test_solvers/test_solution.py b/tests/unit/test_solvers/test_solution.py index 2ef01d7434..c01700267e 100644 --- a/tests/unit/test_solvers/test_solution.py +++ b/tests/unit/test_solvers/test_solution.py @@ -1,6 +1,7 @@ # # Tests for the Solution class # +import os from tests import TestCase import json import pybamm @@ -9,6 +10,7 @@ import pandas as pd from scipy.io import loadmat from tests import get_discretisation_for_testing +from tempfile import TemporaryDirectory class TestSolution(TestCase): @@ -233,95 +235,98 @@ def test_plot(self): solution.plot(["c", "2c"], testing=True) def test_save(self): - model = pybamm.BaseModel() - # create both 1D and 2D variables - c = pybamm.Variable("c") - d = pybamm.Variable("d", domain="negative electrode") - model.rhs = {c: -c, d: 1} - model.initial_conditions = {c: 1, d: 2} - model.variables = {"c": c, "d": d, "2c": 2 * c, "c + d": c + d} - - disc = get_discretisation_for_testing() - disc.process_model(model) - solution = pybamm.ScipySolver().solve(model, np.linspace(0, 1)) - - # test save data - with self.assertRaises(ValueError): - solution.save_data("test.pickle") - - # set variables first then save - solution.update(["c", "d"]) - with self.assertRaisesRegex(ValueError, "pickle"): - solution.save_data(to_format="pickle") - solution.save_data("test.pickle") - - data_load = pybamm.load("test.pickle") - np.testing.assert_array_equal(solution.data["c"], data_load["c"]) - np.testing.assert_array_equal(solution.data["d"], data_load["d"]) - - # to matlab - solution.save_data("test.mat", to_format="matlab") - data_load = loadmat("test.mat") - np.testing.assert_array_equal(solution.data["c"], data_load["c"].flatten()) - np.testing.assert_array_equal(solution.data["d"], data_load["d"]) - - with self.assertRaisesRegex(ValueError, "matlab"): - solution.save_data(to_format="matlab") - - # to matlab with bad variables name fails - solution.update(["c + d"]) - with self.assertRaisesRegex(ValueError, "Invalid character"): - solution.save_data("test.mat", to_format="matlab") - # Works if providing alternative name - solution.save_data( - "test.mat", to_format="matlab", short_names={"c + d": "c_plus_d"} - ) - data_load = loadmat("test.mat") - np.testing.assert_array_equal(solution.data["c + d"], data_load["c_plus_d"]) - - # to csv - with self.assertRaisesRegex( - ValueError, "only 0D variables can be saved to csv" - ): - solution.save_data("test.csv", to_format="csv") - # only save "c" and "2c" - solution.save_data("test.csv", ["c", "2c"], to_format="csv") - csv_str = solution.save_data(variables=["c", "2c"], to_format="csv") - - # check string is the same as the file - with open("test.csv") as f: - # need to strip \r chars for windows - self.assertEqual(csv_str.replace("\r", ""), f.read()) - - # read csv - df = pd.read_csv("test.csv") - np.testing.assert_array_almost_equal(df["c"], solution.data["c"]) - np.testing.assert_array_almost_equal(df["2c"], solution.data["2c"]) - - # to json - solution.save_data("test.json", to_format="json") - json_str = solution.save_data(to_format="json") - - # check string is the same as the file - with open("test.json") as f: - # need to strip \r chars for windows - self.assertEqual(json_str.replace("\r", ""), f.read()) - - # check if string has the right values - json_data = json.loads(json_str) - np.testing.assert_array_almost_equal(json_data["c"], solution.data["c"]) - np.testing.assert_array_almost_equal(json_data["d"], solution.data["d"]) - - # raise error if format is unknown - with self.assertRaisesRegex(ValueError, "format 'wrong_format' not recognised"): - solution.save_data("test.csv", to_format="wrong_format") - - # test save whole solution - solution.save("test.pickle") - solution_load = pybamm.load("test.pickle") - self.assertEqual(solution.all_models[0].name, solution_load.all_models[0].name) - np.testing.assert_array_equal(solution["c"].entries, solution_load["c"].entries) - np.testing.assert_array_equal(solution["d"].entries, solution_load["d"].entries) + with TemporaryDirectory() as dir_name: + test_stub = os.path.join(dir_name, "test") + + model = pybamm.BaseModel() + # create both 1D and 2D variables + c = pybamm.Variable("c") + d = pybamm.Variable("d", domain="negative electrode") + model.rhs = {c: -c, d: 1} + model.initial_conditions = {c: 1, d: 2} + model.variables = {"c": c, "d": d, "2c": 2 * c, "c + d": c + d} + + disc = get_discretisation_for_testing() + disc.process_model(model) + solution = pybamm.ScipySolver().solve(model, np.linspace(0, 1)) + + # test save data + with self.assertRaises(ValueError): + solution.save_data(f"{test_stub}.pickle") + + # set variables first then save + solution.update(["c", "d"]) + with self.assertRaisesRegex(ValueError, "pickle"): + solution.save_data(to_format="pickle") + solution.save_data(f"{test_stub}.pickle") + + data_load = pybamm.load(f"{test_stub}.pickle") + np.testing.assert_array_equal(solution.data["c"], data_load["c"]) + np.testing.assert_array_equal(solution.data["d"], data_load["d"]) + + # to matlab + solution.save_data(f"{test_stub}.mat", to_format="matlab") + data_load = loadmat(f"{test_stub}.mat") + np.testing.assert_array_equal(solution.data["c"], data_load["c"].flatten()) + np.testing.assert_array_equal(solution.data["d"], data_load["d"]) + + with self.assertRaisesRegex(ValueError, "matlab"): + solution.save_data(to_format="matlab") + + # to matlab with bad variables name fails + solution.update(["c + d"]) + with self.assertRaisesRegex(ValueError, "Invalid character"): + solution.save_data(f"{test_stub}.mat", to_format="matlab") + # Works if providing alternative name + solution.save_data( + f"{test_stub}.mat", to_format="matlab", short_names={"c + d": "c_plus_d"} + ) + data_load = loadmat(f"{test_stub}.mat") + np.testing.assert_array_equal(solution.data["c + d"], data_load["c_plus_d"]) + + # to csv + with self.assertRaisesRegex( + ValueError, "only 0D variables can be saved to csv" + ): + solution.save_data(f"{test_stub}.csv", to_format="csv") + # only save "c" and "2c" + solution.save_data(f"{test_stub}.csv", ["c", "2c"], to_format="csv") + csv_str = solution.save_data(variables=["c", "2c"], to_format="csv") + + # check string is the same as the file + with open(f"{test_stub}.csv") as f: + # need to strip \r chars for windows + self.assertEqual(csv_str.replace("\r", ""), f.read()) + + # read csv + df = pd.read_csv(f"{test_stub}.csv") + np.testing.assert_array_almost_equal(df["c"], solution.data["c"]) + np.testing.assert_array_almost_equal(df["2c"], solution.data["2c"]) + + # to json + solution.save_data(f"{test_stub}.json", to_format="json") + json_str = solution.save_data(to_format="json") + + # check string is the same as the file + with open(f"{test_stub}.json") as f: + # need to strip \r chars for windows + self.assertEqual(json_str.replace("\r", ""), f.read()) + + # check if string has the right values + json_data = json.loads(json_str) + np.testing.assert_array_almost_equal(json_data["c"], solution.data["c"]) + np.testing.assert_array_almost_equal(json_data["d"], solution.data["d"]) + + # raise error if format is unknown + with self.assertRaisesRegex(ValueError, "format 'wrong_format' not recognised"): + solution.save_data(f"{test_stub}.csv", to_format="wrong_format") + + # test save whole solution + solution.save(f"{test_stub}.pickle") + solution_load = pybamm.load(f"{test_stub}.pickle") + self.assertEqual(solution.all_models[0].name, solution_load.all_models[0].name) + np.testing.assert_array_equal(solution["c"].entries, solution_load["c"].entries) + np.testing.assert_array_equal(solution["d"].entries, solution_load["d"].entries) def test_get_data_cycles_steps(self): model = pybamm.BaseModel() From fda46ac2169891d7c0bf204946b6fe04e3e0e64f Mon Sep 17 00:00:00 2001 From: kratman Date: Thu, 28 Sep 2023 15:08:14 -0400 Subject: [PATCH 19/32] pre-commit fixes --- tests/unit/test_plotting/test_quick_plot.py | 3 ++- tests/unit/test_simulation.py | 3 ++- tests/unit/test_solvers/test_solution.py | 15 ++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/unit/test_plotting/test_quick_plot.py b/tests/unit/test_plotting/test_quick_plot.py index 670ad3d7f0..507125b340 100644 --- a/tests/unit/test_plotting/test_quick_plot.py +++ b/tests/unit/test_plotting/test_quick_plot.py @@ -294,7 +294,8 @@ def test_spm_simulation(self): with TemporaryDirectory() as dir_name: test_stub = os.path.join(dir_name, "spm_sim_test") test_file = f"{test_stub}.gif" - quick_plot.create_gif(number_of_images=3, duration=3, output_filename=test_file) + quick_plot.create_gif(number_of_images=3, duration=3, + output_filename=test_file) assert not os.path.exists(f"{test_stub}*.png") assert os.path.exists(test_file) diff --git a/tests/unit/test_simulation.py b/tests/unit/test_simulation.py index 37b58e19c1..c98586ee59 100644 --- a/tests/unit/test_simulation.py +++ b/tests/unit/test_simulation.py @@ -275,7 +275,8 @@ def test_save_load(self): sim = pybamm.Simulation(model) sim.solve([0, 600]) with self.assertRaisesRegex( - NotImplementedError, "Cannot save simulation if model format is python" + NotImplementedError, + "Cannot save simulation if model format is python" ): sim.save(test_name) diff --git a/tests/unit/test_solvers/test_solution.py b/tests/unit/test_solvers/test_solution.py index c01700267e..9fc93dfb26 100644 --- a/tests/unit/test_solvers/test_solution.py +++ b/tests/unit/test_solvers/test_solution.py @@ -279,7 +279,8 @@ def test_save(self): solution.save_data(f"{test_stub}.mat", to_format="matlab") # Works if providing alternative name solution.save_data( - f"{test_stub}.mat", to_format="matlab", short_names={"c + d": "c_plus_d"} + f"{test_stub}.mat", to_format="matlab", + short_names={"c + d": "c_plus_d"} ) data_load = loadmat(f"{test_stub}.mat") np.testing.assert_array_equal(solution.data["c + d"], data_load["c_plus_d"]) @@ -318,15 +319,19 @@ def test_save(self): np.testing.assert_array_almost_equal(json_data["d"], solution.data["d"]) # raise error if format is unknown - with self.assertRaisesRegex(ValueError, "format 'wrong_format' not recognised"): + with self.assertRaisesRegex(ValueError, + "format 'wrong_format' not recognised"): solution.save_data(f"{test_stub}.csv", to_format="wrong_format") # test save whole solution solution.save(f"{test_stub}.pickle") solution_load = pybamm.load(f"{test_stub}.pickle") - self.assertEqual(solution.all_models[0].name, solution_load.all_models[0].name) - np.testing.assert_array_equal(solution["c"].entries, solution_load["c"].entries) - np.testing.assert_array_equal(solution["d"].entries, solution_load["d"].entries) + self.assertEqual(solution.all_models[0].name, + solution_load.all_models[0].name) + np.testing.assert_array_equal(solution["c"].entries, + solution_load["c"].entries) + np.testing.assert_array_equal(solution["d"].entries, + solution_load["d"].entries) def test_get_data_cycles_steps(self): model = pybamm.BaseModel() From bbf60331dddedb1a7188e70aa3f3a39d47bb7a3a Mon Sep 17 00:00:00 2001 From: kratman Date: Thu, 28 Sep 2023 15:13:43 -0400 Subject: [PATCH 20/32] Moving parameter printing to temporary directories --- .../test_parameters/test_lead_acid_parameters.py | 12 +++++++----- .../test_parameters/test_lithium_ion_parameters.py | 14 ++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/unit/test_parameters/test_lead_acid_parameters.py b/tests/unit/test_parameters/test_lead_acid_parameters.py index e0151f0e7b..ddc73f61ee 100644 --- a/tests/unit/test_parameters/test_lead_acid_parameters.py +++ b/tests/unit/test_parameters/test_lead_acid_parameters.py @@ -1,10 +1,11 @@ # # Test for the standard lead acid parameters # +import os from tests import TestCase import pybamm from tests import get_discretisation_for_testing - +from tempfile import TemporaryDirectory import unittest @@ -15,10 +16,11 @@ def test_scipy_constants(self): self.assertAlmostEqual(constants.F.evaluate(), 96485, places=0) def test_print_parameters(self): - parameters = pybamm.LeadAcidParameters() - parameter_values = pybamm.lead_acid.BaseModel().default_parameter_values - output_file = "lead_acid_parameters.txt" - parameter_values.print_parameters(parameters, output_file) + with TemporaryDirectory() as dir_name: + parameters = pybamm.LeadAcidParameters() + parameter_values = pybamm.lead_acid.BaseModel().default_parameter_values + output_file = os.path.join(dir_name, "lead_acid_parameters.txt") + parameter_values.print_parameters(parameters, output_file) def test_parameters_defaults_lead_acid(self): # Load parameters to be tested diff --git a/tests/unit/test_parameters/test_lithium_ion_parameters.py b/tests/unit/test_parameters/test_lithium_ion_parameters.py index 9d9d892300..5fb854105f 100644 --- a/tests/unit/test_parameters/test_lithium_ion_parameters.py +++ b/tests/unit/test_parameters/test_lithium_ion_parameters.py @@ -1,19 +1,21 @@ # -# Tests lithium ion parameters load and give expected values +# Tests lithium-ion parameters load and give expected values # +import os from tests import TestCase import pybamm - +from tempfile import TemporaryDirectory import unittest import numpy as np class TestLithiumIonParameterValues(TestCase): def test_print_parameters(self): - parameters = pybamm.LithiumIonParameters() - parameter_values = pybamm.lithium_ion.BaseModel().default_parameter_values - output_file = "lithium_ion_parameters.txt" - parameter_values.print_parameters(parameters, output_file) + with TemporaryDirectory as dir_name: + parameters = pybamm.LithiumIonParameters() + parameter_values = pybamm.lithium_ion.BaseModel().default_parameter_values + output_file = os.path.join(dir_name, "lithium_ion_parameters.txt") + parameter_values.print_parameters(parameters, output_file) def test_lithium_ion(self): """This test checks that all the parameters are being calculated From 3a75c16ba4ab90e9f691849a67d5700ca51d2fb7 Mon Sep 17 00:00:00 2001 From: kratman Date: Thu, 28 Sep 2023 15:19:50 -0400 Subject: [PATCH 21/32] Move expression tree PNG to a temp folder --- tests/unit/test_expression_tree/test_symbol.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/unit/test_expression_tree/test_symbol.py b/tests/unit/test_expression_tree/test_symbol.py index 3a74375ce7..b02e7c59e1 100644 --- a/tests/unit/test_expression_tree/test_symbol.py +++ b/tests/unit/test_expression_tree/test_symbol.py @@ -4,6 +4,7 @@ from tests import TestCase import os import unittest +from tempfile import TemporaryDirectory import numpy as np from scipy.sparse import csr_matrix, coo_matrix @@ -386,13 +387,16 @@ def test_symbol_repr(self): ) def test_symbol_visualise(self): - c = pybamm.Variable("c", "negative electrode") - d = pybamm.Variable("d", "negative electrode") - sym = pybamm.div(c * pybamm.grad(c)) + (c / d + c - d) ** 5 - sym.visualise("test_visualize.png") - self.assertTrue(os.path.exists("test_visualize.png")) - with self.assertRaises(ValueError): - sym.visualise("test_visualize") + with TemporaryDirectory as dir_name: + test_stub = os.path.join(dir_name, "test_visualize") + test_name = f"{test_stub}.png" + c = pybamm.Variable("c", "negative electrode") + d = pybamm.Variable("d", "negative electrode") + sym = pybamm.div(c * pybamm.grad(c)) + (c / d + c - d) ** 5 + sym.visualise(test_name) + self.assertTrue(os.path.exists(test_name)) + with self.assertRaises(ValueError): + sym.visualise(test_stub) def test_has_spatial_derivatives(self): var = pybamm.Variable("var", domain="test") From 10c727093c7a6d3c5a7085f9ba0b0b928ce85db5 Mon Sep 17 00:00:00 2001 From: kratman Date: Thu, 28 Sep 2023 15:30:53 -0400 Subject: [PATCH 22/32] Fixing a few typos --- tests/unit/test_expression_tree/test_symbol.py | 2 +- tests/unit/test_parameters/test_lithium_ion_parameters.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_expression_tree/test_symbol.py b/tests/unit/test_expression_tree/test_symbol.py index b02e7c59e1..3f91633fbe 100644 --- a/tests/unit/test_expression_tree/test_symbol.py +++ b/tests/unit/test_expression_tree/test_symbol.py @@ -387,7 +387,7 @@ def test_symbol_repr(self): ) def test_symbol_visualise(self): - with TemporaryDirectory as dir_name: + with TemporaryDirectory() as dir_name: test_stub = os.path.join(dir_name, "test_visualize") test_name = f"{test_stub}.png" c = pybamm.Variable("c", "negative electrode") diff --git a/tests/unit/test_parameters/test_lithium_ion_parameters.py b/tests/unit/test_parameters/test_lithium_ion_parameters.py index 5fb854105f..0c46eec16e 100644 --- a/tests/unit/test_parameters/test_lithium_ion_parameters.py +++ b/tests/unit/test_parameters/test_lithium_ion_parameters.py @@ -11,7 +11,7 @@ class TestLithiumIonParameterValues(TestCase): def test_print_parameters(self): - with TemporaryDirectory as dir_name: + with TemporaryDirectory() as dir_name: parameters = pybamm.LithiumIonParameters() parameter_values = pybamm.lithium_ion.BaseModel().default_parameter_values output_file = os.path.join(dir_name, "lithium_ion_parameters.txt") From 8747dd9af78cccf6e7a21787cb282998a2ac47df Mon Sep 17 00:00:00 2001 From: Agnik Bakshi <77234005+Agnik7@users.noreply.github.com> Date: Mon, 2 Oct 2023 17:30:45 +0530 Subject: [PATCH 23/32] fix: Broken link --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6aa6987c2..84d7ec8c3e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -185,7 +185,7 @@ You may also test multiple notebooks this way. Passing the path to a folder will nox -s examples -- docs/source/examples/notebooks/models/ ``` -You may also use an appropriate [glob pattern](https://www.malikbrowne.com/blog/a-beginners-guide-glob-patterns) to run all notebooks matching a particular folder or name pattern. +You may also use an appropriate [glob pattern](https://developers.tetrascience.com/docs/common-glob-pattern) to run all notebooks matching a particular folder or name pattern. To edit the structure and how the Jupyter notebooks get rendered in the Sphinx documentation (using `nbsphinx`), install [Pandoc](https://pandoc.org/installing.html) on your system, either using `conda` (through the `conda-forge` channel) From cbec0e946f51f0d342d5e31f2fd5e2b7aa1e7bb8 Mon Sep 17 00:00:00 2001 From: Agnik Bakshi <77234005+Agnik7@users.noreply.github.com> Date: Mon, 2 Oct 2023 17:41:17 +0530 Subject: [PATCH 24/32] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21cfb2ae87..809a721e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ## Bug fixes +- Fixed a bug where there was an expired link related to glob pattern in the CONTRIBUTING.md file.([#3393](https://github.com/pybamm-team/PyBaMM/pull/3393)) - Fixed a bug where empty lists passed to QuickPlot resulted in an IndexError and did not return a meaningful error message ([#3359](https://github.com/pybamm-team/PyBaMM/pull/3359)) - Fixed a bug where there was a missing thermal conductivity in the thermal pouch cell models ([#3330](https://github.com/pybamm-team/PyBaMM/pull/3330)) - Fixed a bug that caused incorrect results of “{Domain} electrode thickness change [m]” due to the absence of dimension for the variable `electrode_thickness_change`([#3329](https://github.com/pybamm-team/PyBaMM/pull/3329)). From 3ebb05ff985bdf503bb8038c7705758372d9c3d9 Mon Sep 17 00:00:00 2001 From: Agnik Bakshi <77234005+Agnik7@users.noreply.github.com> Date: Mon, 2 Oct 2023 18:02:26 +0530 Subject: [PATCH 25/32] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 809a721e2f..21cfb2ae87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,6 @@ ## Bug fixes -- Fixed a bug where there was an expired link related to glob pattern in the CONTRIBUTING.md file.([#3393](https://github.com/pybamm-team/PyBaMM/pull/3393)) - Fixed a bug where empty lists passed to QuickPlot resulted in an IndexError and did not return a meaningful error message ([#3359](https://github.com/pybamm-team/PyBaMM/pull/3359)) - Fixed a bug where there was a missing thermal conductivity in the thermal pouch cell models ([#3330](https://github.com/pybamm-team/PyBaMM/pull/3330)) - Fixed a bug that caused incorrect results of “{Domain} electrode thickness change [m]” due to the absence of dimension for the variable `electrode_thickness_change`([#3329](https://github.com/pybamm-team/PyBaMM/pull/3329)). From 278bdf4d301aed69bb8a11b7f20079d6215e1695 Mon Sep 17 00:00:00 2001 From: Agnik Bakshi <77234005+Agnik7@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:22:24 +0530 Subject: [PATCH 26/32] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 84d7ec8c3e..98d48b6f4a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -185,7 +185,7 @@ You may also test multiple notebooks this way. Passing the path to a folder will nox -s examples -- docs/source/examples/notebooks/models/ ``` -You may also use an appropriate [glob pattern](https://developers.tetrascience.com/docs/common-glob-pattern) to run all notebooks matching a particular folder or name pattern. +You may also use an appropriate [glob pattern](https://linux.die.net/man/7/glob) to run all notebooks matching a particular folder or name pattern. To edit the structure and how the Jupyter notebooks get rendered in the Sphinx documentation (using `nbsphinx`), install [Pandoc](https://pandoc.org/installing.html) on your system, either using `conda` (through the `conda-forge` channel) From cf4ead658c556b3532faf425f91f35a58170b2b0 Mon Sep 17 00:00:00 2001 From: Agnik Bakshi <77234005+Agnik7@users.noreply.github.com> Date: Mon, 2 Oct 2023 20:29:27 +0530 Subject: [PATCH 27/32] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 98d48b6f4a..4612e83252 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -185,7 +185,7 @@ You may also test multiple notebooks this way. Passing the path to a folder will nox -s examples -- docs/source/examples/notebooks/models/ ``` -You may also use an appropriate [glob pattern](https://linux.die.net/man/7/glob) to run all notebooks matching a particular folder or name pattern. +You may also use an appropriate [glob pattern](https://docs.python.org/3/library/glob.html) to run all notebooks matching a particular folder or name pattern. To edit the structure and how the Jupyter notebooks get rendered in the Sphinx documentation (using `nbsphinx`), install [Pandoc](https://pandoc.org/installing.html) on your system, either using `conda` (through the `conda-forge` channel) From cfc2a378ee91e40f31e75222e2fc6edd3cb09071 Mon Sep 17 00:00:00 2001 From: "arjxn.py" Date: Tue, 3 Oct 2023 20:28:04 +0530 Subject: [PATCH 28/32] Add cron job [skip ci] --- .github/workflows/docker.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2b0cf706ae..bb17564fa2 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,7 +4,11 @@ on: workflow_dispatch: pull_request: branches: - - develop + - main + + # Run everyday at 3 am UTC + schedule: + - cron: "0 3 * * *" jobs: pre_job: From 2a88dfea7853be9c0c3fcab88dbf920f333b2c90 Mon Sep 17 00:00:00 2001 From: Arjun Date: Tue, 3 Oct 2023 20:58:57 +0530 Subject: [PATCH 29/32] Push to docker on every push to develop Co-authored-by: Saransh Chopra --- .github/workflows/docker.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bb17564fa2..c3575a50f8 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,13 +2,9 @@ name: Build & Push Docker Images on: workflow_dispatch: - pull_request: + push: branches: - - main - - # Run everyday at 3 am UTC - schedule: - - cron: "0 3 * * *" + - develop jobs: pre_job: From 96eef72344451e532636167eafa3ef279149e7aa Mon Sep 17 00:00:00 2001 From: Agnik Bakshi <77234005+Agnik7@users.noreply.github.com> Date: Sun, 8 Oct 2023 17:51:37 +0530 Subject: [PATCH 30/32] Fix URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a4bb69ac7c..9f45d34327 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Chuck Liu
Chuck Liu

🐛 💻 partben
partben

📖 - Gavin Wiggins
Gavin Wiggins

🐛 💻 + Gavin Wiggins
Gavin Wiggins

🐛 💻 Dion Wilde
Dion Wilde

🐛 💻 Elias Hohl
Elias Hohl

💻 KAschad
KAschad

🐛 From f5ddab39fb673d0ffb297d49e4c4f6e5f42d65e8 Mon Sep 17 00:00:00 2001 From: Agnik Bakshi <77234005+Agnik7@users.noreply.github.com> Date: Sun, 8 Oct 2023 17:52:10 +0530 Subject: [PATCH 31/32] Update .all-contributorsrc --- .all-contributorsrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 2456085b32..405ff36569 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -442,7 +442,7 @@ "login": "wigging", "name": "Gavin Wiggins", "avatar_url": "https://avatars.githubusercontent.com/u/6828967?v=4", - "profile": "https://wigging.me", + "profile": "https://gavinw.me", "contributions": [ "bug", "code" From bc909c3212f0b7d7974b6e11525b1f7108b37489 Mon Sep 17 00:00:00 2001 From: Agnik Bakshi <77234005+Agnik7@users.noreply.github.com> Date: Sun, 8 Oct 2023 18:08:48 +0530 Subject: [PATCH 32/32] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4612e83252..bec0fee02a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,7 +44,7 @@ You now have everything you need to start making changes! ### B. Writing your code -6. PyBaMM is developed in [Python](https://en.wikipedia.org/wiki/Python_(programming_language)), and makes heavy use of [NumPy](https://en.wikipedia.org/wiki/NumPy) (see also [NumPy for MatLab users](https://numpy.org/doc/stable/user/numpy-for-matlab-users.html) and [Python for R users](http://blog.hackerearth.com/how-can-r-users-learn-python-for-data-science)). +6. PyBaMM is developed in [Python](https://en.wikipedia.org/wiki/Python_(programming_language)), and makes heavy use of [NumPy](https://en.wikipedia.org/wiki/NumPy) (see also [NumPy for MatLab users](https://numpy.org/doc/stable/user/numpy-for-matlab-users.html) and [Python for R users](https://www.rebeccabarter.com/blog/2023-09-11-from_r_to_python)). 7. Make sure to follow our [coding style guidelines](#coding-style-guidelines). 8. Commit your changes to your branch with [useful, descriptive commit messages](https://chris.beams.io/posts/git-commit/): Remember these are publicly visible and should still make sense a few months ahead in time. While developing, you can keep using the GitHub issue you're working on as a place for discussion. [Refer to your commits](https://stackoverflow.com/questions/8910271/how-can-i-reference-a-commit-in-an-issue-comment-on-github) when discussing specific lines of code. 9. If you want to add a dependency on another library, or re-use code you found somewhere else, have a look at [these guidelines](#dependencies-and-reusing-code).