Skip to content

Commit

Permalink
Add test for SpanSet.asArray
Browse files Browse the repository at this point in the history
  • Loading branch information
fred3m committed Oct 28, 2022
1 parent 51b1b0c commit 74d4f73
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/test_spanSets.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,23 @@ def testSpanIteration(self):
self.assertEqual(len(span), len(points))
self.assertEqual(points, [lsst.geom.Point2I(x, 4) for x in range(3, 9)])

def testAsArray(self):
spans = afwGeom.SpanSet(lsst.geom.Box2I(lsst.geom.Point2I(2, 3), lsst.geom.Point2I(6, 7)))
truth = np.ones((5, 5), dtype=bool)
arr = spans.asArray()
np.testing.assert_array_equal(arr, truth)

shape = (10, 10)
truth = np.zeros(shape, dtype=bool)
truth[:5, :5] = 1
arr = spans.asArray(shape)
np.testing.assert_array_equal(arr, truth)

truth = np.zeros(shape, dtype=bool)
truth[3:8, 2:7] = 1
arr = spans.asArray(shape, (0, 0))
np.testing.assert_array_equal(arr, truth)


class TestMemory(lsst.utils.tests.MemoryTestCase):
pass
Expand Down

0 comments on commit 74d4f73

Please sign in to comment.