|
| 1 | +import sys |
1 | 2 | import unittest |
2 | 3 | import pdal |
3 | 4 | import os |
@@ -191,6 +192,37 @@ def test_read_arrays(self): |
191 | 192 | self.assertEqual(count, 2) |
192 | 193 | self.assertEqual(len(arrays), 1) |
193 | 194 |
|
| 195 | + def test_reference_counting(self): |
| 196 | + """Can we read and filter data from a list of arrays to PDAL""" |
| 197 | + if Version(pdal.info.version) < Version("1.8"): |
| 198 | + return True |
| 199 | + |
| 200 | + # just some dummy data |
| 201 | + x_vals = [1.0, 2.0, 3.0, 4.0, 5.0] |
| 202 | + y_vals = [6.0, 7.0, 8.0, 9.0, 10.0] |
| 203 | + z_vals = [1.5, 3.5, 5.5, 7.5, 9.5] |
| 204 | + test_data = np.array( |
| 205 | + [(x, y, z) for x, y, z in zip(x_vals, y_vals, z_vals)], |
| 206 | + dtype=[("X", np.float), ("Y", np.float), ("Z", np.float)], |
| 207 | + ) |
| 208 | + |
| 209 | + pipeline = """ |
| 210 | + { |
| 211 | + "pipeline": [ |
| 212 | + { |
| 213 | + "type":"filters.range", |
| 214 | + "limits":"X[2.5:4.5]" |
| 215 | + } |
| 216 | + ] |
| 217 | + } |
| 218 | + """ |
| 219 | + |
| 220 | + p = pdal.Pipeline(pipeline, arrays=[test_data]) |
| 221 | + p.loglevel = 8 |
| 222 | + count = p.execute() |
| 223 | + self.assertEqual(count, 2) |
| 224 | + self.assertEqual(1, sys.getrefcount(p.arrays[0]), "Reference count should only be 1 in this case") |
| 225 | + |
194 | 226 |
|
195 | 227 | class TestDimensions(PDALTest): |
196 | 228 | def test_fetch_dimensions(self): |
|
0 commit comments