Ignore:
Timestamp:
Mar 5, 2009, 8:29:28 AM (14 years ago)
Author:
rwilson
Message:

More testing for ensure_numeric()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/utilities/numerical_tools.py

    r6441 r6456  
    249249        typecode:    numeric type. If specified, use this in the conversion.
    250250                     If not, let numeric package decide.
    251                      numpy assumes float64 if no type in A.
    252251                     typecode will always be one of num.float, num.int, etc.
    253252
     
    258257    """
    259258
    260     if isinstance(A, basestring):
    261         msg = 'Sorry, cannot handle string in ensure_numeric()'
     259    #if isinstance(A, basestring):
     260    if isinstance(A, str):
     261        msg = 'ASorry, cannot handle strings in ensure_numeric()'
    262262        raise Exception, msg
     263
     264    try:
     265        elt = A[0]
     266    except TypeError:
     267        pass
     268    else:
     269        if isinstance(A, basestring):
     270            msg = 'BSorry, cannot handle strings in ensure_numeric()'
     271            raise Exception, msg
     272
    263273
    264274    if typecode is None:
     
    271281
    272282
    273 
    274 
    275283def histogram(a, bins, relative=False):
    276284    """Standard histogram straight from the numeric manual
Note: See TracChangeset for help on using the changeset viewer.