Skip to content

Commit 1385891

Browse files
committed
Misc tweaks
1 parent 11e5cb9 commit 1385891

File tree

5 files changed

+28
-51
lines changed

5 files changed

+28
-51
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,17 @@ jobs:
4343
- name: Install
4444
shell: bash -l {0}
4545
run: |
46-
python setup.py install -- -G "Ninja" -DWITH_TESTS=ON
46+
python setup.py develop -- -G "Ninja" -DWITH_TESTS=ON
4747
pdal --drivers
4848
4949
- name: Test
5050
shell: bash -l {0}
5151
run: |
52-
pip install -e .
5352
SKPATH=$(python -c "import skbuild; print (skbuild.constants.SKBUILD_DIR())")/cmake-build
5453
export PDAL_DRIVER_PATH=$SKPATH
55-
ls $SKPATH
5654
$SKPATH/pdal_filters_python_test
5755
$SKPATH/pdal_io_numpy_test
58-
py.test
56+
py.test -v
5957
6058
windows:
6159
name: ${{ matrix.os }} - ${{ matrix.python-version }}
@@ -84,21 +82,19 @@ jobs:
8482
shell: cmd /C CALL "{0}"
8583
run: |
8684
call conda activate test
87-
where python
8885
python setup.py develop -- -G "Ninja" -DWITH_TESTS=ON
86+
pdal --drivers
8987
9088
- name: Test
9189
shell: cmd /C CALL "{0}"
9290
run: |
9391
call conda activate test
9492
set PYTHONHOME=%CONDA_PREFIX%
95-
py.test
9693
for /f %%i in ('python -c "import skbuild; print (skbuild.constants.SKBUILD_DIR())"') do set SKPATH=%%i
9794
set PDAL_DRIVER_PATH=%SKPATH%\cmake-build
9895
%SKPATH%\cmake-build\pdal_filters_python_test.exe
9996
%SKPATH%\cmake-build\pdal_io_numpy_test.exe
100-
pdal --version
101-
pdal --drivers
97+
py.test -v
10298
10399
dist:
104100
name: Distribution

pdal/CMakeLists.txt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
set(EXTENSION_SRC
2-
PyArray.cpp
3-
PyArray.hpp
4-
PyDimension.hpp
5-
PyPipeline.cpp
6-
PyPipeline.hpp)
1+
set(EXTENSION_SRC PyArray.cpp PyPipeline.cpp)
72

83
set(extension "libpdalpython")
94
add_cython_target(${extension} "libpdalpython.pyx" CXX PY3)
10-
115
add_library(${extension} MODULE ${EXTENSION_SRC} libpdalpython)
12-
target_include_directories( ${extension}
13-
PRIVATE
14-
.
15-
${PDAL_INCLUDE_DIRS}
16-
${Python3_INCLUDE_DIRS}
17-
${Python3_NumPy_INCLUDE_DIRS})
18-
6+
target_include_directories(${extension} PRIVATE . ${Python3_NumPy_INCLUDE_DIRS})
197
target_link_libraries(${extension} ${PDAL_LIBRARIES})
208
python_extension_module(${extension})
219

2210
install(TARGETS ${extension} LIBRARY DESTINATION "pdal")
23-
24-

pdal/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
__version__ = "2.4.2"
22
__all__ = ["Pipeline", "Stage", "Reader", "Filter", "Writer", "dimensions", "info"]
33

4+
from . import libpdalpython
45
from .drivers import inject_pdal_drivers
5-
from .libpdalpython import getDimensions, getInfo
66
from .pipeline import Filter, Pipeline, Reader, Stage, Writer
77

88
inject_pdal_drivers()
9-
dimensions = getDimensions()
10-
info = getInfo()
9+
dimensions = libpdalpython.getDimensions()
10+
info = libpdalpython.getInfo()
1111

12-
del inject_pdal_drivers, getDimensions, getInfo
12+
del inject_pdal_drivers, libpdalpython

pdal/libpdalpython.pyx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,6 @@ cdef class Pipeline:
119119
cdef vector[shared_ptr[Array]] _inputs
120120
cdef int _loglevel
121121

