-
-
Notifications
You must be signed in to change notification settings - Fork 426
[Bug] Python doctests must be updated for numpy 2+ or some later versions of numpy 1 #4100
Description
Describe the bug
Doctest running with the gunittest test suite fail with numpy 2.0.1, as the datatype (like int32) doesn't appear when representing the shape of the array.
I don't know how to support both older numpy and numpy 2.0.1+ on the same doctest, as they don't have the same string representation, but it doesn't really bother, as it was aliases to the python types for a long while.
I observed these bugs last week on some Windows CI runs, as the package managers have recent versions quite fast, but didn't catch on that it was numpy.
To reproduce
- Install numpy 2 through pip
- Run gunittest for
File "etc/python/grass/pygrass/utils.py", line 278, in grass.pygrass.utils.get_raster_for_points, or on Windows for:File "etc\python\grass\pygrass\raster\__init__.py", line 412, in grass.pygrass.raster.RasterSegment.put_row - See error in output
Expected behavior
Screenshots
Windows:
https://github.com/echoix/grass/actions/runs/10085495709/job/27886383708?pr=168#step:11:1767 (one of my runs)

https://github.com/OSGeo/grass/actions/runs/10075548005/job/27854053510#step:11:1603 (the last commit on main)

Ubuntu:
https://github.com/echoix/grass/actions/runs/10085634573/job/27886769880?pr=174#step:19:88 (my branch, with Python 3.12 and numpy 2.0.1 running gunittest+code coverage, but the exact commit might change as I'm rebasing my work for a PR).

System description
- Operating System: Windows (Windows Server 2019 on GitHub Actions CI) or Linux (Ubuntu 22.04, on GitHub Actions CI)
- GRASS GIS version: main at commit 0306f93, but in reality anything since numpy 2 could be installed by pip.
- Ubuntu 22.04 on Github Actions gives numpy 1.21.5-1 with apt, from python3-numpy
Get:155 http://azure.archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3-numpy amd64 1:1.21.5-1ubuntu22.04.1 [3467 kB]- So the change is after numpy 1.21.5
Additional context
I did a small simulation in a branch based on one of my pending work, using Python 3.12 for Ubuntu gunittest, and requires installing dependencies through pip rather than using the system's package manager.