[GRASS-SVN] r72717 - in grass/branches/releasebranch_7_4/temporal/t.rast.what: . testsuite

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 16 14:29:34 PDT 2018


Author: sbl
Date: 2018-05-16 14:29:33 -0700 (Wed, 16 May 2018)
New Revision: 72717

Modified:
   grass/branches/releasebranch_7_4/temporal/t.rast.what/t.rast.what.py
   grass/branches/releasebranch_7_4/temporal/t.rast.what/testsuite/test_what.py
Log:
Correct output format (trunk, r72635, r72636, r72713, r72716); fix #3546

Modified: grass/branches/releasebranch_7_4/temporal/t.rast.what/t.rast.what.py
===================================================================
--- grass/branches/releasebranch_7_4/temporal/t.rast.what/t.rast.what.py	2018-05-16 21:24:16 UTC (rev 72716)
+++ grass/branches/releasebranch_7_4/temporal/t.rast.what/t.rast.what.py	2018-05-16 21:29:33 UTC (rev 72717)
@@ -397,31 +397,40 @@
         if first is True:
             if write_header is True:
                 out_str = "start%(sep)send"%({"sep":separator})
+
+                # Define different separator for coordinates and sites
+                if separator == ',':
+                    coor_sep = ';'
+                else:
+                    coor_sep = ','
+
                 for row in matrix:
                     if vcat:
                         cat = row[0]
                         x = row[1]
                         y = row[2]
-                        out_str += "{sep}{cat}{sep}{x:10.10f};" \
+                        out_str += "{sep}{cat}{csep}{x:10.10f}{csep}" \
                                   "{y:10.10f}".format(cat=cat, x=float(x),
                                                            y=float(y),
-                                                           sep=separator)
+                                                           sep=separator,
+                                                           csep=coor_sep)
                         if site_input:
                             site = row[3]
-                            out_str += "{sep}{site}".format(sep=separator,
+                            out_str += "{sep}{site}".format(sep=coor_sep,
                                                             site=site)
                     else:
                         x = row[0]
                         y = row[1]
-                        out_str += "{sep}{x:10.10f};" \
+                        out_str += "{sep}{x:10.10f}{csep}" \
                                    "{y:10.10f}".format(x=float(x), y=float(y),
-                                                       sep=separator)
+                                                       sep=separator,
+                                                       csep=coor_sep)
                         if site_input:
                             site = row[2]
-                            out_str += "{sep}{site}".format(sep=separator,
+                            out_str += "{sep}{site}".format(sep=coor_sep,
                                                             site=site)
 
-            out_file.write(out_str + "\n")
+                out_file.write(out_str + "\n")
 
         first = False
 
@@ -500,13 +509,17 @@
                 else:
                     matrix.append(cols[:2])
 
-            matrix[i] = matrix[i] + cols[3:]
+            if vcat:
+                matrix[i] = matrix[i] + cols[4:]
+            else:
+                matrix[i] = matrix[i] + cols[3:]
 
         first = False
 
         in_file.close()
 
-    out_file.write(header + "\n")
+    if write_header:
+        out_file.write(header + "\n")
 
     gscript.verbose(_("Writing the output file <%s>"%(output)))
     for row in matrix:

Modified: grass/branches/releasebranch_7_4/temporal/t.rast.what/testsuite/test_what.py
===================================================================
--- grass/branches/releasebranch_7_4/temporal/t.rast.what/testsuite/test_what.py	2018-05-16 21:24:16 UTC (rev 72716)
+++ grass/branches/releasebranch_7_4/temporal/t.rast.what/testsuite/test_what.py	2018-05-16 21:29:33 UTC (rev 72717)
@@ -83,7 +83,7 @@
                           nprocs=1, overwrite=True, verbose=True)
 
         self.assertFileMd5("out_col.txt",
-                           "8720cc237b46ddb18f11440469d0e13f", text=True)
+                           "885b6f50405b08fa9fe9ae33ed50e29b", text=True)
 
     def test_col_output_coords(self):
         self.assertModule("t.rast.what", strds="A", output="out_col_coords.txt",
@@ -91,7 +91,7 @@
                           nprocs=1, overwrite=True, verbose=True)
 
         self.assertFileMd5("out_col_coords.txt",
-                           "ac44ebc5aa040d4ce2a5787e95f208ec", text=True)
+                           "ecdc79a6880a9e1f163cc92fa384b8a3", text=True)
 
     def test_timerow_output(self):
         self.assertModule("t.rast.what", strds="A", output="out_timerow.txt",
@@ -107,7 +107,7 @@
                           nprocs=1, overwrite=True, verbose=True)
 
         self.assertFileMd5("out_col_cat.txt",
-                           "e1d8e6651b3bff1c35e366e48d634db4", text=True)
+                           "ac0a9b14e59920c3f8b5834282a24822", text=True)
 
     def test_timerow_output_cat(self):
         self.assertModule("t.rast.what", strds="A", output="out_col_trow.txt",
@@ -115,7 +115,7 @@
                           nprocs=1, overwrite=True, verbose=True)
 
         self.assertFileMd5("out_col_trow.txt",
-                           "55e2ff8ddaeb731a73daca48adf2768d", text=True)
+                           "1da3350f488df9c919b4009625956b3b", text=True)
 
     def test_timerow_output_coords(self):
         self.assertModule("t.rast.what", strds="A", output="out_timerow_coords.txt",



More information about the grass-commit mailing list