Skip to content

[Bug] Python doctests must be updated for numpy 2+ or some later versions of numpy 1 #4100

@echoix

Description

@echoix

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

  1. Install numpy 2 through pip
  2. 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
  3. 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)
image
https://github.com/OSGeo/grass/actions/runs/10075548005/job/27854053510#step:11:1603 (the last commit on main)
image

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).
image

System description

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.

Metadata

Metadata

Assignees

Labels

PythonRelated code is in PythonbugSomething isn't workingtestsRelated to Test Suite

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions