Ignore:
Timestamp:
Sep 10, 2013, 8:12:49 AM (11 years ago)
Author:
steve
Message:

Got rid of comparison warnings with nans in test_interpolate2d.py

Location:
trunk/anuga_core/source/anuga/fit_interpolate
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/fit_interpolate/interpolate2d.py

    r8967 r8969  
    142142
    143143    # Identify elements that are outside interpolation domain or NaN
     144    oldset = numpy.seterr(invalid='ignore')  # Suppress comparison with nan warning
    144145    outside = (xi < x[0]) + (eta < y[0]) + (xi > x[-1]) + (eta > y[-1])
    145146    outside += numpy.isnan(xi) + numpy.isnan(eta)
    146 
     147    numpy.seterr(**oldset)  # Restore warnings
     148   
    147149    # Restrict interpolation points to those that are inside the grid
    148150    inside = -outside  # Invert boolean array to find elements inside
     
    271273
    272274    if bounds_error:
    273         xi0 = min(xi)
    274         xi1 = max(xi)
    275         eta0 = min(eta)
    276         eta1 = max(eta)
     275        xi0 = numpy.nanmin(xi)
     276        xi1 = numpy.nanmax(xi)
     277        eta0 = numpy.nanmin(eta)
     278        eta1 = numpy.nanmax(eta)
    277279
    278280        msg = ('Interpolation point xi=%f was less than the smallest '
  • trunk/anuga_core/source/anuga/fit_interpolate/test_interpolate2d.py

    r8967 r8969  
    250250        xis = numpy.linspace(x[0], x[-1], 10)
    251251        etas = numpy.linspace(y[0], y[-1], 10)
     252       
    252253        xis[6:7] = numpy.nan
    253254        etas[3] = numpy.nan
    254255        points = axes2points(xis, etas)
    255 
     256       
    256257        vals = interpolate2d(x, y, A, points, mode='linear')
    257258        refs = linear_function(points[:, 0], points[:, 1])
     259       
    258260        assert nanallclose(vals, refs, rtol=1e-12, atol=1e-12)
    259261
     
    279281        etas = numpy.linspace(y[0], y[-1], 10)
    280282        points = axes2points(xis, etas)
     283
    281284
    282285        vals = interpolate2d(x, y, A, points, mode='linear')
Note: See TracChangeset for help on using the changeset viewer.