Fixed Bug Regarding Attribute Error in pytest.approx For Types Implicitly Convertible to Numpy Arrays#12232
Conversation
…ed by reporter in issue pytest-dev#12114
…ed by reporter in issue pytest-dev#12114
RonnyPfannschmidt
left a comment
There was a problem hiding this comment.
thanks for getting this started
i suspect we need to setup a test env which includes numpy on github as the lack of coverage comes unexpected to me, i'll try to resolve that today
| ) | ||
|
|
||
| # convert other_side to numpy array to ensure shape attribute is available | ||
| other_side = _as_numpy_array(other_side) |
There was a problem hiding this comment.
i believe we need to expand the type annotation to include objects which may cast to a array + use a new variable name like other_side_as_array + assert its not none
There was a problem hiding this comment.
Alright, I added those changes in a push. Let me know if the typing for other_side looks alright, currently it is set to other_side: Union["ndarray", List[Any]].
…rray and renamed other_side to other_side_as_array and asserted that it is not none
|
I presume you would like a squash commit instead of a merge |
|
Yeah that sounds good to me! |
|
Hi Ronny, I just wanted to clarify if I have to do anything else for this pull request? |
|
No, next step is merge,I'm just preoccupied |
|
thanks again ! |
|
Of course! Thank you for your help and guidance :) |
Fixed the bug for _repr_compare in the ApproxNumpy class located in pytest.approx to ensure that other_side is a numpy array before comparing np_array_shape != other_side.shape. I have verified that the provided test cases, along with the test case provided in #12114, have all passed using pytest testing/python/approx.py.