Skip to content

Commit 1615a0f

Browse files
authored
Merge pull request #1157 from SixtyCapital/perf-pindex
PERF: Use len rather than size
2 parents 2c7730d + 39b3ea9 commit 1615a0f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

xarray/core/alignment.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def reindex_variables(variables, indexes, indexers, method=None,
164164
get_indexer_kwargs['tolerance'] = tolerance
165165

166166
for name, index in iteritems(indexes):
167-
to_shape[name] = index.size
167+
to_shape[name] = len(index)
168168
if name in indexers:
169169
target = utils.safe_cast_to_index(indexers[name])
170170
if not index.is_unique:
@@ -186,7 +186,7 @@ def reindex_variables(variables, indexes, indexers, method=None,
186186
to_indexers[name] = slice(None)
187187

188188
from_indexers[name] = indexer[to_indexers[name]]
189-
if np.array_equal(from_indexers[name], np.arange(index.size)):
189+
if np.array_equal(from_indexers[name], np.arange(len(index))):
190190
# If the indexer is equal to the original index, use a full
191191
# slice object to speed up selection and so we can avoid
192192
# unnecessary copies

0 commit comments

Comments
 (0)