Skip to content

Commit

Permalink
t.rast.algebra: do not print when debug is off (#2926)
Browse files Browse the repository at this point in the history
  • Loading branch information
petrasovaa authored Apr 22, 2023
1 parent b8dd380 commit c05cc14
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
10 changes: 6 additions & 4 deletions python/grass/temporal/temporal_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,8 @@ def set_temporal_extent_list(self, maplist, topolist=["EQUAL"], temporal="l"):
returncode = self.overlay_map_extent(
map_new, map_j, "and", temp_op=temporal
)
print(map_new.get_id(), map_j.get_id())
if self.debug:
print(map_new.get_id(), map_j.get_id())
# Stop the loop if no temporal or spatial relationship exist.
if returncode == 0:
break
Expand Down Expand Up @@ -1339,7 +1340,7 @@ def _check_spatial_topology_entries(self, spatial_topo_list, spatial_relations):
if spatial_topology in spatial_relations.keys():
spatial_topo_check = True

if self.debug is True:
if self.debug:
print("Spatial topology list", spatial_topo_list, spatial_topo_check)

return spatial_topo_check
Expand All @@ -1366,7 +1367,7 @@ def _check_spatial_topology_relation(self, spatial_topo_list, map_a, map_b):
if map_b in map_a_sr[spatial_topology]:
spatial_topo_check = True

if self.debug is True:
if self.debug:
print("Spatial topology list", spatial_topo_list, spatial_topo_check)

return spatial_topo_check
Expand Down Expand Up @@ -2597,7 +2598,8 @@ def p_expr_stvds_function(self, t):
expr : STVDS LPAREN stds RPAREN
"""
if self.run:
print(t[3])
if self.debug:
print(t[3])
t[0] = self.check_stds(t[3], stds_type="stvds", check_type=False)
else:
t[0] = t[3]
Expand Down
39 changes: 21 additions & 18 deletions python/grass/temporal/temporal_raster_base_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,18 +269,19 @@ def build_spatio_temporal_topology_list(
a9@B
"""
print(
topolist,
assign_val,
count_map,
compare_bool,
compare_cmd,
compop,
aggregate,
new,
convert,
operator_cmd,
)
if self.debug:
print(
topolist,
assign_val,
count_map,
compare_bool,
compare_cmd,
compop,
aggregate,
new,
convert,
operator_cmd,
)

# Check the topology definitions and return the list of temporal and spatial
# topological relations that must be fulfilled
Expand Down Expand Up @@ -486,8 +487,8 @@ def compare_cmd_value(
cmd_value_str = "".join(map(str, cmd_value_list))
# Add command list to result map.
map_i.cmd_list = cmd_value_str

print(cmd_value_str)
if self.debug:
print(cmd_value_str)

return cmd_value_str

Expand Down Expand Up @@ -536,8 +537,8 @@ def operator_cmd_value(
)
# Add command list to result map.
map_i.cmd_list = cmdstring

print("map command string", cmdstring)
if self.debug:
print("map command string", cmdstring)
return cmdstring

def set_temporal_extent_list(
Expand Down Expand Up @@ -721,7 +722,8 @@ def build_condition_cmd_list(
return resultlist
elif isinstance(conclusionlist, list):
# Build result command map list between conditions and conclusions.
print("build_condition_cmd_list", condition_topolist)
if self.debug:
print("build_condition_cmd_list", condition_topolist)
conditiontopolist = self.build_spatio_temporal_topology_list(
iflist, conclusionlist, topolist=condition_topolist
)
Expand Down Expand Up @@ -1799,7 +1801,8 @@ def p_s_numeric_condition_elif(self, t):
numelse = t[9] + t[10] + t[11]
numthen = str(numthen)
numelse = str(numelse)
print(numthen + " " + numelse)
if self.debug:
print(numthen + " " + numelse)
# Create conditional command map list.
resultlist = self.build_condition_cmd_list(
ifmaplist,
Expand Down
7 changes: 4 additions & 3 deletions python/grass/temporal/temporal_vector_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ def p_statement_assign(self, t):
# Map is original from an input STVDS
map_i.load()
# Register map in result space time dataset.
print(map_i.get_temporal_extent_as_tuple())
if self.debug:
print(map_i.get_temporal_extent_as_tuple())
success = resultstds.register_map(map_i, dbif=dbif)
resultstds.update_from_registered_maps(dbif)

Expand Down Expand Up @@ -628,7 +629,7 @@ def p_overlay_operation(self, t):

t[0] = resultlist
if self.debug:
str(t[1]) + t[2] + str(t[3])
print(str(t[1]) + t[2] + str(t[3]))

def p_overlay_operation_relation(self, t):
"""
Expand Down Expand Up @@ -659,7 +660,7 @@ def p_overlay_operation_relation(self, t):

t[0] = resultlist
if self.debug:
str(t[1]) + t[2] + str(t[3])
print(str(t[1]) + t[2] + str(t[3]))

def p_buffer_operation(self, t):
"""
Expand Down

0 comments on commit c05cc14

Please sign in to comment.