From 8f1908729d38b3bfb2df564dd1f267af9aad76a7 Mon Sep 17 00:00:00 2001 From: David Zwicker Date: Mon, 27 Jan 2025 12:01:17 +0100 Subject: [PATCH] Add tests for disabling legacy boundary conditions in UnitGrid --- .../boundaries/test_axes_boundaries_legacy.py | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/grids/boundaries/test_axes_boundaries_legacy.py b/tests/grids/boundaries/test_axes_boundaries_legacy.py index d10a0565..87b7e44f 100644 --- a/tests/grids/boundaries/test_axes_boundaries_legacy.py +++ b/tests/grids/boundaries/test_axes_boundaries_legacy.py @@ -7,7 +7,7 @@ import numpy as np import pytest -from pde import ScalarField, UnitGrid +from pde import ScalarField, UnitGrid, config from pde.grids.base import PeriodicityError from pde.grids.boundaries.axes import ( BCDataError, @@ -79,3 +79,23 @@ def test_boundaries_property_legacy(): g = UnitGrid([2, 2], periodic=[True, False]) bc = BoundariesBase.from_data("auto_periodic_neumann", grid=g) assert len(list(bc.boundaries)) == 2 + + +def test_boundary_specifications_legacy_disabled(): + """Test disabling legacy boundary conditions.""" + accept_lists = config["boundaries.accept_lists"] + config["boundaries.accept_lists"] = False + + g = UnitGrid([2]) + with pytest.raises(BCDataError): + bc1 = BoundariesBase.from_data( + [{"type": "derivative", "value": 0}, {"type": "value", "value": 0}], grid=g + ) + with pytest.raises(BCDataError): + BoundariesBase.from_data([{"type": "derivative"}, {"type": "value"}], grid=g) + with pytest.raises(BCDataError): + BoundariesBase.from_data([{"derivative": 0}, {"value": 0}], grid=g) + with pytest.raises(BCDataError): + BoundariesBase.from_data(["neumann", "dirichlet"], grid=g) + + config["boundaries.accept_lists"] = accept_lists