Repository navigation
Conversation
Enable the gunittest, pygrass raster and pygrass rpc doctest wrappers that were excluded in .gunittest.cfg. - RowIO: Build the Rowio_setup() callbacks from the type declared by the generated binding and accept the fourth (row length) argument. The three-argument callbacks were rejected by ctypes or crashed. - Buffer: Make __array_wrap__ work with NumPy 2, which passes a plain ndarray and an additional return_scalar argument. - Columns: Drop the database connection when pickling, so that the RPC data provider can send the columns to the client process. - GridModule: Look at the parameter typedesc instead of its Python type when adding the mapset to input maps, and handle multiple values and vector maps. Before, inputs never got a mapset and tiles failed. - get_raster_for_points: Do not depend on the NumPy scalar repr in the doctest. The changes were developed with the help of an AI assistant (Claude).
get_raster_for_points() opens the vector map if it is not open and does not close it. The doctest then opened the map again without closing it, so the first handle stayed open. Windows cannot delete files which are open, so the final remove() failed with "Unable to delete file" and the doctest wrapper failed on Windows. The change was developed with the help of an AI assistant (Claude).
| if inm.typedesc not in {"raster", "vector"} or not inm.value: | ||
| continue | ||
| find_mapset = ( | ||
| get_mapset_raster if inm.typedesc == "raster" else get_mapset_vector | ||
| ) | ||
| names = inm.value if isinstance(inm.value, list) else [inm.value] | ||
| qualified = [ | ||
| name if "@" in name else "%s@%s" % (name, find_mapset(name)) | ||
| for name in names | ||
| ] | ||
| inm.value = qualified if isinstance(inm.value, list) else qualified[0] |
There was a problem hiding this comment.
Agreed, the nested conditional expressions were hard to read. In 34034ec it is now a plain if/elif that picks the lookup function, and a small _with_mapset() helper qualifies one name. The list and single value cases are handled in one place.
Generated by Claude Code
|
|
||
| Add a new column and sample again | ||
|
|
||
| >>> vect.close() |
There was a problem hiding this comment.
Why is this not close to the same bloc of code that opens it?
There was a problem hiding this comment.
It should be. The call to get_raster_for_points() is what opens the map, so in 34034ec the vect.close() comes right after that call and its checks, with a short note, instead of at the start of the next block.
Generated by Claude Code
| # The callback type must be the one the generated binding declares for | ||
| # Rowio_setup(). It takes the row length as a fourth argument, and an equivalent | ||
| # type created with ctypes.CFUNCTYPE() is rejected by ctypes. | ||
| CMPFUNC = librowio.Rowio_setup.argtypes[4] |
There was a problem hiding this comment.
I don't understand correctly what's it's doing
There was a problem hiding this comment.
Rowio_setup() takes a callback that reads one row into a buffer, and the generated binding declares the exact ctypes type of that callback. CMPFUNC reuses that type to wrap the three Python row readers. A type made here with ctypes.CFUNCTYPE() is a different class, which ctypes rejects as an argument. I rewrote the comment in 34034ec to say this.
Generated by Claude Code
Split GridModule.define_mapset_inputs() into simpler steps with a helper that qualifies a map name, explain why the Rowio callback type comes from the binding, and close the vector right after the call that opened it in the get_raster_for_points() doctest.
Description
Re-enable the gunittest, pygrass raster and pygrass rpc doctest wrappers that were excluded in
.gunittest.cfg, by fixing what made them fail:RowIO: build theRowio_setup()callbacks from the type declared by the generated binding and accept the fourth (row length) argument. The 3-argument callbacks were rejected by ctypes or crashed.Buffer: make__array_wrap__work with NumPy 2, which passes a plain ndarray and an additionalreturn_scalarargument.Columns: drop the database connection when pickling, so the RPC data provider can send the columns to the client process.GridModule: use the parametertypedescinstead of its Python type when adding the mapset to input maps, and handle multiple values and vector maps. Inputs never got a mapset before, so tiles failed.get_raster_for_points: do not depend on the NumPy scalar repr in the doctest.Motivation and context
Doctests only run through gunittest wrappers. Several of them were excluded or silently broken, so regressions in the documented examples went unnoticed.
How has this been tested?
Ran
python3 -m grass.gunittest.main --location-type nc --config .gunittest.cfg(as intest_thorough.sh) with thenc_spm_full_v2beta1dataset onpython/grass/gunittest,python/grass/pygrass/rasterandpython/grass/pygrass/rpc: all files pass. All other pygrass doctest wrappers also pass. Existing pygrass raster, vector and table tests give the same results as before.Types of changes
functionality to not work as before)
Checklist
pre-defined prefixes
of this project.
The changes were developed with the help of an AI assistant (Claude).
Generated by Claude Code