Skip to content

Commit 17cb751

Browse files
committed
use numbers.Integral
1 parent 1405d5a commit 17cb751

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

zarr/compat.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,17 @@
44
import sys
55

66

7-
import numpy as np
8-
9-
107
PY2 = sys.version_info[0] == 2
118

129

13-
numpy_integer_types = np.int8, np.int16, np.int32, np.int64, np.uint8, np.uint16, np.uint32, \
14-
np.uint64
15-
16-
1710
if PY2: # pragma: no cover
1811

1912
text_type = unicode
2013
binary_type = str
21-
integer_types = (int, long) + numpy_integer_types
2214
reduce = reduce
2315

2416
else:
2517

2618
text_type = str
2719
binary_type = bytes
28-
integer_types = (int,) + numpy_integer_types
2920
from functools import reduce

zarr/util.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
from __future__ import absolute_import, print_function, division
33
import operator
44
from textwrap import TextWrapper
5+
import numbers
56

67

78
import numpy as np
89

910

10-
from zarr.compat import integer_types, PY2, reduce
11+
from zarr.compat import PY2, reduce
1112

1213

1314
def normalize_shape(shape):
@@ -17,7 +18,7 @@ def normalize_shape(shape):
1718
raise TypeError('shape is None')
1819

1920
# handle 1D convenience form
20-
if isinstance(shape, integer_types):
21+
if isinstance(shape, numbers.Integral):
2122
shape = (int(shape),)
2223

2324
# normalize
@@ -89,7 +90,7 @@ def normalize_chunks(chunks, shape, typesize):
8990
return guess_chunks(shape, typesize)
9091

9192
# handle 1D convenience form
92-
if isinstance(chunks, integer_types):
93+
if isinstance(chunks, numbers.Integral):
9394
chunks = (int(chunks),)
9495

9596
# handle bad dimensionality
@@ -137,7 +138,8 @@ def normalize_axis_selection(item, length):
137138
"""Convenience function to normalize a selection within a single axis
138139
of size `l`."""
139140

140-
if isinstance(item, int):
141+
if isinstance(item, numbers.Integral):
142+
item = int(item)
141143

142144
# handle wraparound
143145
if item < 0:
@@ -191,7 +193,7 @@ def normalize_array_selection(item, shape):
191193
the given `shape`."""
192194

193195
# normalize item
194-
if isinstance(item, integer_types):
196+
if isinstance(item, numbers.Integral):
195197
item = (int(item),)
196198
elif isinstance(item, slice):
197199
item = (item,)

0 commit comments

Comments
 (0)