예제 #1
0
    def test_correctTimesLogged(self):
        log = read(self.test_file_path)['log']

        self.assertListEqual([2018, 1, 18, 16, 1, 0, 3, 18, -1],
                             list(log[0]['time'].timetuple()))
        self.assertListEqual([2018, 1, 18, 16, 3, 0, 3, 18, -1],
                             list(log[1]['time'].timetuple()))
예제 #2
0
 def test_correctPoints(self):
     data = read(self.test_file_path)
     points = data[keys.point]
     point = np.array([
         points['x']['data'][0], points['y']['data'][0],
         points['z']['data'][0], points['return']['data'][0]
     ])
     np.testing.assert_allclose(point, np.array([0.11, 0.12, 0.13, 1]))
예제 #3
0
from laserchicken.feature_extractor import *
from laserchicken.feature_extractor.pulse_penetration_feature_extractor import GROUND_TAGS
from laserchicken.keys import point, normalized_height
from laserchicken.utils import copy_point_cloud
from laserchicken.volume_specification import InfiniteCylinder, Cell
from . import compute_features
from .feature_map import create_default_feature_map, _create_name_extractor_pairs

np.random.seed(1234)

_TEST_FILE_NAME = 'AHN3.ply'
_TEST_NEIGHBORHOODS_FILE_NAME = 'AHN3_1000_random_neighbors.json'
_TEST_DATA_SOURCE = 'testdata'

_CYLINDER = InfiniteCylinder(4)
_PC_260807 = read_ply.read(os.path.join(_TEST_DATA_SOURCE, _TEST_FILE_NAME))
_PC_1000 = copy_point_cloud(_PC_260807,
                            array_mask=(np.random.choice(range(
                                len(_PC_260807[keys.point]['x']['data'])),
                                                         size=1000,
                                                         replace=False)))
_PC_10 = copy_point_cloud(_PC_260807,
                          array_mask=(np.random.choice(range(
                              len(_PC_260807[keys.point]['x']['data'])),
                                                       size=10,
                                                       replace=False)))
_1000_NEIGHBORHOODS_IN_260807 = next(
    compute_neighbors.compute_neighborhoods(_PC_260807,
                                            _PC_1000,
                                            _CYLINDER,
                                            sample_size=500))
예제 #4
0
    def test_correctModulesLogged(self):
        log = read(self.test_file_path)['log']

        modules = [entry['module'] for entry in log]
        self.assertListEqual(['load', 'filter'], modules)
예제 #5
0
    def test_allLogEntriesContainAllColumns(self):
        log = read(self.test_file_path)['log']

        for entry in log:
            for key in ['time', 'module', 'parameters', 'version']:
                self.assertIn(key, entry)
예제 #6
0
 def test_correctPointCloudWithInvalidComments(self):
     """Invalid comments should not cause error."""
     data = read(self.test_file_with_invalid_comments_path)
     point_cloud = data['pointcloud']
     offset = point_cloud['offset']['data'][0]
     np.testing.assert_allclose(offset, 12.1)
예제 #7
0
 def test_correctPointCloudWithoutComments(self):
     """Missing comment section should not cause error (regression test)."""
     data = read(self.test_file_without_comments_path)
     point_cloud = data['pointcloud']
     offset = point_cloud['offset']['data'][0]
     np.testing.assert_allclose(offset, 12.1)
예제 #8
0
 def test_correctPointCloud(self):
     data = read(self.test_file_path)
     point_cloud = data['pointcloud']
     offset = point_cloud['offset']['data'][0]
     np.testing.assert_allclose(offset, 12.1)
예제 #9
0
 def test_rightNumberOfPoints(self):
     data = read(self.test_file_path)
     self.assertEqual(len(data[keys.point]['x']['data']), 3)
예제 #10
0
 def test_containsXElement(self):
     data = read(self.test_file_path)
     self.assertIn('x', data[keys.point])
예제 #11
0
 def test_containsPointsElement(self):
     data = read(self.test_file_path)
     self.assertIn(keys.point, data)
예제 #12
0
 def test_existentPly_noError(self):
     read(self.test_file_path)
예제 #13
0
 def test_wrongFormat_error(self):
     with raises(ValueError):
         read(self.las_file_path)
예제 #14
0
 def test_nonexistentFile_error(self):
     # Catch most specific subclass of FileNotFoundException (3.6) and IOError (2.7).
     with raises(Exception):
         read('nonexistentfile.ply')