Skip to content

Commit 005a9ac

Browse files
authored
Merge pull request #500 from jakirkham/use_math_ceil
Use `math.ceil` for scalars
2 parents 44bfc18 + 4404aa0 commit 005a9ac

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

docs/release.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Upcoming Release
3434
* Require Numcodecs 0.6.4+ to use text handling functionality from it.
3535
By :user:`John Kirkham <jakirkham>`; :issue:`497`.
3636

37+
* Use ``math.ceil`` for scalars.
38+
By :user:`John Kirkham <jakirkham>`; :issue:`500`.
39+
3740
.. _release_2.3.2:
3841

3942
2.3.2

zarr/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import binascii
33
import hashlib
44
import itertools
5+
import math
56
import operator
67
import re
78
from functools import reduce
@@ -355,7 +356,7 @@ def _cdata_shape(self):
355356
if self._shape == ():
356357
return 1,
357358
else:
358-
return tuple(int(np.ceil(s / c))
359+
return tuple(math.ceil(s / c)
359360
for s, c in zip(self._shape, self._chunks))
360361

361362
@property
@@ -2007,7 +2008,7 @@ def _resize_nosync(self, *args):
20072008

20082009
# determine the new number and arrangement of chunks
20092010
chunks = self._chunks
2010-
new_cdata_shape = tuple(int(np.ceil(s / c))
2011+
new_cdata_shape = tuple(math.ceil(s / c)
20112012
for s, c in zip(new_shape, chunks))
20122013

20132014
# remove any chunks not within range

zarr/indexing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import collections
33
import itertools
4+
import math
45
import numbers
56

67
import numpy as np
@@ -91,7 +92,7 @@ def __iter__(self):
9192

9293

9394
def ceildiv(a, b):
94-
return int(np.ceil(a / b))
95+
return math.ceil(a / b)
9596

9697

9798
class SliceDimIndexer(object):

zarr/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import inspect
33
import json
4+
import math
45
import numbers
56
import uuid
67
from textwrap import TextWrapper, dedent
@@ -92,7 +93,7 @@ def guess_chunks(shape, typesize):
9293
if np.product(chunks) == 1:
9394
break # Element size larger than CHUNK_MAX
9495

95-
chunks[idx % ndims] = np.ceil(chunks[idx % ndims] / 2.0)
96+
chunks[idx % ndims] = math.ceil(chunks[idx % ndims] / 2.0)
9697
idx += 1
9798

9899
return tuple(int(x) for x in chunks)

0 commit comments

Comments
 (0)