force step=>rlevel computation to result in integer

For whatever stupid reason, np.log2(x) cannot be relied upon to be an
integer when x is a power of 2 ON WIN32!!!  All hail win32!
This commit is contained in:
John Evans 2014-09-26 16:00:42 -04:00
commit 1341a15f7b

View file

@ -832,9 +832,11 @@ class Jp2k(Jp2kBox):
# one of them.
step = rows_step
if np.log2(step) != np.floor(np.log2(step)):
# Check if the step size is a power of 2.
if np.abs(np.log2(step) - np.floor(np.log2(step))) > 1e-6:
msg = "Row and column strides must be powers of 2."
raise IndexError(msg)
rlevel = np.int(np.round(np.log2(step)))
if rows.start is None:
rows_start = 0
@ -857,7 +859,7 @@ class Jp2k(Jp2kBox):
cols_stop = cols.stop
area = (rows_start, cols_start, rows_stop, cols_stop)
data = self.read(area=area, rlevel=np.int(np.log2(step)))
data = self.read(area=area, rlevel=rlevel)
if len(pargs) == 2:
return data