-
-
Notifications
You must be signed in to change notification settings - Fork 323
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
i.pca: added tests for the module #3550
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! In general, this looks very good, and I know it is more than skill-tests for GSoC in other projects.
Nevertheless, I made some suggestions for changes, Please have a look at them.
Most importantly, please re-format the added Pyhton file using black. See: /~https://github.com/OSGeo/grass/actions/runs/8512975348/job/23315779012#step:8:257 for how it is used in CI. If the file does not comply to black
formating standards for Python, CI will fail and the PR cannot be merged,
You can install black with: pip install black==23.1.0
7e78d16
to
d2503b5
Compare
@ninsbl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me...
I just tried it locally, runs ok but yields a
|
I didn't get it with python 3.11
|
This is likely a Python 3.12 issue. Markus, please test with adding an r before triple quote (file test_pca.py:39): lsat7_2002_pca_info_out = r"""north=228513 |
Yes, python 3.12 here:
The warning then disappears but it then fails:
|
It is probably because of the quotations inside the string... Can you try to change the variable "lsat7_2002_pca_info_out" to:
|
diff --git a/imagery/i.pca/testsuite/test_pca.py b/imagery/i.pca/testsuite/test_pca.py
index 9da7991f87..7999feba8e 100644
--- a/imagery/i.pca/testsuite/test_pca.py
+++ b/imagery/i.pca/testsuite/test_pca.py
@@ -36,7 +36,7 @@ class TestReport(TestCase):
output="lsat7_2002_pca",
)
- lsat7_2002_pca_info_out = """north=228513
+ lsat7_2002_pca_info_out = r"""north=228513
south=214975.5
east=645012
west=629992.5
@@ -47,7 +47,7 @@ class TestReport(TestCase):
cells=250325
datatype=CELL
ncats=0
- comments=\"Eigen values, (vectors), and [percent importance]:PC1 4334.35 ( 0.2824, 0.3342, 0.5092,-0.0087, 0.5264, 0.5217) [83.04%]PC2 588.31 ( 0.2541, 0.1885, 0.2923,-0.7428,-0.5110,-0.0403) [11.27%]PC3 239.22 ( 0.3801, 0.3819, 0.2681, 0.6238,-0.4000,-0.2980) [ 4.58%]PC4 32.85 ( 0.1752,-0.0191,-0.4053, 0.1593,-0.4435, 0.7632) [ 0.63%]PC5 20.73 (-0.6170,-0.2514, 0.6059, 0.1734,-0.3235, 0.2330) [ 0.40%]PC6 4.08 (-0.5475, 0.8021,-0.2282,-0.0607,-0.0208, 0.0252) [ 0.08%]i.pca input=\"lsat7_2002_10,lsat7_2002_20,lsat7_2002_30,lsat7_2002_40\,lsat7_2002_50,lsat7_2002_70\" output=\"lsat7_2002_pca\" rescale=0,255 \percent=99" """
+ comments="Eigen values, (vectors), and [percent importance]:PC1 4334.35 ( 0.2824, 0.3342, 0.5092,-0.0087, 0.5264, 0.5217) [83.04%]PC2 588.31 ( 0.2541, 0.1885, 0.2923,-0.7428,-0.5110,-0.0403) [11.27%]PC3 239.22 ( 0.3801, 0.3819, 0.2681, 0.6238,-0.4000,-0.2980) [ 4.58%]PC4 32.85 ( 0.1752,-0.0191,-0.4053, 0.1593,-0.4435, 0.7632) [ 0.63%]PC5 20.73 (-0.6170,-0.2514, 0.6059, 0.1734,-0.3235, 0.2330) [ 0.40%]PC6 4.08 (-0.5475, 0.8021,-0.2282,-0.0607,-0.0208, 0.0252) [ 0.08%]i.pca input="lsat7_2002_10,lsat7_2002_20,lsat7_2002_30,lsat7_2002_40\,lsat7_2002_50,lsat7_2002_70" output="lsat7_2002_pca" rescale=0,255 \percent=99" """
lsat7_2002_pca_univar_out = [
"""n=250325 works for both 3.12 and 3.11. |
This PR adds a test suite using gunittest for the i.pca module.
i.pca is tested against the sample data used in CI.
The expected results (from r.info and r.univar) are saved in the data directory, and are used to validate the correctness of the module.