Skip to content

grass.jupyter: add tests for utils helpers - #7486

Merged
cwhite911 merged 5 commits into
OSGeo:mainfrom
Valyrian-Code:grass.jupyter-utils-tests
Jun 6, 2026
Merged

cwhite911 merged 5 commits into
OSGeo:mainfrom
Valyrian-Code:grass.jupyter-utils-tests

Conversation

@Valyrian-Code

Copy link
Copy Markdown
Contributor

Description

Add unit tests for two pure helper functions in grass.jupyter.utils that
were previously untested:

  • get_rendering_size — covers all aspect-ratio branches (both dimensions
    given, only width, only height, taller-than-wide, wider-than-tall) plus a
    custom-defaults case.
  • get_map_name_from_d_command — covers the default map parameter, the
    per-command special cases (d.his, d.legend, d.rgb, d.shade), a
    missing parameter, and a non-string value.

Motivation and context

grass.jupyter.utils has several pure helpers with no direct test coverage.
These two are deterministic and dependency-free (no rendering or optional
mapping libraries), so they are a good, low-risk place to start adding
coverage.

How has this been tested?

pytest python/grass/jupyter/tests/grass_jupyter_utils_test.py — 14 tests
pass. ruff format and ruff check are clean.

Types of changes

  • Tests

Copilot AI review requested due to automatic review settings June 3, 2026 06:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds unit tests for pure helper functions in grass.jupyter.utils to validate rendering size calculation and map-name extraction from display commands.

Changes:

  • Introduces parametrized tests for get_rendering_size() covering explicit dimensions, aspect-ratio-derived dimensions, and default sizing behavior.
  • Adds tests for get_map_name_from_d_command() across common display modules and edge cases (missing parameter, non-string values).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

get_rendering_size and get_map_name_from_d_command in grass.jupyter.utils had no direct test coverage. Both are pure, deterministic, and free of rendering or optional mapping dependencies. Add a pytest module covering get_rendering_size across all aspect-ratio branches and get_map_name_from_d_command across its default, per-command special-case, missing, and non-string inputs.
@Valyrian-Code
Valyrian-Code force-pushed the grass.jupyter-utils-tests branch from 2e9a541 to c712d31 Compare June 3, 2026 06:06
@github-actions github-actions Bot added Python Related code is in Python libraries tests Related to Test Suite notebook labels Jun 3, 2026

@cwhite911 cwhite911 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Valyrian-Code this looks good. I just have a few additional edge cases you could add.

Following review: add get_map_name_from_d_command cases for map=None and for multiple maps passed to d.rgb (only the primary red map is returned), and get_rendering_size cases documenting round()'s half-to-even behavior (2.5 -> 2, 3.5 -> 4).
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Thanks for the review @cwhite911 - added all three edge cases in b2d28fc (map=None, the d.rgb multi-map case returning only red_map, and the two round() half-to-even cases). Ready for another look.

@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Thanks again @cwhite911, this was a really helpful review. I enjoyed working in grass.jupyter and I'd be glad to keep helping here.

If there are other grass.jupyter issues or small things you'd like a hand with, I'm happy to pick them up. I'm also looking into the vector styling and legend ideas that came up on Discourse, and I'd love to contribute more in this area over the coming weeks.

Just point me at whatever would be most useful, and thanks for the warm welcome to the project.

@cwhite911 cwhite911 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Valyrian-Code. Looks good!

@cwhite911
cwhite911 enabled auto-merge (squash) June 5, 2026 17:09
@echoix

echoix commented Jun 5, 2026

Copy link
Copy Markdown
Member

There was a hang in a t.list on macOS, killed after 5 minutes (expecting at most seconds), 296.33s call temporal/t.list/tests/test_t_list.py::test_t_list_csv[,]. What I find interesting is a warning related to an unclosed TextIOWriter https://github.com/OSGeo/grass/actions/runs/27020186894/job/79745720633?pr=7486#step:14:1749. I wouldn’t investigate the process still running before making sure it is not only code coverage that hasn’t still finished saving the data file.

@echoix

echoix commented Jun 5, 2026

Copy link
Copy Markdown
Member

For the windows failure, it seems Cairo was changed in osgeo4w yesterday, in the following commit, and some patch mentioning the header file changed. jef-n/OSGeo4W@c3b8830

I didn’t have time to finish looking and understanding

@cwhite911

cwhite911 commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

For the windows failure, it seems Cairo was changed in osgeo4w yesterday, in the following commit, and some patch mentioning the header file changed. jef-n/OSGeo4W@c3b8830

I didn’t have time to finish looking and understanding

Looks like the cairo header was moved from …/include/cairo.h to …/include/cairo/cairo.h

I'll open a PR #7507.

@cwhite911
cwhite911 merged commit 43c934e into OSGeo:main Jun 6, 2026
29 of 51 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Jun 6, 2026
@Valyrian-Code
Valyrian-Code deleted the grass.jupyter-utils-tests branch June 7, 2026 17:05
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Jul 7, 2026
* grass.jupyter: add tests for utils helpers

get_rendering_size and get_map_name_from_d_command in grass.jupyter.utils had no direct test coverage. Both are pure, deterministic, and free of rendering or optional mapping dependencies. Add a pytest module covering get_rendering_size across all aspect-ratio branches and get_map_name_from_d_command across its default, per-command special-case, missing, and non-string inputs.

* grass.jupyter: add edge-case tests for utils helpers

Following review: add get_map_name_from_d_command cases for map=None and for multiple maps passed to d.rgb (only the primary red map is returned), and get_rendering_size cases documenting round()'s half-to-even behavior (2.5 -> 2, 3.5 -> 4).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libraries notebook Python Related code is in Python tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants