Skip to content

Commit

Permalink
Add tests for disabling legacy boundary conditions in UnitGrid
Browse files Browse the repository at this point in the history
  • Loading branch information
david-zwicker committed Jan 27, 2025
1 parent 605174e commit 8f19087
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/grids/boundaries/test_axes_boundaries_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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

0 comments on commit 8f19087

Please sign in to comment.