Skip to content

Commit bda2778

Browse files
committed
Parametrize pipeline iterator tests by filename and add copy of range.json test pipeline as Python expression
1 parent 945b16e commit bda2778

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

pdal/libpdalpython.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ cdef class Pipeline(PipelineResultsMixin):
239239
addArrayReaders(executor, self._inputs)
240240

241241

242+
@cython.internal
242243
cdef class PipelineIterator(PipelineResultsMixin):
243244
cdef unique_ptr[StreamableExecutor] _executor
244245

test/data/range.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reader("test/data/autzen-utm.las") | Filter.range(limits="Intensity[80:120)")

test/test_pipeline.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,10 @@ def test_meshio(self, filename):
409409

410410
class TestPipelineIterator:
411411

412-
def test_array(self):
412+
@pytest.mark.parametrize("filename", ["range.json", "range.py"])
413+
def test_array(self, filename):
413414
"""Can we fetch PDAL data as numpy arrays"""
414-
r = get_pipeline("range.json")
415+
r = get_pipeline(filename)
415416
count = r.execute()
416417
arrays = r.arrays
417418
assert len(arrays) == 1
@@ -424,19 +425,21 @@ def test_array(self):
424425
concat_array = np.concatenate(arrays)
425426
np.testing.assert_array_equal(array, concat_array)
426427

427-
def test_StopIteration(self):
428+
@pytest.mark.parametrize("filename", ["range.json", "range.py"])
429+
def test_StopIteration(self, filename):
428430
"""Is StopIteration raised when the iterator is exhausted"""
429-
r = get_pipeline("range.json")
431+
r = get_pipeline(filename)
430432
it = r.iterator(chunk_size=100)
431433
for array in it:
432434
assert isinstance(array, np.ndarray)
433435
with pytest.raises(StopIteration):
434436
next(it)
435437
assert next(it, None) is None
436438

437-
def test_metadata(self):
439+
@pytest.mark.parametrize("filename", ["range.json", "range.py"])
440+
def test_metadata(self, filename):
438441
"""Can we fetch PDAL metadata"""
439-
r = get_pipeline("range.json")
442+
r = get_pipeline(filename)
440443
r.execute()
441444

442445
it = r.iterator(chunk_size=100)
@@ -445,9 +448,10 @@ def test_metadata(self):
445448

446449
assert r.metadata == it.metadata
447450

448-
def test_schema(self):
451+
@pytest.mark.parametrize("filename", ["range.json", "range.py"])
452+
def test_schema(self, filename):
449453
"""Fetching a schema works"""
450-
r = get_pipeline("range.json")
454+
r = get_pipeline(filename)
451455
r.execute()
452456

453457
it = r.iterator(chunk_size=100)
@@ -476,9 +480,10 @@ def test_merged_arrays(self):
476480
np.testing.assert_array_equal(np.concatenate(streaming_arrays),
477481
non_streaming_array)
478482

479-
def test_premature_exit(self):
483+
@pytest.mark.parametrize("filename", ["range.json", "range.py"])
484+
def test_premature_exit(self, filename):
480485
"""Can we stop iterating before all arrays are fetched"""
481-
r = get_pipeline("range.json")
486+
r = get_pipeline(filename)
482487
r.execute()
483488
assert len(r.arrays) == 1
484489
array = r.arrays[0]
@@ -488,9 +493,10 @@ def test_premature_exit(self):
488493
np.testing.assert_array_equal(array2, array[:len(array2)])
489494
break
490495

491-
def test_multiple_iterators(self):
496+
@pytest.mark.parametrize("filename", ["range.json", "range.py"])
497+
def test_multiple_iterators(self, filename):
492498
"""Can we create multiple independent iterators"""
493-
r = get_pipeline("range.json")
499+
r = get_pipeline(filename)
494500
it1 = r.iterator(chunk_size=100)
495501
it2 = r.iterator(chunk_size=100)
496502
for a1, a2 in zip(it1, it2):

0 commit comments

Comments
 (0)