Skip to content

pytest.approx raises TypeError for 0-d numpy array #3593

@floogit

Description

@floogit

This works:

>>> import pytest
>>> pytest.approx(5.)
5.0 ± 5.0e-06

This doesn't work:

>>> import pytest; import numpy as np
>>> pytest.approx(np.array(5.))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/_pytest/python_api.py", line 83, in __repr__
    self._approx_scalar(x) for x in np.asarray(self.expected)))
TypeError: iteration over a 0-d array

This looks like a bug to me.

pytest 3.6.0
numpy 1.14.3

Thanks, Florian

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions