Changeset 7a516d0 in sasmodels
- Timestamp:
- Jan 25, 2018 10:13:41 AM (7 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- c11d09f
- Parents:
- 7fec3b7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
re68bae9 r7a516d0 320 320 print("\n".join(list_models(kind))) 321 321 322 def test_load(): 323 # type: () -> None 324 """Check that model load works""" 325 def test_models(fst, snd): 326 """Confirm that two models produce the same parameters""" 327 fst = load_model(fst) 328 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 332 fst = [[x for x in p.name if x == x.lower()] for p in fst.info.parameters.kernel_parameters] 333 snd = [[x for x in p.name if x == x.lower()] for p in snd.info.parameters.kernel_parameters] 334 assert sorted(fst) == sorted(snd), "{} != {}".format(fst, snd) 335 336 337 test_models( 338 "cylinder+sphere", 339 "sphere+cylinder") 340 test_models( 341 "cylinder*sphere", 342 "sphere*cylinder") 343 test_models( 344 "cylinder@hardsphere*sphere", 345 "sphere*cylinder@hardsphere") 346 test_models( 347 "barbell+sphere*cylinder@hardsphere", 348 "sphere*cylinder@hardsphere+barbell") 349 test_models( 350 "barbell+cylinder@hardsphere*sphere", 351 "cylinder@hardsphere*sphere+barbell") 352 test_models( 353 "barbell+sphere*cylinder@hardsphere", 354 "barbell+cylinder@hardsphere*sphere") 355 test_models( 356 "sphere*cylinder@hardsphere+barbell", 357 "cylinder@hardsphere*sphere+barbell") 358 test_models( 359 "barbell+sphere*cylinder@hardsphere", 360 "cylinder@hardsphere*sphere+barbell") 361 test_models( 362 "barbell+cylinder@hardsphere*sphere", 363 "sphere*cylinder@hardsphere+barbell") 364 365 #Test the the model produces the parameters that we would expect 366 model = load_model("cylinder@hardsphere*sphere") 367 actual = [p.name for p in model.info.parameters.kernel_parameters] 368 target = ("sld sld_solvent radius length theta phi volfraction" 369 " A_sld A_sld_solvent A_radius").split() 370 assert target == actual, "%s != %s"%(target, actual) 371 322 372 if __name__ == "__main__": 323 373 list_models_main()
Note: See TracChangeset
for help on using the changeset viewer.