Skip to content

r.colors.stddev: add tests - #7487

Merged
echoix merged 3 commits into
OSGeo:mainfrom
Valyrian-Code:r.colors.stddev-tests
Jun 5, 2026
Merged

echoix merged 3 commits into
OSGeo:mainfrom
Valyrian-Code:r.colors.stddev-tests

Conversation

@Valyrian-Code

Copy link
Copy Markdown
Contributor

Description

r.colors.stddev had no test coverage. This adds a pytest module that builds a
raster with a known mean and standard deviation (values 1..9) and checks the
resulting color table:

  • Default mode: white is placed at the mean, blue at mean - 2*stddev, and red
    at mean + 2*stddev.
  • Banded mode (-b): the central green band spans mean - stddev to
    mean + stddev.

The expected mean and (population) standard deviation are computed in the test
with the standard library, so the assertions are self-contained.

Motivation and context

scripts/r.colors.stddev is a small, deterministic script with no tests.
Adding coverage fits the ongoing effort to write pytest tests for GRASS tools.

How has this been tested?

pytest scripts/r.colors.stddev/tests/r_colors_stddev_test.py — 2 tests pass.
ruff format and ruff check are clean.

Types of changes

  • Tests

r.colors.stddev had no test coverage. Add a pytest module that builds a raster with a known mean and standard deviation and checks the resulting color table: default mode places white at the mean and blue/red at mean -/+ two standard deviations, and banded mode (-b) centers the green band on mean -/+ one standard deviation.
Copilot AI review requested due to automatic review settings June 3, 2026 06:14
@github-actions github-actions Bot added raster Related to raster data processing Python Related code is in Python module tests Related to Test Suite labels Jun 3, 2026

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 automated tests for r.colors.stddev to validate that generated color rules align with expected mean/stddev breakpoints for both default and banded modes.

Changes:

  • Introduces a new pytest module covering default and -b (banded) behavior.
  • Creates a small deterministic raster (values 1..9) to assert expected rule breakpoints via r.colors.out JSON.

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

@echoix
echoix enabled auto-merge (squash) June 4, 2026 21:15
@echoix
echoix merged commit ce20541 into OSGeo:main Jun 5, 2026
26 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Jun 5, 2026
@Valyrian-Code
Valyrian-Code deleted the r.colors.stddev-tests branch June 5, 2026 13:55
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Jul 7, 2026
r.colors.stddev had no test coverage. Add a pytest module that builds a raster with a known mean and standard deviation and checks the resulting color table: default mode places white at the mean and blue/red at mean -/+ two standard deviations, and banded mode (-b) centers the green band on mean -/+ one standard deviation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants