Skip to content

Commit

Permalink
use dtype's fields PyObject* now
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Jun 17, 2024
1 parent c03f987 commit 7c18e18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/pdal/PyArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ Array::Array(PyArrayObject* array) : m_array(array), m_rowMajor(true)
PyArray_Descr *dtype = PyArray_DTYPE(m_array);
npy_intp ndims = PyArray_NDIM(m_array);
npy_intp *shape = PyArray_SHAPE(m_array);
int numFields = (dtype->fields == Py_None) ?

PyObject* fields = PyDataType_FIELDS(dtype);
int numFields = (fields == Py_None) ?
0 :
static_cast<int>(PyDict_Size(dtype->fields));
static_cast<int>(PyDict_Size(fields));

int xyz = 0;
if (numFields == 0)
Expand All @@ -110,7 +112,7 @@ Array::Array(PyArrayObject* array) : m_array(array), m_rowMajor(true)
}
else
{
PyObject *names_dict = dtype->fields;
PyObject *names_dict = fields;
PyObject *names = PyDict_Keys(names_dict);
PyObject *values = PyDict_Values(names_dict);
if (!names || !values)
Expand Down
5 changes: 4 additions & 1 deletion src/pdal/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def print_version(args):

line = '----------------------------------------------------------------------------------------------------------------------------\n'
version = f'PDAL version {pdal_version}\nPython bindings version {__version__}\n'
plugin = f"Environment-set PDAL_DRIVER_PATH: {os.environ['PDAL_DRIVER_PATH']}"
driver_path = 'PDAL_DRIVER_PATH not set!'
if 'PDAL_DRIVER_PATH' in os.environ:
driver_path = os.environ['PDAL_DRIVER_PATH']
plugin = f"Environment-set PDAL_DRIVER_PATH: {driver_path}"
output = f'{line}{version}{plugin}\n{line}\n{debug}'
print (output)

Expand Down

0 comments on commit 7c18e18

Please sign in to comment.