From bcf99e026ae8d54b310347480794ad6fad6eecdf Mon Sep 17 00:00:00 2001 From: Swasti Mishra Date: Tue, 4 Nov 2025 14:53:24 +0530 Subject: [PATCH 1/3] Fix: replace broken discussion-auto-responder action with github-script (fixes #5186) --- .github/workflows/discussion_autoresponder.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/discussion_autoresponder.yml b/.github/workflows/discussion_autoresponder.yml index 936493074f..4e72090918 100644 --- a/.github/workflows/discussion_autoresponder.yml +++ b/.github/workflows/discussion_autoresponder.yml @@ -4,7 +4,6 @@ on: discussion: types: [created] - permissions: {} jobs: @@ -17,8 +16,15 @@ jobs: steps: - name: Run Discussion Autoresponder - uses: wesleyscholl/discussion-auto-responder@b1a3c1b9a1e3d1b1a3c1b9a1e3d1b1a3c1b9a1e3 # v1.0.8 + uses: actions/github-script@v7 with: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - comment_body: "Hi! We have now moved our discussions to [Discourse](https://pybamm.discourse.group/). Please post your question there." - delay_milliseconds: 0 + script: | + const discussion = context.payload.discussion; + const message = `Hi! We have now moved our discussions to [Discourse](https://pybamm.discourse.group/). Please post your question there.`; + + await github.rest.discussions.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + discussion_number: discussion.number, + body: message, + }); From 8d1be0a2c9fcf7064db78f358a88023b31a9b130 Mon Sep 17 00:00:00 2001 From: Swasti Mishra Date: Tue, 4 Nov 2025 14:54:36 +0530 Subject: [PATCH 2/3] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cac3dffdd..ce3de2bc8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ ## Bug fixes +- Fixed Discussion Autoresponder workflow by replacing the unmaintained action with a maintained github-script implementation ([#5261](https://github.com/pybamm-team/PyBaMM/pull/5261)) - Set `zip(..., strict=True)` in solver and expression tree files to ensure iterable length safety. ([#5241](https://github.com/pybamm-team/PyBaMM/pull/5241)) - Adds `options` property to IDAKLU, fixes pickling issue with `__getstate__` when keys are not available. ([#5234](https://github.com/pybamm-team/PyBaMM/pull/5234)) - Fixed a bug where simulations using output variables in `IDAKLUSolver` couldn't be pickled ([#5225](https://github.com/pybamm-team/PyBaMM/pull/5225)) From 1c1b3ca9df58537ed935d27aa974be1d6fc45fd1 Mon Sep 17 00:00:00 2001 From: Swasti Mishra Date: Fri, 6 Feb 2026 15:24:28 +0530 Subject: [PATCH 3/3] test: add pytest fixture for default P2D mesh --- conftest.py | 10 ++++++++++ tests/__init__.py | 1 - .../test_finite_volume/test_extrapolation.py | 5 ++--- .../test_finite_volume/test_finite_volume.py | 13 ++++++------- .../test_ghost_nodes_and_neumann.py | 6 +++--- .../test_finite_volume/test_grad_div_shapes.py | 11 +++++------ 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/conftest.py b/conftest.py index ba258c541a..c2909df5d0 100644 --- a/conftest.py +++ b/conftest.py @@ -2,6 +2,7 @@ import pytest import pybamm +from tests.shared import get_mesh_for_testing def pytest_addoption(parser): @@ -50,3 +51,12 @@ def set_debug_value(): @pytest.fixture(autouse=True) def disable_telemetry(): pybamm.telemetry.disable() + + +@pytest.fixture +def p2d_mesh(): + """ + Default P2D mesh for unit tests. + """ + geometry = pybamm.battery_geometry() + return get_mesh_for_testing(xpts=None, rpts=10, geometry=geometry) diff --git a/tests/__init__.py b/tests/__init__.py index 58f394643f..ce86859bcc 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -30,7 +30,6 @@ get_unit_3d_mesh_for_testing, get_mesh_for_testing_symbolic, get_mesh_for_testing_symbolic_concatenation, - get_p2d_mesh_for_testing, get_size_distribution_mesh_for_testing, get_1p1d_mesh_for_testing, get_2p1d_mesh_for_testing, diff --git a/tests/unit/test_spatial_methods/test_finite_volume/test_extrapolation.py b/tests/unit/test_spatial_methods/test_finite_volume/test_extrapolation.py index d0a512c528..8ae06cfe3d 100644 --- a/tests/unit/test_spatial_methods/test_finite_volume/test_extrapolation.py +++ b/tests/unit/test_spatial_methods/test_finite_volume/test_extrapolation.py @@ -10,7 +10,6 @@ get_1p1d_mesh_for_testing, get_mesh_for_testing, get_mesh_for_testing_symbolic, - get_p2d_mesh_for_testing, ) @@ -733,9 +732,9 @@ def test_extrapolate_on_nonuniform_grid(self): surf_eqn_disc.evaluate(None, linear_y), y_surf, rtol=1e-7, atol=1e-6 ) - def test_extrapolate_2d_models(self): + def test_extrapolate_2d_models(self, p2d_mesh): # create discretisation - mesh = get_p2d_mesh_for_testing() + mesh = p2d_mesh method_options = { "extrapolation": { "order": {"gradient": "linear", "value": "linear"}, diff --git a/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py b/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py index 218506b6f9..267daa2b59 100644 --- a/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py +++ b/tests/unit/test_spatial_methods/test_finite_volume/test_finite_volume.py @@ -11,7 +11,6 @@ get_1p1d_mesh_for_testing, get_mesh_for_testing, get_mesh_for_testing_symbolic, - get_p2d_mesh_for_testing, ) @@ -254,7 +253,7 @@ def test_mass_matrix_shape(self): mass = np.eye(submesh.npts) np.testing.assert_array_equal(mass, model.mass_matrix.entries.toarray()) - def test_p2d_mass_matrix_shape(self): + def test_p2d_mass_matrix_shape(self, p2d_mesh): # Create model c = pybamm.Variable( "c", @@ -271,7 +270,7 @@ def test_p2d_mass_matrix_shape(self): model.variables = {"c": c, "N": N} # Create discretisation - mesh = get_p2d_mesh_for_testing() + mesh = p2d_mesh spatial_methods = {"negative particle": pybamm.FiniteVolume()} disc = pybamm.Discretisation(mesh, spatial_methods) disc.process_model(model) @@ -355,8 +354,8 @@ def test_jacobian(self): eqn_jac = eqn_disc.jac(y) eqn_jac.evaluate(y=y_test) - def test_boundary_value_domain(self): - mesh = get_p2d_mesh_for_testing() + def test_boundary_value_domain(self, p2d_mesh): + mesh = p2d_mesh spatial_methods = { "macroscale": pybamm.FiniteVolume(), "negative particle": pybamm.FiniteVolume(), @@ -649,8 +648,8 @@ def test_full_broadcast_domains(self): disc = pybamm.Discretisation(mesh, spatial_methods) disc.process_model(model) - def test_evaluate_at(self): - mesh = get_p2d_mesh_for_testing() + def test_evaluate_at(self, p2d_mesh): + mesh = p2d_mesh spatial_methods = { "macroscale": pybamm.FiniteVolume(), "negative particle": pybamm.FiniteVolume(), diff --git a/tests/unit/test_spatial_methods/test_finite_volume/test_ghost_nodes_and_neumann.py b/tests/unit/test_spatial_methods/test_finite_volume/test_ghost_nodes_and_neumann.py index 87a483f5ae..2efeef978e 100644 --- a/tests/unit/test_spatial_methods/test_finite_volume/test_ghost_nodes_and_neumann.py +++ b/tests/unit/test_spatial_methods/test_finite_volume/test_ghost_nodes_and_neumann.py @@ -6,7 +6,7 @@ import pytest import pybamm -from tests import get_mesh_for_testing, get_p2d_mesh_for_testing +from tests import get_mesh_for_testing class TestGhostNodes: @@ -102,9 +102,9 @@ def test_add_ghost_nodes_concatenation(self): + symbol_plus_ghost_both.evaluate(None, y_test)[-1] ) / 2 == 3 - def test_p2d_add_ghost_nodes(self): + def test_p2d_add_ghost_nodes(self, p2d_mesh): # create discretisation - mesh = get_p2d_mesh_for_testing() + mesh = p2d_mesh spatial_methods = { "macroscale": pybamm.FiniteVolume(), "negative particle": pybamm.FiniteVolume(), diff --git a/tests/unit/test_spatial_methods/test_finite_volume/test_grad_div_shapes.py b/tests/unit/test_spatial_methods/test_finite_volume/test_grad_div_shapes.py index 92cfb4d341..ad72ef77b3 100644 --- a/tests/unit/test_spatial_methods/test_finite_volume/test_grad_div_shapes.py +++ b/tests/unit/test_spatial_methods/test_finite_volume/test_grad_div_shapes.py @@ -12,7 +12,6 @@ get_mesh_for_testing, get_mesh_for_testing_symbolic, get_mesh_for_testing_symbolic_concatenation, - get_p2d_mesh_for_testing, get_spherical_mesh_for_testing_symbolic, ) @@ -137,7 +136,7 @@ def test_cylindrical_grad_div_shapes_Dirichlet_bcs(self): div_eval[1:-1], 4 * np.ones((npts - 2, 1)), rtol=1e-7, atol=1e-6 ) - def test_spherical_grad_div_shapes_Dirichlet_bcs(self): + def test_spherical_grad_div_shapes_Dirichlet_bcs(self, p2d_mesh): """ Test grad and div with Dirichlet boundary conditions in spherical polar coordinates @@ -212,13 +211,13 @@ def test_spherical_grad_div_shapes_Dirichlet_bcs(self): div_eval[:, :-1], 6 * np.ones([sec_npts, npts - 1]), rtol=1e-7, atol=1e-6 ) - def test_p2d_spherical_grad_div_shapes_Dirichlet_bcs(self): + def test_p2d_spherical_grad_div_shapes_Dirichlet_bcs(self, p2d_mesh): """ Test grad and div with Dirichlet boundary conditions in the pseudo 2-dimensional case """ # Create discretisation - mesh = get_p2d_mesh_for_testing() + mesh = p2d_mesh spatial_methods = {"negative particle": pybamm.FiniteVolume()} disc = pybamm.Discretisation(mesh, spatial_methods) prim_pts = mesh["negative particle"].npts @@ -633,13 +632,13 @@ def test_spherical_grad_div_shapes_Neumann_bcs_symbolic(self): atol=1e-6, ) - def test_p2d_spherical_grad_div_shapes_Neumann_bcs(self): + def test_p2d_spherical_grad_div_shapes_Neumann_bcs(self, p2d_mesh): """ Test grad and div with Neumann boundary conditions in the pseudo 2-dimensional case """ # Create discretisation - mesh = get_p2d_mesh_for_testing() + mesh = p2d_mesh spatial_methods = {"negative particle": pybamm.FiniteVolume()} disc = pybamm.Discretisation(mesh, spatial_methods) prim_pts = mesh["negative particle"].npts