From 63d203796b8d1cd981a5e2585450f4cc12ffd97b Mon Sep 17 00:00:00 2001 From: John Evans Date: Wed, 2 Apr 2014 12:21:56 -0400 Subject: [PATCH] Use memoryview instead of np.getbuffer. #210 np.getbuffer is not available in python3. --- glymur/jp2box.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/glymur/jp2box.py b/glymur/jp2box.py index f62567d..92c94ba 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -1885,11 +1885,11 @@ class PaletteBox(Jp2kBox): if all(b == bps[0] for b in bps): # All components are the same. Writing is straightforward. if self.bits_per_component[0] <= 8: - write_buffer = np.getbuffer(self.palette.astype(np.uint8)) + write_buffer = memoryview(self.palette.astype(np.uint8)) elif self.bits_per_component[0] <= 16: - write_buffer = np.getbuffer(self.palette.astype(np.uint16)) + write_buffer = memoryview(self.palette.astype(np.uint16)) elif self.bits_per_component[0] <= 32: - write_buffer = np.getbuffer(self.palette.astype(np.uint32)) + write_buffer = memoryview(self.palette.astype(np.uint32)) fptr.write(write_buffer) else: # Not all the components are the same. More general, but much rarer