Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.semantic.label: fix print raster map semantic label #3595

Merged
merged 2 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/r.semantic.label/r.semantic.label.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def print_map_semantic_label(name, label_reader):
with RasterRow(name) as rast:
semantic_label = rast.info.semantic_label
if semantic_label:
label_reader.print_info(semantic_label)
label_reader.print_info(semantic_label=semantic_label)
else:
gs.info(_("No semantic label assigned to <{}>").format(name))
except OpenError as e:
Expand Down
17 changes: 16 additions & 1 deletion scripts/r.semantic.label/testsuite/test_r_semantic_label.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from grass.gunittest.case import TestCase
from grass.gunittest.main import test
from grass.gunittest.gmodules import SimpleModule, call_module
from grass.gunittest.gmodules import SimpleModule

from grass.script.core import tempname
from grass.pygrass.gis import Mapset
Expand Down Expand Up @@ -46,6 +46,21 @@ def test_semantic_label_assign(self):
# check also using pygrass
self.assertEqual(self.read_semantic_label(), self.semantic_label)

def test_semantic_label_print(self):
semantic_label = "S2_1"
semantic_label_desc = "S2 Visible (Coastal/Aerosol)"
module = SimpleModule(
"r.semantic.label",
map=self.map,
semantic_label=semantic_label,
)
self.assertModule(module)

module = SimpleModule("r.semantic.label", map=self.map, operation="print")
self.assertModule(module)

self.assertEqual(module.outputs.stdout.strip(), semantic_label_desc)

def test_semantic_label_dissociate(self):
module = SimpleModule("r.semantic.label", operation="remove", map=self.map)
self.assertModule(module)
Expand Down
Loading