Skip to content

Commit

Permalink
fdlake8 (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs authored Oct 2, 2024
1 parent 7e5d2f1 commit 1201e14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bempp/api/grid/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def import_grid(filename):
if domain_indices is None or _np.all(domain_indices == 0):
try:
domain_indices = mesh.cell_data_dict["gmsh:geometrical"]["triangle"]
except:
except: # noqa: E722
pass

return Grid(vertices, elements, domain_indices=domain_indices)
Expand Down
31 changes: 20 additions & 11 deletions test/unit/grid/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,39 @@ def test_union_two_grids_one_domain_each(two_element_grid):
"""Test union of two grids, each with one domain."""

two_element_grid_2 = bempp.api.grid.Grid(two_element_grid.vertices, two_element_grid.elements)
np.testing.assert_array_equal(bempp.api.grid.union([two_element_grid, two_element_grid_2]).domain_indices, np.array([0 , 0, 1, 1], dtype="uint32"))
np.testing.assert_array_equal(
bempp.api.grid.union([two_element_grid, two_element_grid_2]).domain_indices,
np.array([0 , 0, 1, 1], dtype="uint32"))


def test_union_two_grids_two_domains_each(two_element_grid):
"""Test union of two grids, each with two domains."""

two_element_grid = bempp.api.grid.Grid(two_element_grid.vertices, two_element_grid.elements, domain_indices=[0, 1])
two_element_grid_2 = bempp.api.grid.Grid(two_element_grid.vertices, two_element_grid.elements, domain_indices=[0, 1])
np.testing.assert_array_equal(bempp.api.grid.union([two_element_grid, two_element_grid_2]).domain_indices, np.array([0, 1, 2, 3], dtype="uint32"))
two_element_grid_2 = bempp.api.grid.Grid(
two_element_grid.vertices, two_element_grid.elements, domain_indices=[0, 1])
np.testing.assert_array_equal(
bempp.api.grid.union([two_element_grid, two_element_grid_2]).domain_indices,
np.array([0, 1, 2, 3], dtype="uint32"))


def test_union_two_grids_two_domains_each_unnormalized(two_element_grid):
"""Test union of two grids, each with two domains,
and without domain index normalization."""
"""Test union of two grids, each with two domains, and without domain index normalization."""

two_element_grid = bempp.api.grid.Grid(two_element_grid.vertices, two_element_grid.elements, domain_indices=[0, 2])
two_element_grid_2 = bempp.api.grid.Grid(two_element_grid.vertices, two_element_grid.elements, domain_indices=[0, 3])
np.testing.assert_array_equal(bempp.api.grid.union([two_element_grid, two_element_grid_2], normalize_domain_indices=False).domain_indices, np.array([0, 2, 3, 6], dtype="uint32"))
two_element_grid_2 = bempp.api.grid.Grid(
two_element_grid.vertices, two_element_grid.elements, domain_indices=[0, 3])
np.testing.assert_array_equal(
bempp.api.grid.union([two_element_grid, two_element_grid_2], normalize_domain_indices=False).domain_indices,
np.array([0, 2, 3, 6], dtype="uint32"))


def test_union_two_grids_two_domains_each_normalized(two_element_grid):
"""Test union of two grids, each with two domains,
and with domain index normalization."""
"""Test union of two grids, each with two domains, and with domain index normalization."""

two_element_grid = bempp.api.grid.Grid(two_element_grid.vertices, two_element_grid.elements, domain_indices=[0, 2])
two_element_grid_2 = bempp.api.grid.Grid(two_element_grid.vertices, two_element_grid.elements, domain_indices=[0, 3])
np.testing.assert_array_equal(bempp.api.grid.union([two_element_grid, two_element_grid_2], normalize_domain_indices=True).domain_indices, np.array([0, 1, 2, 3], dtype="uint32"))
two_element_grid_2 = bempp.api.grid.Grid(
two_element_grid.vertices, two_element_grid.elements, domain_indices=[0, 3])
np.testing.assert_array_equal(
bempp.api.grid.union([two_element_grid, two_element_grid_2], normalize_domain_indices=True).domain_indices,
np.array([0, 1, 2, 3], dtype="uint32"))

0 comments on commit 1201e14

Please sign in to comment.