Exemplo n.º 1
0
    def test_type_name(self):
        # Double default
        nose.tools.assert_equal(LandmarkD().data_type, 'double')
        nose.tools.assert_equal(LandmarkF().data_type, 'float')

        nose.tools.assert_equal(LandmarkD([1, 2, 2]).data_type, 'double')
        nose.tools.assert_equal(LandmarkF([1, 2, 2]).data_type, 'float')
Exemplo n.º 2
0
 def test_new(self):
     LandmarkF()
     LandmarkD()
     LandmarkF([1, 1, 1])
     LandmarkD([1, 1, 1])
     LandmarkF([1, 1, 1], scale=10)
     LandmarkD([1, 1, 1], scale=10)
Exemplo n.º 3
0
    def test_get_scale(self):
        l = LandmarkF()
        nose.tools.assert_equal(l.scale, 1)

        l = LandmarkF([3, 4, 5], 44.5)
        nose.tools.assert_almost_equal(l.scale, 44.5, self.precs[1])

        l = LandmarkD()
        nose.tools.assert_equal(l.scale, 1)

        l = LandmarkD([3, 4, 5], 44.5)
        nose.tools.assert_almost_equal(l.scale, 44.5, self.precs[0])
Exemplo n.º 4
0
    def test_get_loc(self):
        l = LandmarkF()
        numpy.testing.assert_equal(l.loc, [0, 0, 0])

        l = LandmarkF([1, 2, 3])
        numpy.testing.assert_equal(l.loc, [1, 2, 3])

        l = LandmarkD()
        numpy.testing.assert_equal(l.loc, [0, 0, 0])

        l = LandmarkD([1, 2, 3])
        numpy.testing.assert_equal(l.loc, [1, 2, 3])
Exemplo n.º 5
0
    def test_cos_obs_angle(self):

        l = LandmarkF()
        # default
        nose.tools.assert_equal(l.cos_obs_angle, 1)
        l.cos_obs_angle = 0.5
        numpy.testing.assert_almost_equal(l.cos_obs_angle, 0.5, self.precs[1])

        l.cos_obs_angle = -0.5
        numpy.testing.assert_almost_equal(l.cos_obs_angle, -0.5, self.precs[1])
        # Can technically go outside range of cosine
        l.cos_obs_angle = 1.5
        numpy.testing.assert_almost_equal(l.cos_obs_angle, 1.5, self.precs[1])

        l.cos_obs_angle = -1.5
        numpy.testing.assert_almost_equal(l.cos_obs_angle, -1.5, self.precs[1])

        l = LandmarkD()
        # default
        nose.tools.assert_equal(l.cos_obs_angle, 1)
        l.cos_obs_angle = 0.5
        numpy.testing.assert_almost_equal(l.cos_obs_angle, 0.5, self.precs[0])

        l.cos_obs_angle = -0.5
        numpy.testing.assert_almost_equal(l.cos_obs_angle, -0.5, self.precs[0])
        # Can technically go outside range of cosine
        l.cos_obs_angle = 1.5
        numpy.testing.assert_almost_equal(l.cos_obs_angle, 1.5, self.precs[0])

        l.cos_obs_angle = -1.5
        numpy.testing.assert_almost_equal(l.cos_obs_angle, -1.5, self.precs[0])
Exemplo n.º 6
0
    def test_color(self):

        l = LandmarkF()

        # default
        nose.tools.assert_equal(l.color, RGBColor())
        c = RGBColor(0, 0, 0)
        l.color = c
        nose.tools.assert_equal(l.color, c)

        c = RGBColor(12, 240, 120)
        l.color = c
        nose.tools.assert_equal(l.color, c)

        l = LandmarkD()

        # default
        nose.tools.assert_equal(l.color, RGBColor())
        c = RGBColor(0, 0, 0)
        l.color = c
        nose.tools.assert_equal(l.color, c)

        c = RGBColor(12, 240, 120)
        l.color = c
        nose.tools.assert_equal(l.color, c)
Exemplo n.º 7
0
    def test_set_scale(self):

        l = LandmarkF()
        l.scale = 1
        nose.tools.assert_equal(l.scale, 1)

        l.scale = 2
        nose.tools.assert_equal(l.scale, 2)

        l.scale = 2.456
        nose.tools.assert_almost_equal(l.scale, 2.456, self.precs[1])

        l.scale = -2
        nose.tools.assert_almost_equal(l.scale, -2, self.precs[1])

        l = LandmarkD()
        l.scale = 1
        nose.tools.assert_equal(l.scale, 1)

        l.scale = 2
        nose.tools.assert_equal(l.scale, 2)

        l.scale = 2.456
        nose.tools.assert_almost_equal(l.scale, 2.456, self.precs[0])

        l.scale = -2
        nose.tools.assert_almost_equal(l.scale, -2, self.precs[0])
Exemplo n.º 8
0
    def test_normal(self):

        l = LandmarkF()
        numpy.testing.assert_equal(l.normal, [0, 0, 0])

        l.normal = [0, 1, 0]
        numpy.testing.assert_equal(l.normal, [0, 1, 0])

        l = LandmarkD()
        numpy.testing.assert_equal(l.normal, [0, 0, 0])

        l.normal = [0, 1, 0]
        numpy.testing.assert_equal(l.normal, [0, 1, 0])
Exemplo n.º 9
0
    def test_set_loc(self):
        l = LandmarkF()
        l.loc = [1, 1, 1]
        numpy.testing.assert_equal(l.loc, [1, 1, 1])

        l.loc = [9.12, 4.1, 8.3]
        numpy.testing.assert_almost_equal(l.loc, [9.12, 4.1, 8.3],
                                          self.precs[1])

        l = LandmarkD()
        l.loc = [1, 1, 1]
        numpy.testing.assert_equal(l.loc, [1, 1, 1])

        l.loc = [9.12, 4.1, 8.3]
        numpy.testing.assert_almost_equal(l.loc, [9.12, 4.1, 8.3],
                                          self.precs[0])
Exemplo n.º 10
0
    def test_observations(self):

        l = LandmarkF()

        # default
        nose.tools.assert_equal(l.observations, 0)

        l.observations = 42
        nose.tools.assert_equal(l.observations, 42)

        l = LandmarkD()

        # default
        nose.tools.assert_equal(l.observations, 0)

        l.observations = 42
        nose.tools.assert_equal(l.observations, 42)
Exemplo n.º 11
0
    def test_covariance(self):
        covars = [Covar3d(7), Covar3f(7)]

        l = LandmarkF()

        # check default
        numpy.testing.assert_array_equal(l.covariance.matrix(),
                                         Covar3d().matrix())

        # set type-aligned covariance
        l.covariance = covars[1]
        numpy.testing.assert_array_almost_equal(l.covariance.matrix(),
                                                covars[1].matrix(),
                                                self.precs[1])

        l = LandmarkD()
        numpy.testing.assert_array_equal(l.covariance.matrix(),
                                         Covar3d().matrix())
        l.covariance = covars[0]
        numpy.testing.assert_array_almost_equal(l.covariance.matrix(),
                                                covars[0].matrix(),
                                                self.precs[0])