Apply suggestions from code review

This commit is contained in:
Bruno Oliveira 2024-04-25 07:58:05 -03:00 committed by GitHub
parent 3d5bebfd47
commit dfa90bba2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 3 deletions

View File

@ -1 +1 @@
Fixed attribute error in pytest.approx for types implicitly convertible to numpy arrays by converting other_side to a numpy array so that np_array_shape != other_side.shape can be properly checked.
Fixed error in :func:`pytest.approx` when used with `numpy` arrays and comparing with other types.

View File

@ -163,7 +163,7 @@ class ApproxNumpy(ApproxBase):
self._approx_scalar, self.expected.tolist()
)
# convert other_side to numpy array to ensure shape attribute is available
# Convert other_side to numpy array to ensure shape attribute is available.
other_side_as_array = _as_numpy_array(other_side)
assert other_side_as_array is not None

View File

@ -763,7 +763,8 @@ class TestApprox:
assert a12 != approx(a21)
assert a21 != approx(a12)
def test_numpy_array_implicit_conversion(self):
def test_numpy_array_implicit_conversion(self) -> None:
"""#12114."""
np = pytest.importorskip("numpy")
class ImplicitArray: