2
2
from __future__ import absolute_import , print_function , division
3
3
import operator
4
4
from textwrap import TextWrapper
5
+ import numbers
5
6
6
7
7
8
import numpy as np
8
9
9
10
10
- from zarr .compat import integer_types , PY2 , reduce
11
+ from zarr .compat import PY2 , reduce
11
12
12
13
13
14
def normalize_shape (shape ):
@@ -17,7 +18,7 @@ def normalize_shape(shape):
17
18
raise TypeError ('shape is None' )
18
19
19
20
# handle 1D convenience form
20
- if isinstance (shape , integer_types ):
21
+ if isinstance (shape , numbers . Integral ):
21
22
shape = (int (shape ),)
22
23
23
24
# normalize
@@ -89,7 +90,7 @@ def normalize_chunks(chunks, shape, typesize):
89
90
return guess_chunks (shape , typesize )
90
91
91
92
# handle 1D convenience form
92
- if isinstance (chunks , integer_types ):
93
+ if isinstance (chunks , numbers . Integral ):
93
94
chunks = (int (chunks ),)
94
95
95
96
# handle bad dimensionality
@@ -137,7 +138,8 @@ def normalize_axis_selection(item, length):
137
138
"""Convenience function to normalize a selection within a single axis
138
139
of size `l`."""
139
140
140
- if isinstance (item , int ):
141
+ if isinstance (item , numbers .Integral ):
142
+ item = int (item )
141
143
142
144
# handle wraparound
143
145
if item < 0 :
@@ -191,7 +193,7 @@ def normalize_array_selection(item, shape):
191
193
the given `shape`."""
192
194
193
195
# normalize item
194
- if isinstance (item , integer_types ):
196
+ if isinstance (item , numbers . Integral ):
195
197
item = (int (item ),)
196
198
elif isinstance (item , slice ):
197
199
item = (item ,)
0 commit comments