Changeset 2455 for trunk

Show
Ignore:
Timestamp:
01/16/2008 11:32:27 AM (12 months ago)
Author:
wd15
Message:

updating fipy for numpy 1.0.4

Location:
trunk/fipy
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/fipy/meshes/numMesh/mesh.py

    r2447 r2455  
    218218        for i in range(otherNumFaces): 
    219219##          Seems to be overwriting other.faceVertexIDs with new numpy 
    220 ##            currFace = other.faceVertexIDs[i]  
    221             currFace = other.faceVertexIDs[...,i].copy() 
     220##            currFace = other.faceVertexIDs[i] 
     221##            currFace = other.faceVertexIDs[...,i].copy() 
     222##          Changed this again as numpy 1.0.4 seems to have no copy method for 
     223##          masked arrays. 
     224            try: 
     225                currFace = other.faceVertexIDs[...,i].copy() 
     226            except: 
     227                currFace = MA.array(other.faceVertexIDs[...,i], mask=MA.getmask(other.faceVertexIDs[...,i])) 
     228 
    222229            keepGoing = 1 
    223230            currIndex = 0  
  • trunk/fipy/tools/numerix.py

    r2347 r2455  
    283283                                    separator=separator) 
    284284    elif isFloat(arr): 
    285         from numpy.core.arrayprint import _floatFormat, _formatFloat 
    286 ##      _floatFormat seems to be broken 
    287 ##         if isinstance(arr, NUMERIX.ndarray): 
    288 ##             format, length = _floatFormat(arr, precision=precision,  
    289 ##                                           suppress_small=suppress_small) 
    290 ##         else: 
    291 ##             format, length = _floatFormat(NUMERIX.array(arr),  
    292 ##                                           precision=precision, suppress_small=suppress_small) 
    293         return _formatFloat(arr, format='%%1.%df' % precision) 
     285        try: 
     286            ## this is for numpy 1.0.4 and above 
     287            ## why has the interface changed again? 
     288            from numpy.core.arrayprint import FloatFormat 
     289            return FloatFormat(NUMERIX.array((arr,)), precision, suppress_small)(arr).strip()        
     290        except: 
     291            from numpy.core.arrayprint import _floatFormat, _formatFloat 
     292            return _formatFloat(arr, format='%%1.%df' % precision) 
     293 
    294294    elif isInt(arr): 
    295295        from numpy.core.arrayprint import _formatInteger 
     
    568568 
    569569        >>> print tostring(cos(2*pi/6), precision=3) 
    570         0.5   
     570        0.5 
    571571        >>> print tostring(cos(array((0,2*pi/6,pi/2))), precision=3, suppress_small=1) 
    572572        [ 1.   0.5  0. ]