Closed weiji14 closed 4 months ago
It's caused by upstream changes in NumPy 2.0.
References:
Nice job tracking this down! What do you think we should do here? Seems like this only affects the repr
, and the other tests work fine. Don't think we can xfail a doctest though, and we need to keep compatibility with NumPy 1.22-1.26 (whose beta just came out https://github.com/numpy/numpy/releases/tag/v1.26.0b1) still.
Since dataarray_to_matrix
is somewhat internal, we could maybe just use print([float(r) for r in region])
? Or see what pytest-doctestplus is doing at https://github.com/scientific-python/pytest-doctestplus/issues/210
Or see what pytest-doctestplus is doing at scientific-python/pytest-doctestplus#210
Let's wait for more days or weeks.
Honestly, I'm not sure when we have a proper way to handle this in doctestplus. In the meantime, you can do the workaround in your conftest:
https://github.com/astropy/astroquery/blob/main/astroquery/conftest.py#L17
Currently, the returned region
is a list of np.float64
object. I think it makes more sense to return a list of float
values. Then, we no longer have to worry about the changes in the numpy scalar representation. See https://github.com/GenericMappingTools/pygmt/pull/3226 for the fix.
We still have the issue in the doctests workflow (see https://github.com/GenericMappingTools/pygmt/actions/runs/9629554292/job/26559112184):
_____________________ [doctest] pygmt.src.grdclip.grdclip ______________________
101 Example
102 -------
103 >>> import pygmt
104 >>> # Load a grid of @earth_relief_30m data, with a longitude range of
105 >>> # 10° E to 30° E, and a latitude range of 15° N to 25° N
106 >>> grid = pygmt.datasets.load_earth_relief(
107 ... resolution="30m", region=[10, 30, 15, 25]
108 ... )
109 >>> # Report the minimum and maximum data values
110 >>> [grid.data.min(), grid.data.max()]
Expected:
[183.5, 1807.0]
Got:
[np.float64(183.5), np.float64(1807.0)]
Description of the problem
The following doctest started failing on the GMT Dev Tests on 28 Jul 2023, previously passing on 26 Jul 2023. See https://github.com/GenericMappingTools/pygmt/actions/runs/5686923585/job/15414542417#step:16:723.
Doesn't seem to be an issue with upstream GMT, at least I don't see anything obvious in these 7 commits https://github.com/GenericMappingTools/gmt/compare/f4977110c4cddd657a34e35f6108e1dea12a1655...c94da14cee4af27d60a01f47532e649b52d923b8.
The
region
variable is created here - https://github.com/GenericMappingTools/pygmt/blob/855f6fa1b533c106d1e0fe5b68a92e1e7ef5df27/pygmt/clib/conversion.py#L88-L117 Might be related to changes in the dev version of numpy/pandas/xarray?Minimal Complete Verifiable Example
Full error message
System information
Failing on:
Passing version:
Diff