Skip to content

Commit

Permalink
use dtype's fields PyObject* now (#170)
Browse files Browse the repository at this point in the history
* use dtype's fields PyObject* now

* bump version for this to 3.4.4
  • Loading branch information
hobu committed Jun 17, 2024
1 parent c03f987 commit c70fd36
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 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
2 changes: 1 addition & 1 deletion src/pdal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__all__ = ["Pipeline", "Stage", "Reader", "Filter", "Writer", "dimensions", "info"]
__version__ = '3.4.3'
__version__ = '3.4.4'

from . import libpdalpython
from .drivers import inject_pdal_drivers
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 c70fd36

Please sign in to comment.