Changeset 788cbd1 in sasmodels


Ignore:
Timestamp:
Feb 21, 2017 10:10:11 AM (8 years ago)
Author:
GitHub <noreply@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
a3002be, 3fc5d27
Parents:
9ed53e7 (diff), 749a7d4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Paul Kienzle <pkienzle@…> (02/21/17 10:10:11)
git-committer:
GitHub <noreply@…> (02/21/17 10:10:11)
Message:

Merge pull request #31 from SasView?/ticket-816

ticket-816: test that model calculation returns NaN if point is out of range

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sasview_model.py

    ra38b065 r749a7d4  
    734734            return [self.params[par.name]], [1.0] 
    735735 
    736 def test_model(): 
     736def test_cylinder(): 
    737737    # type: () -> float 
    738738    """ 
    739     Test that a sasview model (cylinder) can be run. 
     739    Test that the cylinder model runs, returning the value at [0.1,0.1]. 
    740740    """ 
    741741    Cylinder = _make_standard_model('cylinder') 
     
    746746    # type: () -> float 
    747747    """ 
    748     Test that a sasview model (cylinder) can be run. 
     748    Test that 2-D hardsphere model runs and doesn't produce NaN. 
    749749    """ 
    750750    Model = _make_standard_model('hardsphere') 
     
    757757    # type: () -> float 
    758758    """ 
    759     Test that a sasview model (cylinder) can be run. 
     759    Test that the 2-D RPA model runs 
    760760    """ 
    761761    RPA = _make_standard_model('rpa') 
     
    763763    return rpa.evalDistribution([0.1, 0.1]) 
    764764 
     765def test_empty_distribution(): 
     766    # type: () -> None 
     767    """ 
     768    Make sure that sasmodels returns NaN when there are no polydispersity points 
     769    """ 
     770    Cylinder = _make_standard_model('cylinder') 
     771    cylinder = Cylinder() 
     772    cylinder.setParam('radius', -1.0) 
     773    cylinder.setParam('background', 0.) 
     774    Iq = cylinder.evalDistribution(np.asarray([0.1])) 
     775    assert np.isnan(Iq[0]), "empty distribution fails" 
    765776 
    766777def test_model_list(): 
    767778    # type: () -> None 
    768779    """ 
    769     Make sure that all models build as sasview models. 
     780    Make sure that all models build as sasview models 
    770781    """ 
    771782    from .exception import annotate_exception 
     
    794805 
    795806if __name__ == "__main__": 
    796     print("cylinder(0.1,0.1)=%g"%test_model()) 
     807    print("cylinder(0.1,0.1)=%g"%test_cylinder()) 
     808    #test_empty_distribution() 
Note: See TracChangeset for help on using the changeset viewer.