Came across this while poking around the approx code:
|
elif hasattr(obj, "__array__") or hasattr("obj", "__array_interface__"): |
elif hasattr(obj, "__array__") or hasattr("obj", "__array_interface__"):
Second hasattr uses the string "obj" instead of the variable obj. Means any object that implements __array_interface__ without __array__ won't be recognized as a numpy-like array by _as_numpy_array. So they fall through to ApproxSequenceLike instead of ApproxNumpy.
Not a huge impact day-to-day since most numpy users work with actual ndarray, but could affect users with custom array types or libraries that only implement __array_interface__. The fix is just removing the quotes.
Came across this while poking around the approx code:
pytest/src/_pytest/python_api.py
Line 909 in 8344ded
Second hasattr uses the string
"obj"instead of the variableobj. Means any object that implements__array_interface__without__array__won't be recognized as a numpy-like array by_as_numpy_array. So they fall through toApproxSequenceLikeinstead ofApproxNumpy.Not a huge impact day-to-day since most numpy users work with actual ndarray, but could affect users with custom array types or libraries that only implement
__array_interface__. The fix is just removing the quotes.