Changeset 82923a6 in sasmodels


Ignore:
Timestamp:
Apr 18, 2016 8:31:11 AM (9 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3a45c2c, f36c1b7
Parents:
7835d462
Message:

allow tests against inf and nan

Location:
sasmodels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/model_test.py

    re78edc4 r82923a6  
    207207                    self.assertTrue(np.isfinite(actual_yi), 
    208208                                    'invalid f(%s): %s' % (xi, actual_yi)) 
     209                elif np.isnan(yi): 
     210                    self.assertTrue(np.isnan(actual_yi), 
     211                                    'f(%s): expected:%s; actual:%s' 
     212                                    % (xi, yi, actual_yi)) 
    209213                else: 
    210                     self.assertTrue(is_near(yi, actual_yi, 5), 
     214                    # is_near does not work for infinite values, so also test 
     215                    # for exact values.  Note that this will not 
     216                    self.assertTrue(yi==actual_yi or is_near(yi, actual_yi, 5), 
    211217                                    'f(%s); expected:%s; actual:%s' 
    212218                                    % (xi, yi, actual_yi)) 
  • sasmodels/models/porod.py

    rec45c4f r82923a6  
    2626""" 
    2727 
    28 from numpy import sqrt, power 
     28from numpy import sqrt, power, inf, errstate 
    2929 
    3030name = "porod" 
     
    4242    @param q: Input q-value 
    4343    """ 
    44     return 1.0/power(q, 4) 
     44    with errstate(divide='ignore'): 
     45        return power(q, -4) 
    4546 
    4647Iq.vectorized = True  # Iq accepts an array of q values 
     
    5859demo = dict(scale=1.5, background=0.5) 
    5960 
    60 tests = [[{'scale': 0.00001, 'background':0.01}, 0.04, 3.916250]] 
     61tests = [ 
     62    [{'scale': 0.00001, 'background':0.01}, 0.04, 3.916250], 
     63    [{}, 0.0, inf], 
     64] 
Note: See TracChangeset for help on using the changeset viewer.