122-
def __dealloc__(self):
123-
self.inputs = []
124-
125-
def __copy__(self):
126-
cdef Pipeline clone = self.__class__()
127-
clone._inputs = self._inputs
128-
return clone
129-
130122
def execute(self):
131123
return self._get_executor().execute()
132124

@@ -194,23 +186,25 @@ cdef class Pipeline:
194186

195187
#========= non-public properties & methods ===========================================
196188

197-
@property
198-
def _json(self):
199-
raise NotImplementedError("Abstract property")
189+
def _get_json(self):
190+
raise NotImplementedError("Abstract method")
200191

201192
@property
202193
def _has_inputs(self):
203194
return not self._inputs.empty()
204195

196+
def _copy_inputs(self, Pipeline other):
197+
self._inputs = other._inputs
198+
205199
def _del_executor(self):
206200
self._executor.reset()
207201

208202
cdef PipelineExecutor* _get_executor(self) except NULL:
209203
if not self._executor:
210-
json_bytes = self._json.encode("UTF-8")
211-
executor = new PipelineExecutor(json_bytes)
204+
json = self._get_json()
205+
executor = new PipelineExecutor(json)
212206
executor.setLogLevel(self._loglevel)
213-
readPipeline(executor, json_bytes)
207+
readPipeline(executor, json)
214208
addArrayReaders(executor, self._inputs)
215209
self._executor.reset(executor)
216210
return self._executor.get()

pdal/pipeline.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
from typing import Any, Container, Dict, Iterator, List, Optional, Sequence, Union, cast
77

88
import numpy as np
9+
910
try:
1011
from meshio import Mesh
11-
except ModuleNotFoundError:
12+
except ModuleNotFoundError: # pragma: no cover
1213
Mesh = None
1314

1415
from . import libpdalpython
1516

16-
1717
LogLevelToPDAL = {
1818
logging.ERROR: 0,
1919
logging.WARNING: 1,
@@ -30,6 +30,7 @@ def __init__(
3030
arrays: Sequence[np.ndarray] = (),
3131
loglevel: int = logging.ERROR,
3232
):
33+
super().__init__()
3334
self._stages: List[Stage] = []
3435
if spec:
3536
stages = _parse_stages(spec) if isinstance(spec, str) else spec
@@ -79,12 +80,13 @@ def __or__(self, other: Union[Stage, Pipeline]) -> Pipeline:
7980
return new
8081

8182
def __copy__(self) -> Pipeline:
82-
clone = cast(Pipeline, super().__copy__())
83+
clone = self.__class__(loglevel=self.loglevel)
84+
clone._copy_inputs(self)
8385
clone |= self
8486
return clone
8587

86-
def get_meshio(self, idx: int) -> Mesh:
87-
if Mesh is None:
88+
def get_meshio(self, idx: int) -> Optional[Mesh]:
89+
if Mesh is None: # pragma: no cover
8890
raise RuntimeError(
8991
"The get_meshio function can only be used if you have installed meshio. "
9092
"Try pip install meshio"
@@ -98,8 +100,7 @@ def get_meshio(self, idx: int) -> Mesh:
98100
[("triangle", np.stack((mesh["A"], mesh["B"], mesh["C"]), 1))],
99101
)
100102

101-
@property
102-
def _json(self) -> str:
103+
def _get_json(self) -> str:
103104
options_list = []
104105
stage2tag: Dict[Stage, str] = {}
105106
for stage in self._stages:
@@ -134,8 +135,8 @@ def inputs(self) -> List[Union[Stage, str]]:
134135
def options(self) -> Dict[str, Any]:
135136
return dict(self._options)
136137

137-
def pipeline(self, *arrays: np.ndarray) -> Pipeline:
138-
return Pipeline((self,), arrays)
138+
def pipeline(self, *arrays: np.ndarray, loglevel: int = logging.ERROR) -> Pipeline:
139+
return Pipeline((self,), arrays, loglevel)
139140

140141
def __or__(self, other: Union[Stage, Pipeline]) -> Pipeline:
141142
return Pipeline((self, other))

0 commit comments

Comments
 (0)