def test_set_oob(self): # 2x2 covariance mat c = Covariance.new_covar(c_type='f') c[0, 0] = 1 # Valid set nose.tools.assert_raises(IndexError, c.__setitem__, (0, 2), 1) c = Covariance.new_covar(c_type='d') c[0, 0] = 1 # Valid set nose.tools.assert_raises(IndexError, c.__setitem__, (0, 2), 1)
def test_get_oob(self): # 2x2 covariance mat c = Covariance.new_covar(c_type='d') _ = c[0, 0] # Valid access nose.tools.assert_raises(IndexError, c.__getitem__, (0, 2)) c = Covariance.new_covar(c_type='f') _ = c[0, 0] # Valid access nose.tools.assert_raises(IndexError, c.__getitem__, (0, 2))
def test_new_identity(self): # Valid dimensions and types c = Covariance.new_covar(2, 'd') print('constructed matrix:\n', c.to_matrix()) c = Covariance.new_covar(3, 'd') print('constructed matrix:\n', c.to_matrix()) c = Covariance.new_covar(2, 'f') print('constructed matrix:\n', c.to_matrix()) c = Covariance.new_covar(3, 'f') print('constructed matrix:\n', c.to_matrix())
def test_set_oob(self): # 2x2 covariance mat c = Covariance.new_covar(c_type='f') c[0, 0] = 1 # Valid set nose.tools.assert_raises( IndexError, c.__setitem__, (0, 2), 1 ) c = Covariance.new_covar(c_type='d') c[0, 0] = 1 # Valid set nose.tools.assert_raises( IndexError, c.__setitem__, (0, 2), 1 )
def test_get_oob(self): # 2x2 covariance mat c = Covariance.new_covar(c_type='d') _ = c[0, 0] # Valid access nose.tools.assert_raises( IndexError, c.__getitem__, (0, 2) ) c = Covariance.new_covar(c_type='f') _ = c[0, 0] # Valid access nose.tools.assert_raises( IndexError, c.__getitem__, (0, 2) )
def test_covariance(self): for ct in self.ctypeS: print(ct) l = Landmark(ctype=ct) # check default #nose.tools.assert_equal(l.covariance, Covariance.new_covar(3)) # set type-aligned covariance c = Covariance.new_covar(3, ct, 7) l.covariance = c
def test_new_scalar(self): c = Covariance.new_covar(2, 'd', 2.) print('constructed matrix:\n', c.to_matrix()) c = Covariance.new_covar(3, 'd', 2.) print('constructed matrix:\n', c.to_matrix()) c = Covariance.new_covar(2, 'f', 2.) print('constructed matrix:\n', c.to_matrix()) c = Covariance.new_covar(3, 'f', 2.) print('constructed matrix:\n', c.to_matrix()) c = Covariance.new_covar(2, 'd', 14.675) print('constructed matrix:\n', c.to_matrix()) c = Covariance.new_covar(3, 'd', 14.675) print('constructed matrix:\n', c.to_matrix()) c = Covariance.new_covar(2, 'f', 14.675) print('constructed matrix:\n', c.to_matrix()) c = Covariance.new_covar(3, 'f', 14.675) print('constructed matrix:\n', c.to_matrix())
def test_get_covar(self): dflt_covar = Covariance.new_covar(2) f = Feature()