Changeset a69d8cd in sasmodels for sasmodels/core.py


Ignore:
Timestamp:
Jan 26, 2018 7:13:22 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
ecb485c
Parents:
49284e1
Message:

add support for pytest and use it on travis/appveyor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/core.py

    r7a516d0 ra69d8cd  
    320320    print("\n".join(list_models(kind))) 
    321321 
    322 def test_load(): 
    323     # type: () -> None 
    324     """Check that model load works""" 
     322def test_composite_order(): 
    325323    def test_models(fst, snd): 
    326324        """Confirm that two models produce the same parameters""" 
    327325        fst = load_model(fst) 
    328326        snd = load_model(snd) 
    329         # Remove the upper case characters frin the parameters, since 
    330         # they lasndel the order of events and we specfically are 
    331         # changin that aspect 
     327        # Un-disambiguate parameter names so that we can check if the same 
     328        # parameters are in a pair of composite models. Since each parameter in 
     329        # the mixture model is tagged as e.g., A_sld, we ought to use a 
     330        # regex subsitution s/^[A-Z]+_/_/, but removing all uppercase letters 
     331        # is good enough. 
    332332        fst = [[x for x in p.name if x == x.lower()] for p in fst.info.parameters.kernel_parameters] 
    333333        snd = [[x for x in p.name if x == x.lower()] for p in snd.info.parameters.kernel_parameters] 
    334334        assert sorted(fst) == sorted(snd), "{} != {}".format(fst, snd) 
    335335 
    336  
    337     test_models( 
     336    def build_test(first, second): 
     337        test = lambda description: test_models(first, second) 
     338        description = first + " vs. " + second 
     339        return test, description 
     340 
     341    yield build_test( 
    338342        "cylinder+sphere", 
    339343        "sphere+cylinder") 
    340     test_models( 
     344    yield build_test( 
    341345        "cylinder*sphere", 
    342346        "sphere*cylinder") 
    343     test_models( 
     347    yield build_test( 
    344348        "cylinder@hardsphere*sphere", 
    345349        "sphere*cylinder@hardsphere") 
    346     test_models( 
     350    yield build_test( 
    347351        "barbell+sphere*cylinder@hardsphere", 
    348352        "sphere*cylinder@hardsphere+barbell") 
    349     test_models( 
     353    yield build_test( 
    350354        "barbell+cylinder@hardsphere*sphere", 
    351355        "cylinder@hardsphere*sphere+barbell") 
    352     test_models( 
     356    yield build_test( 
    353357        "barbell+sphere*cylinder@hardsphere", 
    354358        "barbell+cylinder@hardsphere*sphere") 
    355     test_models( 
     359    yield build_test( 
    356360        "sphere*cylinder@hardsphere+barbell", 
    357361        "cylinder@hardsphere*sphere+barbell") 
    358     test_models( 
     362    yield build_test( 
    359363        "barbell+sphere*cylinder@hardsphere", 
    360364        "cylinder@hardsphere*sphere+barbell") 
    361     test_models( 
     365    yield build_test( 
    362366        "barbell+cylinder@hardsphere*sphere", 
    363367        "sphere*cylinder@hardsphere+barbell") 
    364368 
     369def test_composite(): 
     370    # type: () -> None 
     371    """Check that model load works""" 
    365372    #Test the the model produces the parameters that we would expect 
    366373    model = load_model("cylinder@hardsphere*sphere") 
Note: See TracChangeset for help on using the changeset viewer.