Skip to content

Commit 6bfc6d6

Browse files
committed
ENH: added more information in "bad dtype" error message
1 parent e600402 commit 6bfc6d6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎larray/util/misc.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ def array_lookup2(array, sorted_keys, sorted_values):
325325
# prevent an array of booleans from matching a integer axis (sorted_keys)
326326
# XXX: we might want to allow signed and unsigned integers to match against each other
327327
if array.dtype.kind != sorted_keys.dtype.kind:
328-
raise KeyError('key has not the same dtype than axis')
328+
raise KeyError('key has not the same dtype than axis (key has '
329+
f'{array.dtype.kind!r} kind while axis has '
330+
f'{sorted_keys.dtype.kind!r} kind)\n'
331+
f'{array}\n{sorted_keys}\n')
329332
# TODO: it is very important to fail quickly, so guess_axis should try this in chunks
330333
# (first test first element of key, if several axes match, try [1:11] elements, [12:112], [113:1113], ...
331334
if not np.all(np.isin(array, sorted_keys)):

0 commit comments

Comments
 (0)