Show More
@@ -863,7 +863,8 b' class IPCompleter(Completer):' | |||||
863 | return list(obj.keys()) |
|
863 | return list(obj.keys()) | |
864 | except Exception: |
|
864 | except Exception: | |
865 | return [] |
|
865 | return [] | |
866 |
elif _safe_isinstance(obj, 'numpy', 'ndarray') |
|
866 | elif _safe_isinstance(obj, 'numpy', 'ndarray') or\ | |
|
867 | _safe_isinstance(obj, 'numpy', 'void'): | |||
867 | return obj.dtype.names or [] |
|
868 | return obj.dtype.names or [] | |
868 | return [] |
|
869 | return [] | |
869 |
|
870 |
@@ -668,6 +668,20 b' def test_struct_array_key_completion():' | |||||
668 | _, matches = complete(line_buffer="d['") |
|
668 | _, matches = complete(line_buffer="d['") | |
669 | nt.assert_in("hello", matches) |
|
669 | nt.assert_in("hello", matches) | |
670 | nt.assert_in("world", matches) |
|
670 | nt.assert_in("world", matches) | |
|
671 | # complete on the numpy struct itself | |||
|
672 | dt = numpy.dtype([('my_head', [('my_dt', '>u4'), ('my_df', '>u4')]), | |||
|
673 | ('my_data', '>f4', 5)]) | |||
|
674 | x = numpy.zeros(2, dtype=dt) | |||
|
675 | ip.user_ns['d'] = x[1] | |||
|
676 | _, matches = complete(line_buffer="d['") | |||
|
677 | nt.assert_in("my_head", matches) | |||
|
678 | nt.assert_in("my_data", matches) | |||
|
679 | # complete on a nested level | |||
|
680 | with greedy_completion(): | |||
|
681 | ip.user_ns['d'] = numpy.zeros(2, dtype=dt) | |||
|
682 | _, matches = complete(line_buffer="d[1]['my_head']['") | |||
|
683 | nt.assert_true(any(["my_dt" in m for m in matches])) | |||
|
684 | nt.assert_true(any(["my_df" in m for m in matches])) | |||
671 |
|
685 | |||
672 |
|
686 | |||
673 | @dec.skip_without('pandas') |
|
687 | @dec.skip_without('pandas') |
General Comments 0
You need to be logged in to leave comments.
Login now