#3391 closed defect (fixed)

r.learn.ml : the list of caterory map indices is not handled properly.

Reported by: maitl Owned by: grass-dev@…
Priority: normal Milestone: 7.2.2
Component: Addons Version: unspecified
Keywords: Cc:
CPU: All Platform: All

Description

# 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

Attachments (1)

r.learn.ml (32.5 KB) - added by maitl 19 months ago.
The copy of r.learn.ml with bugfix example

Download all attachments as: .zip

Change History (2)

Changed 19 months ago by maitl

Attachment: r.learn.ml added

The copy of r.learn.ml with bugfix example

comment:1 Changed 19 months ago by spawley

Resolution: fixed
Status: newclosed

Thanks again for this Jaan, I have updated the Add-Ons with #71358 and I'm closing the ticket.

Note: See TracTickets for help on using tickets.