Skip to content

Commit 332186e

Browse files
committed
Raise RuntimeError from Cython if the pipeline has not been executed
1 parent a69b248 commit 332186e

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

pdal/PyPipeline.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ PyArrayObject* viewToNumpyArray(PointViewPtr view)
184184

185185
std::vector<PyArrayObject*> PyPipelineExecutor::getArrays() const
186186
{
187-
if (!executed())
188-
throw python_error("call execute() before fetching arrays");
189-
190187
std::vector<PyArrayObject*> output;
191188
for (auto view: getManagerConst().views())
192189
output.push_back(viewToNumpyArray(view));
@@ -248,9 +245,6 @@ PyArrayObject* meshToNumpyArray(const TriangularMesh* mesh)
248245

249246
std::vector<PyArrayObject*> PyPipelineExecutor::getMeshes() const
250247
{
251-
if (!executed())
252-
throw python_error("call execute() before fetching the mesh");
253-
254248
std::vector<PyArrayObject*> output;
255249
for (auto view: getManagerConst().views())
256250
output.push_back(meshToNumpyArray(view->mesh()));

pdal/PyPipeline.hpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,11 @@ namespace python
4545

4646
class Array;
4747

48-
class python_error : public std::runtime_error
49-
{
50-
public:
51-
inline python_error(std::string const& msg) : std::runtime_error(msg)
52-
{}
53-
};
54-
5548
class PyPipelineExecutor : public PipelineExecutor
5649
{
5750
public:
5851
PyPipelineExecutor(std::string const& json);
59-
PyPipelineExecutor(std::string const& json,
60-
std::vector<pdal::python::Array*> arrays);
61-
52+
PyPipelineExecutor(std::string const& json, std::vector<Array*> arrays);
6253
std::vector<PyArrayObject*> getArrays() const;
6354
std::vector<PyArrayObject*> getMeshes() const;
6455
};

pdal/libpdalpython.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ cdef extern from "PyPipeline.hpp" namespace "pdal::python":
6464
cdef cppclass PyPipelineExecutor:
6565
PyPipelineExecutor(const char*) except +
6666
PyPipelineExecutor(const char*, vector[Array*]&) except +
67+
bool executed() except +
6768
int64_t execute() except +
6869
bool validate() except +
6970
string getPipeline() except +
@@ -117,10 +118,14 @@ cdef class Pipeline:
117118

118119
property arrays:
119120
def __get__(self):
121+
if not self._executor.executed():
122+
raise RuntimeError("call execute() before fetching arrays")
120123
return self._vector_to_list(self._executor.getArrays())
121124

122125
property meshes:
123126
def __get__(self):
127+
if not self._executor.executed():
128+
raise RuntimeError("call execute() before fetching the mesh")
124129
return self._vector_to_list(self._executor.getMeshes())
125130

126131
def execute(self):

0 commit comments

Comments
 (0)