Fix : Jedi do not complete numpy arrays in dictionary

Fix ipython/ipython#10468
This commit is contained in:
Matthias Bussonnier
2017-04-20 11:53:19 -07:00
committed by Dave Halter
parent fbde21166b
commit b0f10081d4
2 changed files with 31 additions and 1 deletions

View File

@@ -41,6 +41,36 @@ def test_builtin_details():
assert m.type == 'module'
def test_numpy_like_non_zero():
"""
Numpy-like array can't be caster to bool and need to be compacre with
`is`/`is not` and not `==`/`!=`
"""
class NumpyNonZero:
def __zero__(self):
raise ValueError('Numpy arrays would raise and tell you to use .any() or all()')
def __bool__(self):
raise ValueError('Numpy arrays would raise and tell you to use .any() or all()')
class NumpyLike:
def __eq__(self, other):
return NumpyNonZero()
def something(self):
pass
x = NumpyLike()
d = {'a': x}
# just assert these do not raise. They (strangely) trigger different
# codepath
get_completion('d["a"].some', {'d':d})
get_completion('x.some', {'x':x})
def test_nested_resolve():
class XX():
def x():