Skip to content
This repository was archived by the owner on Dec 30, 2023. It is now read-only.

Commit 97f5f17

Browse files
committed
Merge pull request #81 from larsmans/fixes
Fix bug in buffer protocol support
2 parents a03b8d8 + 0501b09 commit 97f5f17

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pcl/_pcl.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ cdef class SegmentationNormal:
138138
return min_angle, max_angle
139139

140140

141-
# Empirically determine strides, for buffer support.
141+
# Empirically determine strides, for buffer protocol support.
142142
# XXX Is there a more elegant way to get these?
143143
cdef Py_ssize_t _strides[2]
144144
cdef PointCloud _pc_tmp = PointCloud(np.array([[1, 2, 3],
@@ -205,9 +205,9 @@ cdef class PointCloud:
205205
cdef Py_ssize_t npoints = self.thisptr().size()
206206

207207
if self._view_count == 0:
208-
self._view_count += 1
209208
self._shape[0] = npoints
210209
self._shape[1] = 3
210+
self._view_count += 1
211211

212212
buffer.buf = <char *>&(cpp.getptr_at(self.thisptr(), 0).x)
213213
buffer.format = 'f'

tests/test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ def test_asarray(self):
5353
a[:] += 6
5454
assert_array_almost_equal(p[0], a[0])
5555

56+
# Regression test: deleting a second view would previously
57+
# reset the view count to zero.
58+
b = np.asarray(p)
59+
del b
60+
61+
self.assertRaises(ValueError, p.resize, 2 * len(p))
62+
5663
def test_pickle(self):
5764
"""Test pickle support."""
5865
# In this testcase because picking reduces to pickling NumPy arrays.

0 commit comments

Comments
 (0)