[GRASS-dev] [GRASS GIS] #3391: r.learn.ml : the list of caterory map indices is not handled properly.
GRASS GIS
trac at osgeo.org
Wed Aug 9 05:26:03 PDT 2017
#3391: r.learn.ml : the list of caterory map indices is not handled properly.
--------------------+-------------------------
Reporter: maitl | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone: 7.2.2
Component: Addons | Version: unspecified
Keywords: | CPU: All
Platform: All |
--------------------+-------------------------
# convert to lists
"""
if ',' in categorymaps:
categorymaps = [int(i) for i in categorymaps.split(',')]
print(categorymaps)
else: categorymaps = None
"""
fails if there is only one category map.
------------------------------------------
The proposed solution is
if categorymaps.strip() == '':
categorymaps = None
else:
try:
categorymaps = [int(i.strip()) for i in
categorymaps.split(',')]
# negatiivse ja maplist, _ = maps_from_group(group) suurima
indeksi kontroll, dublikaatide kontroll (unique)
nCategories = len(maps_from_group(group)[0])
if min(categorymaps) < 0:
gscript.fatal('Category map index can not be negative.')
if max(categorymaps) > nCategories - 1:
gscript.fatal('Category map index input can not exceed ' +
str(nCategories - 1))
if not len(np.unique(categorymaps)) == len(categorymaps):
gscript.fatal('Duplicate indices in category map index
list.')
except:
gscript.fatal('Error in category map list input.')
if ',' in indexes:
indexes = [int(i) for i in indexes.split(',')]
else:
indexes = int(indexes)
if indexes == -1: indexes = None
# credits for this fix go to Jaan Janno from Tartu University, Estonia
--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3391>
GRASS GIS <https://grass.osgeo.org>
More information about the grass-dev
mailing list