def test_LandmarkManager_get(): lgroup = LabelledPointUndirectedGraph(points, adjacency_matrix, mask_dict) man = LandmarkManager() man._landmark_groups['test_set'] = lgroup assert(man['test_set'] is lgroup) assert is_same_array(man['test_set'].points, lgroup.points)
def test_LandmarkManager_str(): pcloud = PointCloud(points) man = LandmarkManager() man['test_set'] = pcloud out_str = man.__str__() assert len(out_str) > 0
def test_LandmarkManager_get(): lgroup = LabelledPointUndirectedGraph(points, adjacency_matrix, mask_dict) man = LandmarkManager() man._landmark_groups['test_set'] = lgroup assert (man['test_set'] is lgroup) assert is_same_array(man['test_set'].points, lgroup.points)
def test_LandmarkManager_str(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) man = LandmarkManager() man['test_set'] = pcloud out_str = man.__str__() assert (len(out_str) > 0)
def test_LandmarkManager_copy_method(): pcloud = PointCloud(points) man = LandmarkManager() man["test_set"] = pcloud man_copy = man.copy() assert man_copy["test_set"] is not man["test_set"] assert not is_same_array(man_copy["test_set"].points, man["test_set"].points)
def test_LandmarkManager_copy_method(): pcloud = PointCloud(points) man = LandmarkManager() man['test_set'] = pcloud man_copy = man.copy() assert man_copy['test_set'] is not man['test_set'] assert not is_same_array(man_copy['test_set'].points, man['test_set'].points)
def test_LandmarkManager_copy_method(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) man = LandmarkManager() man['test_set'] = pcloud man_copy = man.copy() assert (man_copy['test_set'] is not man['test_set']) assert (not is_same_array(man_copy['test_set'].lms.points, man['test_set'].lms.points))
def test_LandmarkManager_get(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) mask_dict = OrderedDict([('all', np.ones(10, dtype=np.bool))]) lgroup = LandmarkGroup(pcloud, mask_dict, copy=False) man = LandmarkManager() man._landmark_groups['test_set'] = lgroup assert(man['test_set'] is lgroup)
def test_LandmarkManager_get(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) target = PointCloud(points) mask_dict = {'all': np.ones(10, dtype=np.bool)} lgroup = LandmarkGroup(target, 'label', pcloud, mask_dict, copy=False) man = LandmarkManager(target) man._landmark_groups['test_set'] = lgroup assert_equal(man['test_set'], lgroup)
def test_LandmarkManager_copy_method(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) target = PointCloud(points, copy=True) man = LandmarkManager(target) man['test_set'] = pcloud man_copy = man.copy() assert (man_copy._target is man._target) assert (man_copy['test_set'] is not man['test_set']) assert (not is_same_array(man_copy['test_set'].lms.points, man['test_set'].lms.points)) assert_equal(man['test_set'].group_label, 'test_set')
def test_LandmarkManager_set_None_key(): lgroup = LabelledPointUndirectedGraph.init_with_all_label( points, adjacency_matrix) man = LandmarkManager() with raises(ValueError): man[None] = lgroup
def test_LandmarkManager_set_LabelledPointUndirectedGraph(): lgroup = LabelledPointUndirectedGraph(points, adjacency_matrix, mask_dict) man = LandmarkManager() man['test_set'] = lgroup assert not is_same_array(man['test_set'].points, lgroup.points) assert man['test_set']._labels_to_masks is not lgroup._labels_to_masks
def test_LandmarkManager_in(): pcloud = PointCloud(points) man = LandmarkManager() man['test_set'] = pcloud assert 'test_set' in man
def test_LandmarkManager_in(): pcloud = PointCloud(points) man = LandmarkManager() man["test_set"] = pcloud assert "test_set" in man
def test_LandmarkManager_set_PointCloud_not_copy_target(): pcloud = PointCloud(points) man = LandmarkManager() man['test_set'] = pcloud assert not is_same_array(man['test_set'].points, pcloud.points) assert_allclose(man['test_set'].points, np.ones([10, 3]))
def test_LandmarkManager_in(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) man = LandmarkManager() man['test_set'] = pcloud assert ('test_set' in man)
def test_LandmarkManager_set_PointCloud_not_copy_target(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) man = LandmarkManager() man['test_set'] = pcloud assert (not is_same_array(man['test_set'].lms.points, pcloud.points)) assert_allclose(man['test_set']['all'].points, np.ones([10, 3]))
def test_LandmarkManager_set(): lgroup = LabelledPointUndirectedGraph(points, adjacency_matrix, mask_dict) man = LandmarkManager() man['test_set'] = lgroup assert_allclose(man._landmark_groups['test_set'].points, lgroup.points) assert man._landmark_groups['test_set'].n_labels == 1
def test_LandmarkManager_set_pointcloud(): pcloud = PointCloud(points) man = LandmarkManager() man['test_set'] = pcloud new_pcloud = man['test_set'] assert new_pcloud is not pcloud assert isinstance(new_pcloud, PointCloud)
def test_LandmarkManager_del(): pcloud = PointCloud(points) man = LandmarkManager() man['test_set'] = pcloud del man['test_set'] assert man.n_groups == 0
def test_LandmarkManager_set_pointcloud(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) man = LandmarkManager() man['test_set'] = pcloud lgroup = man['test_set'] assert (lgroup.lms is not pcloud) assert_allclose(lgroup._labels_to_masks['all'], np.ones(10, dtype=np.bool))
def test_LandmarkManager_iterate(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) target = PointCloud(points) man = LandmarkManager() man['test_set'] = pcloud for l in man: assert_equal(l, 'test_set')
def test_LandmarkManager_del(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) target = PointCloud(points) man = LandmarkManager() man['test_set'] = pcloud del man['test_set'] assert_equal(man.n_groups, 0)
def test_LandmarkManager_iterate(): pcloud = PointCloud(points) man = LandmarkManager() man['test_set'] = pcloud man['test_set2'] = pcloud man['test_set3'] = pcloud for l in man: assert not is_same_array(man[l].points, pcloud.points) assert len(man) == 3
def test_LandmarkManager_set_LandmarkGroup(): points = np.ones((10, 3)) mask_dict = OrderedDict([('all', np.ones(10, dtype=np.bool))]) pcloud = PointCloud(points, copy=False) lgroup = LandmarkGroup(pcloud, mask_dict, copy=False) man = LandmarkManager() man['test_set'] = lgroup assert (not is_same_array(man['test_set'].lms.points, lgroup.lms.points)) assert_allclose(man['test_set']['all'].points, np.ones([10, 3])) assert (man['test_set']._labels_to_masks is not lgroup._labels_to_masks)
def test_LandmarkManager_set(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) mask_dict = OrderedDict([('all', np.ones(10, dtype=np.bool))]) lgroup = LandmarkGroup(pcloud, mask_dict, copy=False) man = LandmarkManager() man['test_set'] = lgroup assert_allclose(man._landmark_groups['test_set'].lms.points, lgroup.lms.points) assert_equal(man._landmark_groups['test_set'].n_labels, 1)
def test_LandmarkManager_group_order(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) target = PointCloud(points) man = LandmarkManager() man["test_set"] = pcloud.copy() man["abc"] = pcloud.copy() man["def"] = pcloud.copy() assert_equal(list(man._landmark_groups.keys()), ["test_set", "abc", "def"]) # check that after deleting and inserting the order will remain the same. del man["test_set"] man["tt"] = pcloud.copy() assert_equal(list(man._landmark_groups.keys()), ["abc", "def", "tt"])
def test_LandmarkManager_group_order(): points = np.ones((10, 3)) pcloud = PointCloud(points, copy=False) target = PointCloud(points) man = LandmarkManager() man['test_set'] = pcloud.copy() man['abc'] = pcloud.copy() man['def'] = pcloud.copy() assert_equal(list(man._landmark_groups.keys()), ['test_set', 'abc', 'def']) # check that after deleting and inserting the order will remain the same. del man['test_set'] man['tt'] = pcloud.copy() assert_equal(list(man._landmark_groups.keys()), ['abc', 'def', 'tt'])
def as_menpo_img(self): """ Converts image to menpo image Returns ------- menpo.image.Image: current image as menpo image """ menpo_img = Image(self.img) lmk = self.lmk menpo_lmk = PointCloud(self.lmk) lmk_manager = LandmarkManager() lmk_manager["LMK"] = menpo_lmk menpo_img.landmarks = lmk_manager return menpo_img
def test_landmarkmanager_view_widget(): l = LandmarkManager() l['test'] = PointCloud(pcloud2d) with raises(MenpowidgetsMissingError): l.view_widget()
def landmarkmanager_view_widget_test(): LandmarkManager().view_widget() assert 1
def landmarkmanager_view_widget_test(): l = LandmarkManager() l['test'] = PointCloud(pcloud2d) l.view_widget() assert 1
def test_LandmarkManager_set_None_key(): pcloud = PointCloud(np.ones((10, 3)), copy=False) lgroup = LandmarkGroup.init_with_all_label(pcloud) man = LandmarkManager() man[None] = lgroup