Changeset 5658


Ignore:
Timestamp:
Aug 14, 2008, 1:24:02 PM (16 years ago)
Author:
ole
Message:

Added more input checks in Polygon_function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/utilities/polygon.py

    r5570 r5658  
    686686        except:
    687687            msg = 'Polygon_function takes a list of pairs (polygon, value).'
    688             msg += 'Got %s' %polygons
     688            msg += 'Got %s' %regions
    689689            raise msg
    690690
    691691
    692692        T = regions[0]
     693
     694        if isinstance(T, basestring):
     695            msg = 'You passed in a list of text values into polygon_function'
     696            msg += ' instead of a list of pairs (polygon, value): "%s"' %T
     697           
     698            raise Exception, msg
     699       
    693700        try:
    694701            a = len(T)
    695702        except:
    696703            msg = 'Polygon_function takes a list of pairs (polygon, value).'
    697             msg += 'Got %s' %polygons
     704            msg += 'Got %s' %str(T)
    698705            raise msg
    699706
    700         assert a == 2, 'Must have two component each: %s' %T
     707        msg = 'Each entry in regions have two components: (polygon, value).'
     708        msg +='I got %s' %str(T)
     709        assert a == 2, msg
    701710
    702711
Note: See TracChangeset for help on using the changeset viewer.