Build refinement transfers from union and pin physical body support
This commit is contained in:
1 parent
1e8e2c9a69
commit
fbe73779c1
13 files changed
+357
-106
No files matched your search
@@ -181,14 +181,14 @@ class FixedPatchSetTests(unittest.TestCase):
|
||||
ly, lx = p.fine_shape
|
||||
np.testing.assert_array_equal(s.fine_kind[y0:y0 + ly, x0:x0 + lx], p.fine_kind)
|
||||
gy, gx = np.divmod(p.ghost_fine.astype(np.int64), lx)
|
||||
np.testing.assert_array_equal(s.ghost_fine[cells:cells + len(gy)],
|
||||
(gy + y0) * fx + gx + x0)
|
||||
np.testing.assert_array_equal(s.ghost_coarse[cells:cells + len(gy)], p.ghost_coarse)
|
||||
ghosts = dict(zip(map(int, s.ghost_fine), map(int, s.ghost_coarse)))
|
||||
for f, c in zip((gy + y0) * fx + gx + x0, p.ghost_coarse):
|
||||
self.assertEqual(ghosts[int(f)], int(c))
|
||||
q, c = np.divmod(p.coalesce_fine.astype(np.int64), ly * lx)
|
||||
cy, cx = np.divmod(c, lx)
|
||||
np.testing.assert_array_equal(s.coalesce_fine[rows:rows + len(q)],
|
||||
q * fy * fx + (cy + y0) * fx + cx + x0)
|
||||
np.testing.assert_array_equal(s.coalesce_coarse[rows:rows + len(q)], p.coalesce_coarse)
|
||||
rows_by_target = dict(zip(map(int, s.coalesce_coarse), s.coalesce_fine))
|
||||
for target, children in zip(p.coalesce_coarse, q * fy * fx + (cy + y0) * fx + cx + x0):
|
||||
np.testing.assert_array_equal(rows_by_target[int(target)], children)
|
||||
rows, cells = rows + len(q), cells + len(gy)
|
||||
self.assertEqual((rows, cells), (len(s.coalesce_coarse), len(s.ghost_fine)))
|
||||
self.assertEqual(int((s.fine_kind == ACTIVE).sum()), 4 * int(s.covered.sum()))
|
||||
@@ -207,10 +207,12 @@ class FixedPatchSetTests(unittest.TestCase):
|
||||
np.testing.assert_array_equal(s.coalesce_coarse, p.coalesce_coarse)
|
||||
np.testing.assert_array_equal(s.ghost_coarse, p.ghost_coarse)
|
||||
|
||||
def test_gap_and_overlap_rejected(self):
|
||||
for gap in (0, 2, 3):
|
||||
with self.subTest(gap=gap), self.assertRaisesRegex(ValueError, "closer"):
|
||||
self.build(((4, 4, 8, 12), (8 + gap, 4, 12 + gap, 12)))
|
||||
def test_gap_and_overlap_use_dependency_checks(self):
|
||||
for gap in (-2, 0, 1, 2, 3):
|
||||
with self.subTest(gap=gap):
|
||||
pair = self.build(((4, 4, 8, 12), (8 + gap, 4, 12 + gap, 12)))
|
||||
refinement._transfer_footprint(pair)
|
||||
refinement._check_parent_pull_closure(pair)
|
||||
with self.assertRaises(ValueError):
|
||||
self.build(())
|
||||
with self.assertRaises(ValueError): # FixedPatch2D margin still applies
|
||||
@@ -226,7 +228,7 @@ class FixedPatchSetTests(unittest.TestCase):
|
||||
support[y0:y0 + p.fine_shape[0], x0:x0 + p.fine_shape[1]] = True
|
||||
np.testing.assert_array_equal(layout.owned, support)
|
||||
self.assertTrue(layout.owned.ravel()[s.ghost_fine.astype(np.intp)].all())
|
||||
with self.assertRaisesRegex(ValueError, "aligned"):
|
||||
with self.assertRaisesRegex(ValueError, "divide"):
|
||||
self.build(self.FACE).fine_layout((5, 4))
|
||||
for block in ((0, 4), (4, 0), (-4, 4), (4.0, 4), (True, 4), (4,), (4, 4, 4), (np.bool_(1), 4)):
|
||||
with self.subTest(block=block), self.assertRaisesRegex(ValueError, "positive integers"):
|
||||
|
||||
Reference in new issue
Block a user