Exemplo n.º 1
0
 def test_equal(self):
     coord1 = self.create_coord()
     coord2 = self.create_coord()
     # print('coord1: {}'.format(coord1))
     # print('coord2: {}'.format(coord2))
     # print('equal: {}'.format(coord1 == coord2))
     self.assertTrue(all(coord1 == coord2))
     self.assertTrue(
         coordinate.Coordinate(nm=1000.) == coordinate.Coordinate(um=1.))
Exemplo n.º 2
0
    def test_set_pixelsize(self):
        # setting pixelsize to a number
        coord = self.create_coord()
        coord.pixelsize = 100.
        # print('pixelsize: {}'.format(coord.pixelsize))
        # print('length: {}'.format(len(coord)))
        # print('coord: {}'.format(coord))
        self.assertTrue(all(coord['px'] == np.array([50, 60])))

        # setting pixelsize to an array
        coord = self.create_coord()
        coord.pixelsize = [20, 20]
        self.assertTrue(all(coord['px'] == np.array([250, 300])))

        # setting pixelsize to a Coordinate
        coord = self.create_coord()
        coord.pixelsize = coordinate.Coordinate(nm=(50, 50))
Exemplo n.º 3
0
 def test_divide(self):
     intended_result = coordinate.Coordinate(um=(2.5, 3.))
     start_coord = self.create_coord()
     self.assertTrue(all(start_coord / 2. == intended_result))
     self.assertTrue(all(start_coord / [2., 2] == intended_result))
Exemplo n.º 4
0
 def test_mul(self):
     intended_result = coordinate.Coordinate(um=(10., 12))
     start_coord = self.create_coord()
     n = 2
     self.assertTrue(all(start_coord * n == intended_result))
     self.assertTrue(all(start_coord * np.array((n, n)) == intended_result))
Exemplo n.º 5
0
 def test_sum(self):
     intended_result = coordinate.Coordinate(um=(7., 6.))
     start_coord = coordinate.Coordinate(um=(5., 6.))
     to_add = coordinate.Coordinate(um=(2., 0.))
     result = start_coord + to_add
     self.assertTrue(np.all(intended_result == result))
Exemplo n.º 6
0
 def create_coord(self):
     return coordinate.Coordinate(um=(5., 6))