コード例 #1
0
 def test_AddFeatureArray(self):
     test_data = test_tools.ComplexTestData()
     pc = test_data.get_point_cloud()
     feature_add = np.array([1, 1, 1, 1, 1], dtype=int)
     utils.update_feature(pc, 'test_feature', feature_add)
     self.assertIn('test_feature', pc[keys.point])
     self.assertTrue(
         all(pc[keys.point]['test_feature']['data'] == feature_add))
コード例 #2
0
 def test_AddFeatureArrayMask(self):
     test_data = test_tools.ComplexTestData()
     pc = test_data.get_point_cloud()
     feature_add = np.array([1, 2, 3, 4], dtype=int)
     mask = np.array([1, 1, 0, 1, 1], dtype=bool)
     utils.update_feature(pc, 'test_feature', feature_add, array_mask=mask)
     self.assertIn('test_feature', pc[keys.point])
     self.assertTrue(
         all(pc[keys.point]['test_feature']['data'] == [1, 2, 0, 3, 4]))
コード例 #3
0
 def test_extract_can_overwrite():
     target = test_tools.ComplexTestData().get_point_cloud()
     target[keys.point]['test2_b'] = {
         "type": np.float64,
         "data": [0.9, 0.99, 0.999, 0.9999]
     }
     feature_names = ['test3_a', 'test2_b']
     target = _compute_features(target, feature_names, overwrite=True)
     assert target[keys.point]['test2_b']['data'][2] == 11.5
コード例 #4
0
 def test_AddFeatureValueMaskInvalid(self):
     test_data = test_tools.ComplexTestData()
     pc = test_data.get_point_cloud()
     feature_add = 1.1
     mask = np.array([1, 1, 0, 1, 1, 1], dtype=bool)
     with pytest.raises(AssertionError):
         utils.update_feature(pc,
                              'test_feature',
                              feature_add,
                              array_mask=mask)
コード例 #5
0
 def test_AddToPointCloud(self):
     test_data = test_tools.ComplexTestData()
     pc_source = test_data.get_point_cloud()
     pc_dest = utils.copy_point_cloud(pc_source)
     utils.add_to_point_cloud(pc_dest, pc_source)
     for key in pc_source.keys():
         self.assertIn(key, pc_dest)
     for attr in pc_source[keys.point].keys():
         self.assertEqual(len(pc_dest[keys.point][attr]['data']),
                          2 * len(pc_source[keys.point][attr]['data']))
     self.assertEqual(pc_dest[keys.provenance][-1]['module'],
                      'laserchicken.utils')
コード例 #6
0
 def test_AddToPointCloudInvalid(self):
     pc_1 = test_tools.SimpleTestData.get_point_cloud()
     # invalid format
     pc_2 = {}
     with pytest.raises(TypeError):
         utils.add_to_point_cloud(pc_1, pc_2)
     with pytest.raises(AttributeError):
         utils.add_to_point_cloud(pc_2, pc_1)
     # non-matching attributes
     test_data = test_tools.ComplexTestData()
     pc_2 = test_data.get_point_cloud()
     with pytest.raises(AttributeError):
         utils.add_to_point_cloud(pc_1, pc_2)
     # different structure
     pc_2 = {'vertex': {'x': 1, 'y': 2, 'z': 3}}
     with pytest.raises(TypeError):
         utils.add_to_point_cloud(pc_1, pc_2)
     # different data types
     pc_2 = {
         'vertex': {
             'x': {
                 'data': np.zeros(3, dtype=int),
                 'type': 'int'
             },
             'y': {
                 'data': np.zeros(3, dtype=int),
                 'type': 'int'
             },
             'z': {
                 'data': np.zeros(3, dtype=int),
                 'type': 'int'
             }
         }
     }
     with pytest.raises(ValueError):
         utils.add_to_point_cloud(pc_1, pc_2)
コード例 #7
0
 def test_AddFeatureArrayInvalid(self):
     test_data = test_tools.ComplexTestData()
     pc = test_data.get_point_cloud()
     feature_add = np.array([1, 1, 1, 1, 1, 2], dtype=int)
     with pytest.raises(AssertionError):
         utils.update_feature(pc, 'test_feature', feature_add)
コード例 #8
0
 def test_extract_unknown_feature():
     with raises(ValueError):
         target = test_tools.ComplexTestData().get_point_cloud()
         _compute_features(target, ['some_unknown_feature'])
コード例 #9
0
 def test_extract_multiple_features_ends_up_in_pc():
     target = test_tools.ComplexTestData().get_point_cloud()
     feature_names = ['test3_a', 'test2_b']
     target = _compute_features(target, feature_names)
     assert ('test3_a' in target[keys.point]
             and 'test2_b' in target[keys.point])
コード例 #10
0
 def test_extract_only_requested_feature_ends_up_in_pc():
     target = test_tools.ComplexTestData().get_point_cloud()
     _compute_features(target, ['test3_a'])
     assert 'test1_b' not in target[keys.point]
コード例 #11
0
 def test_extract_single_feature_has_correct_values_in_pc():
     target = test_tools.ComplexTestData().get_point_cloud()
     _compute_features(target, ['test1_a'])
     assert all(target[keys.point]['test1_a']['data'] == 0.5 *
                target[keys.point]['z']['data'])
コード例 #12
0
 def test_extract_single_feature_ends_up_in_pc():
     target = test_tools.ComplexTestData().get_point_cloud()
     _compute_features(target, ['test3_a'])
     assert all(target[keys.point]['test3_a']['data'] == target[keys.point]
                ['z']['data'])