Esempio n. 1
0
 def setUp(self):
     # arguments and keywords
     self.points = [(0, 0), (1, 0), (0, 2)]
     self.amorph = ROISelector.Amorph(self.points)
     # # verbosity
     self.v = {'verbose': 1}
     print("")
     print(self.separator)
     print(self.shortDescription())
Esempio n. 2
0
 def test_add_point(self):
     """ # ROISelector.Amorph.add_point """
     # add point to grid points
     print(">>> {}".format((5, 5)))
     amorph = ROISelector.Amorph(np.flip(np.indices((3, 3)).T, 2))
     amorph = amorph.add_point((5, 5), **self.v)
     print(amorph.N)
     self.assertIsInstance(amorph, ROISelector.Amorph)
     # add point to flat points
     print(">>> {}".format((5, 5)))
     self.amorph.add_point((5, 5), **self.v)
     self.assertIsInstance(self.amorph, ROISelector.Amorph)
Esempio n. 3
0
 def test_contains(self):
     """ # ROISelector.Amorph.contains """
     # in flat points
     points = np.array([(5, 5), (0, 0), (1, 0)]).T
     print(">>> {}".format(points))
     self.amorph = self.amorph.add_point((5, 0), **self.v)
     self.amorph.contains(*points, **self.v)
     # in grid points
     print(">>> {}".format(points))
     amorph = ROISelector.Amorph(np.flip(np.indices((4, 4)).T, -1),
                                 **self.v)
     print(np.array([(5, 5), (3, 2), (0, 0), (1, 0)]).T)
     amorph.contains(*np.array([(5, 5), (3, 2), (0, 0), (1, 0)]).T,
                     **self.v)
Esempio n. 4
0
 def test_Amorph(self):
     """ # ROISelector.Amorph """
     # with list
     print(">>> {}".format(self.points))
     amorph = ROISelector.Amorph(self.points, **self.v)
     self.assertIsInstance(amorph, ROISelector.Amorph)
     self.assertTrue(np.all(amorph == self.amorph))
     # with tuple
     print(">>> {}".format(tuple(self.points)))
     amorph = ROISelector.Amorph(*self.points, **self.v)
     self.assertIsInstance(amorph, ROISelector.Amorph)
     self.assertTrue(np.all(amorph == self.amorph))
     # with numpy array
     print(">>> {}".format(np.flip(np.indices((3, 3)).T, 2)))
     amorph = ROISelector.Amorph(np.flip(np.indices((3, 3)).T, 2), **self.v)
     self.assertIsInstance(amorph, ROISelector.Amorph)
     self.assertFalse(np.all(amorph == self.amorph))
     self.assertIsInstance(amorph[:2, :2, :], ROISelector.Amorph)
     # single-point input (separate)
     print(">>> {}".format((0, 0)))
     amorph = ROISelector.Amorph(0, 0, **self.v)
     self.assertIsInstance(amorph, ROISelector.Amorph)
     self.assertFalse(np.all(amorph == self.amorph))