#3727 closed defect (fixed)
t.rast.aggregate fails with python3
Reported by: | veroandreo | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 7.8.0 |
Component: | Temporal | Version: | svn-trunk |
Keywords: | t.rast.aggregate, t.rast.algebra, python3 | Cc: | |
CPU: | Unspecified | Platform: | Unspecified |
Description
Here's how to reproduce:
g.region raster=elevation for map in `seq 1 10` ; do r.mapcalc "prueba_${map} = ${map}" ; done t.create output=A type=strds temporaltype=absolute title="test" description="test" t.register input=A maps=`g.list rast pat=prueba* sep=, map=.` start="2000-01-01" increment="1 months" -i t.rast.aggregate in=A out=B granularity="2 months" method=average basename=b_bimonthly suffix=gran
and this is the error I get:
Traceback (most recent call last): File "/home/veroandreo/software/grass7_trunk/dist.x86_64-pc-linux-gnu/scripts/t.rast.aggregate", line 219, in <module> main() File "/home/veroandreo/software/grass7_trunk/dist.x86_64-pc-linux-gnu/scripts/t.rast.aggregate", line 196, in main overwrite=gcore.overwrite(), file_limit=file_limit) File "/home/veroandreo/software/grass7_trunk/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/aggregation.py", line 230, in aggregate_by_topology topo_builder.build(mapsA=granularity_list, mapsB=map_list, spatial=spatial) File "/home/veroandreo/software/grass7_trunk/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/spatio_temporal_relationships.py", line 569, in build self._build_internal_iteratable(mapsA, spatial) File "/home/veroandreo/software/grass7_trunk/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/spatio_temporal_relationships.py", line 411, in _build_internal_iteratable self._detect_first() File "/home/veroandreo/software/grass7_trunk/dist.x86_64-pc-linux-gnu/etc/python/grass/temporal/spatio_temporal_relationships.py", line 378, in _detect_first prev_ = self._store.values()[0] TypeError: 'dict_values' object does not support indexing WARNING:root:Needed to restart the libgis server, caller: Server check thread
It works fine in 76 rel branch. I am using trunk r73904 in virtualenv with python3.
Attachments (1)
Change History (8)
comment:1 by , 6 years ago
comment:2 by , 6 years ago
Keywords: | t.rast.algebra added |
---|---|
Priority: | normal → major |
G7:t.rast.algebra fails with the same error when trying to add 2 strds. To test, just create another strds (B) and run:
for map in `seq -w 1 10` ; do r.mapcalc "bla_${map} = ${map}" ; done t.create output=B type=strds temporaltype=absolute title="test" description="test2" t.register input=B maps=`g.list rast pat=bla* sep=, map=.` start="2000-01-01" increment="1 months" -i t.rast.algebra expression="C = A + B" basename=c_test
follow-up: 5 comment:3 by , 6 years ago
This problem can be solved by wrapping list() around the dictionary value type in "temporal/spatio_temporal_relationships.py", line 378, in _detect_first:
prev_ = list(self._store.values())[0]
comment:4 by , 6 years ago
I just applied your modification, but when I compile in python 3 virtualenv as suggested here https://trac.osgeo.org/grass/wiki/Python3Support#Howtotest, I get compilation errors everywhere.
I guess I'm doing something wrong. Can someone else try, please? I just attached the small patch as to ease testing
comment:5 by , 6 years ago
Replying to huhabla:
This problem can be solved by wrapping list() around the dictionary value type in "temporal/spatio_temporal_relationships.py", line 378, in _detect_first:
prev_ = list(self._store.values())[0]
I tested this as well via Vero's patch:
t.create output=A type=strds temporaltype=absolute title="test" description="test" Creates a space time dataset. Usage: t.create output=name maps=name[,name,...] [type=name] semantictype=string title=string description=string [--overwrite] [--help] [--verbose] [--quiet] [--ui] Flags: Parameters: output Name of the output space time dataset maps Type of the output space time dataset type Type of the input map options: raster,vector,raster_3d default: raster semantictype Semantic type of the space time dataset options: min,max,sum,mean default: mean title Title of the new space time dataset description Description of the new space time dataset ERROR: t.create: Sorry, <temporaltype> is not a valid parameter ERROR: Value <strds> out of range for parameter <type> Legal range: raster,vector,raster_3d ERROR: Required parameter <maps> not set: (Type of the output space time dataset)
... quite weird!
comment:7 by , 6 years ago
So, compilation problem was a different issue, i.e., i updated my system and was using an old virtualenv. I trashed it, created a new one, compiled grass there and the patch solved the reported error. Thanks, Soeren!
However, there are new errors now in G7:g.gui.animation, G7:g.gui.timeline and G7:g.gui.tplot that I'll report in separate tickets.
For the record, all the temporal GUI tools: G7:g.gui.timeline, G7:g.gui.animation and G7:g.gui.tplot also yield the same error (I can create a new ticket if needed). Here's how to test following the previous example: