From dc6a41e55863aa3fa8c17f2b0475f4b2bbac6a8e Mon Sep 17 00:00:00 2001 From: brycefrank Date: Sun, 20 Oct 2019 10:52:52 -0700 Subject: [PATCH] Some small edits, tweaks to testing suite. --- pyfor/cloud.py | 4 ++-- pyfor/rasterizer.py | 1 - pyfortest/test_pyfor.py | 16 +++------------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/pyfor/cloud.py b/pyfor/cloud.py index 31a51f0..b6348b7 100644 --- a/pyfor/cloud.py +++ b/pyfor/cloud.py @@ -158,7 +158,7 @@ def from_pdal(cls, ins): df = df.rename( columns={"X": "x", "Y": "y", "Z": "z", "ReturnNumber": "return_num"} ) - cloud_data = pyfor.cloud.CloudData(df, header=None) + cloud_data = CloudData(df, header=None) return cls(cloud_data) def _get_las_points(self, las): @@ -414,7 +414,7 @@ def chm(self, cell_size, interp_method=None, pit_filter=None, kernel_size=3): def standard_metrics(self, heightbreak=0): from pyfor.metrics import standard_metrics_cloud - return standard_metrics_cloud(self.data.points) + return standard_metrics_cloud(self.data.points, heightbreak) @property def convex_hull(self): diff --git a/pyfor/rasterizer.py b/pyfor/rasterizer.py index 340de26..23b41e1 100644 --- a/pyfor/rasterizer.py +++ b/pyfor/rasterizer.py @@ -261,7 +261,6 @@ def force_extent(self, bbox): self.array = self.array[:bot_diff, :] # Handle the affine transformation - # new_affine = from_origin(old_left + ((-left_diff) * self.grid.cell_size), old_top - (top_diff * self.grid.cell_size), self.grid.cell_size, self.grid.cell_size) new_affine = from_origin( new_left, new_top, self.grid.cell_size, self.grid.cell_size ) diff --git a/pyfortest/test_pyfor.py b/pyfortest/test_pyfor.py index fe8465e..339a5e8 100644 --- a/pyfortest/test_pyfor.py +++ b/pyfortest/test_pyfor.py @@ -233,6 +233,8 @@ def test_update(self): self.test_grid.cloud.data.points = self.test_grid.cloud.data.points.iloc[1:50] self.test_grid._update() post = self.test_grid.m + self.assertEqual(pre, 200) + self.assertEqual(post, 1) class GridMetricsTestCase(unittest.TestCase): @@ -271,6 +273,7 @@ def test_total_returns(self): def test_standard_metrics(self): metrics_dict = metrics.standard_metrics_grid(self.test_grid, 2) + self.assertEqual(len(metrics_dict), 25) class CloudMetrcsTestCase(unittest.TestCase): @@ -391,19 +394,6 @@ def test_array_to_raster_writes(self): self.assertTrue(os.path.exists(os.path.join(data_dir, "temp_raster_array.tif"))) os.remove(os.path.join(data_dir, "temp_raster_array.tif")) - def test_raster_output_transform(self): - """ - Tests if the written raster output was rotated and transformed correctly. - :return: - """ - pass - - def test_array_to_polygon(self): - array = np.random.randint(1, 5, size=(99, 99)).astype(np.int32) - gisexport.array_to_polygons(array, self.test_raster._affine) - gisexport.array_to_polygons(array) - - class VoxelGridTestCase(unittest.TestCase): def setUp(self): self.test_voxel_grid = voxelizer.VoxelGrid(cloud.Cloud(test_las), cell_size=2)