-
-
Notifications
You must be signed in to change notification settings - Fork 361
i.cca: use 0 based array indexing #3239
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
Draft
marisn
wants to merge
8
commits into
OSGeo:main
Choose a base branch
from
marisn:i_cca_fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f698757
i.cca: use 0 based array indexing
marisn 27074be
i.cca: add a test for i.cca output correctness
marisn b71d67e
Merge branch 'main' into i_cca_fix
marisn 19f8bcd
i.cca use all signature var values (thanks @metzm for spotting the bug)
marisn 982a052
Merge branch 'main' into i_cca_fix
echoix fdf74ae
black
neteler 5968b5b
fix landsat map names for CI
neteler 571c8e6
Merge branch 'main' into i_cca_fix
echoix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
""" | ||
Name: i.cca tests | ||
Purpose: Test correctness of generated outputs | ||
|
||
Author: Maris Nartiss | ||
Copyright: (C) 2023 by Maris Nartiss and the GRASS Development Team | ||
Licence: This program is free software under the GNU General Public | ||
License (>=v2). Read the file COPYING that comes with GRASS | ||
for details. | ||
""" | ||
|
||
from grass.script.core import tempname | ||
|
||
from grass.gunittest.case import TestCase | ||
from grass.gunittest.main import test | ||
|
||
|
||
class OutputMatchTest(TestCase): | ||
""" | ||
Compare values to output generated by pre-7.0 version of the module. | ||
Comparison values were obtained with pre-ccmath rewrite version | ||
664305e4b8de924c8dfb5385e8bf6c18fbf649be | ||
""" | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
"""Ensures expected computational region and generated data""" | ||
cls.use_temp_region() | ||
cls.runModule("g.region", raster="lsat7_2002_20") | ||
cls.group_name = tempname(10) | ||
cls.subgroup_name = "vis" | ||
cls.runModule( | ||
"i.group", | ||
group=cls.group_name, | ||
subgroup=cls.subgroup_name, | ||
input="lsat7_2002_20,lsat7_2002_30,lsat7_2002_40", | ||
) | ||
cls.rasters = [] | ||
cls.signatures = [] | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
"""Remove the temporary region and generated data""" | ||
cls.del_temp_region() | ||
cls.runModule( | ||
"g.remove", flags="f", type="group", name=cls.group_name, quiet=True | ||
) | ||
for r in cls.rasters: | ||
cls.runModule("g.remove", flags="f", type="raster", name=r, quiet=True) | ||
for s in cls.signatures: | ||
cls.runModule("i.signatures", type="sig", remove=s, quiet=True) | ||
|
||
def test_output_values(self): | ||
"""Test correctness of i.cca output""" | ||
sig_name = tempname(10) | ||
self.assertModule( | ||
"i.cluster", | ||
classes=4, | ||
group=self.group_name, | ||
subgroup=self.subgroup_name, | ||
signaturefile=sig_name, | ||
quiet=True, | ||
) | ||
self.signatures.append(sig_name) | ||
out_prefix = tempname(10) | ||
self.assertModule( | ||
"i.cca", | ||
group=self.group_name, | ||
subgroup=self.subgroup_name, | ||
signature=sig_name, | ||
output=out_prefix, | ||
quiet=True, | ||
) | ||
self.assertRasterExists(f"{out_prefix}.1") | ||
self.rasters.append(f"{out_prefix}.1") | ||
self.assertRasterExists(f"{out_prefix}.2") | ||
self.rasters.append(f"{out_prefix}.2") | ||
self.assertRasterExists(f"{out_prefix}.3") | ||
self.rasters.append(f"{out_prefix}.3") | ||
self.assertRasterMinMax( | ||
map=f"{out_prefix}.1", refmin=-10, refmax=9, msg="Wrong calculated value" | ||
) | ||
self.assertRasterMinMax( | ||
map=f"{out_prefix}.2", refmin=-34, refmax=-3, msg="Wrong calculated value" | ||
) | ||
self.assertRasterMinMax( | ||
map=f"{out_prefix}.3", refmin=-24, refmax=5, msg="Wrong calculated value" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
test() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.