forked from pytest-dev/pytest
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python_api: handle array-like args in approx()
This treats objects that expose an ndarray via the __array__ interface the same as direct subclasses of ndarray. Fixes pytest-dev#8132.
- Loading branch information
1 parent
7e2e663
commit fd7f260
Showing
3 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Fixed regression in ``approx``: in 6.2.0 ``approx`` no longer raises | ||
``TypeError`` when dealing with non-numeric types, falling back to normal comparison. | ||
Before 6.2.0, array types like tf.DeviceArray fell through to the scalar case, | ||
and happened to compare correctly to a scalar if they had only one element. | ||
After 6.2.0, these types began failing, because they inherited neither from | ||
standard Python number hierarchy nor from ``numpy.ndarray``. | ||
|
||
``approx`` now converts arguments to ``numpy.ndarray`` if they expose the array | ||
protocol and are not scalars. This treats array-like objects like numpy arrays, | ||
regardless of size. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters