Skip to content

Commit

Permalink
Use adjacencylist constructor in test (#3139)
Browse files Browse the repository at this point in the history
* Use constructor.

* ruff check

* Only works for int64 - leave possibility open for later generalisation here.

* Ruff format.
  • Loading branch information
jhale committed Apr 17, 2024
1 parent a9c5de0 commit 1a63fa7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions python/test/unit/mesh/test_dual_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import numpy as np

from dolfinx import cpp as _cpp
from dolfinx import mesh
from dolfinx import graph, mesh


def to_adj(cells):
def to_adj(cells, dtype):
cflat = []
coff = [0]
for c in cells:
cflat += c
cc = coff[-1] + len(c)
coff += [cc]
adj = _cpp.graph.AdjacencyList_int64(np.array(cflat), np.array(coff))
adj = graph.adjacencylist(np.array(cflat, dtype=dtype), np.array(coff, dtype=dtype))
return adj


Expand All @@ -26,7 +25,7 @@ def test_dgrsph_1d():
x = 0
# Circular chain of interval cells
cells = [[n0, n0 + 1], [n0 + 1, n0 + 2], [n0 + 2, x]]
w = mesh.build_dual_graph(MPI.COMM_WORLD, mesh.CellType.interval, to_adj(cells))
w = mesh.build_dual_graph(MPI.COMM_WORLD, mesh.CellType.interval, to_adj(cells, np.int64))
assert w.num_nodes == 3
for i in range(w.num_nodes):
assert len(w.links(i)) == 2

0 comments on commit 1a63fa7

Please sign in to comment.