[GRASS-dev] failing doctest when delete temporal dataset
Luca Delucchi
lucadeluge at gmail.com
Thu Feb 18 02:49:29 PST 2016
Hi devs,
I added (patch provided as attachment) a doctest in list_maps_of_stds
temporal function. I get the following error, but if I run the python
code of the test I get not error. Do you have any idea how to solve
it?
File "list_stds.py", line 181, in list_stds.list_maps_of_stds
Failed example:
check = sp.delete()
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.7/doctest.py", line 1315, in __run
compileflags, 1) in test.globs
File "<doctest list_stds.list_maps_of_stds[17]>", line 1, in <module>
check = sp.delete()
File "/home/lucadelu/compilati/grass_trunk/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/abstract_space_time_dataset.py",
line 1943, in delete
self.msgr.verbose(_("Delete space time %s dataset <%s> from temporal "
TypeError: 'int' object is not callable
--
ciao
Luca
http://gis.cri.fmach.it/delucchi/
www.lucadelu.org
-------------- next part --------------
Index: lib/python/temporal/list_stds.py
===================================================================
--- lib/python/temporal/list_stds.py (revision 67872)
+++ lib/python/temporal/list_stds.py (working copy)
@@ -52,7 +52,8 @@
>>> tgis.init()
>>> name = "list_stds_test"
>>> sp = tgis.open_new_stds(name=name, type="strds",
- ... temporaltype="absolute", title="title", descr="descr", semantic="mean", dbif=None, overwrite=True)
+ ... temporaltype="absolute", title="title", descr="descr",
+ ... semantic="mean", dbif=None, overwrite=True)
>>> mapset = tgis.get_current_mapset()
>>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name")
>>> rows = stds_list[mapset]
@@ -60,7 +61,8 @@
... if row["name"] == name:
... print True
True
- >>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name,mapset", where="mapset = '%s'"%(mapset))
+ >>> stds_list = tgis.get_dataset_list("strds", "absolute",
+ ... columns="name,mapset", where="mapset = '%s'"%(mapset))
>>> rows = stds_list[mapset]
>>> for row in rows:
... if row["name"] == name and row["mapset"] == mapset:
@@ -145,6 +147,38 @@
set, in case gran=None the granule of the space time
dataset is used
:param outpath: The path to file where to save output
+
+ >>> import grass.temporal as tgis
+ >>> tgis.init()
+ >>> name = "list_stds_test"
+ >>> sp = tgis.open_new_stds(name=name, type="strds",
+ ... temporaltype="absolute", title="title", descr="descr",
+ ... semantic="mean", dbif=None, overwrite=True)
+ >>> from grass.script.raster import mapcalc
+ >>> mapcalc("register_map_1 = 1", quiet=True, overwrite=True)
+ >>> mapcalc("register_map_2 = 2", quiet=True, overwrite=True)
+ >>> tgis.register_maps_in_space_time_dataset('raster', name,
+ ... maps='register_map_1,register_map_2', start='2016-02-01', end="2016-02-02")
+ >>> tgis.list_maps_of_stds('raster', name, 'name', 'start_time', None,
+ ... '|', 'cols', True)
+ register_map_1
+ register_map_2
+ >>> import grass.script as gscript
+ >>> out = gscript.tempfile()
+ >>> tgis.list_maps_of_stds('raster', name, 'name', 'start_time', None,
+ ... '|', 'cols', True, outpath=out)
+ >>> fi = open(out)
+ >>> for line in fi.readlines():
+ ... print line.strip()
+ register_map_1
+ register_map_2
+ >>> maps = sp.get_registered_maps_as_objects()
+ >>> for ma in maps:
+ ... sel = ma.select()
+ ... dele = ma.delete()
+ >>> gscript.run_command('g.remove', type='raster', name='register_map_1,register_map_2', flags='f')
+ 0
+ >>> check = sp.delete()
"""
dbif, connected = init_dbif(dbif)
More information about the grass-dev
mailing list