Opened 9 years ago

Closed 8 years ago

#2605 closed defect (worksforme)

d.rast.leg: invalid literal for float(): rectangle

Reported by: pertusus Owned by: grass-dev@…
Priority: normal Milestone: 7.0.5
Component: Display Version: svn-releasebranch70
Keywords: Cc:
CPU: Unspecified Platform: Unspecified

Description

I get a traceback for d.rast.leg.

d.rast.leg raster_selection_basins_change lines=2
Traceback (most recent call last):
  File "/usr/local/grass-7.0.0svn//scripts/d.rast.leg", line 167, in <module>
    main()
  File "/usr/local/grass-7.0.0svn//scripts/d.rast.leg", line 103, in main
    f = tuple([float(x) for x in s.split()[1:5]])
ValueError: invalid literal for float(): rectangle:

This is triggered by a wrong parsing of d.info which returns:

frame rectangle: 0.000000 640.000000 0.000000 480.000000

Original code is

[float(x) for x in s.split()[1:5]]

which naturally the to x being 'rectangle:'

I attach a patch where I propose instead:

[float(x) for x in s.split(":")[1].split()[0:4]]

It seems more robust, though I don't know if the : will be there forever. Overall, the approach is not very robust, but I have no idea on what's going on so I only propose that fix which may not be appropriate in other cases.

Attachments (1)

d.rast.leg_d.info-parsing.diff (488 bytes ) - added by pertusus 9 years ago.
patch to split first d.info output at :

Download all attachments as: .zip

Change History (9)

by pertusus, 9 years ago

patch to split first d.info output at :

comment:1 by neteler, 9 years ago

Milestone: 7.0.17.0.2

Ticket retargeted after 7.0.1 milestone closed

comment:2 by neteler, 8 years ago

Milestone: 7.0.27.0.3

Ticket retargeted after milestone closed

comment:3 by neteler, 8 years ago

I checked with the NC dataset, this one works:

GRASS 7.0.3svn (nc_spm_08):~ > g.region raster=basin_50K
GRASS 7.0.3svn (nc_spm_08):~ > d.mon wx0
GRASS 7.0.3svn (nc_spm_08):~ > d.rast.leg basin_50K lines=2
 100%
 100%
GRASS 7.0.3svn (nc_spm_08):~ > d.rast.leg basin_50K 
 100%
 100%

Do you have an North Carolina example which fails?

comment:4 by neteler, 8 years ago

Milestone: 7.0.3

Ticket retargeted after milestone closed

comment:5 by neteler, 8 years ago

Milestone: 7.0.4

Ticket retargeted after 7.0.3 milestone closed

comment:6 by neteler, 8 years ago

Is the proposed patch still needed?

comment:7 by martinl, 8 years ago

Milestone: 7.0.47.0.5

comment:8 by martinl, 8 years ago

Resolution: worksforme
Status: newclosed

No activity last 8 months, closing, feel free to reopen if needed.

Note: See TracTickets for help on using tickets.