Changeset ecb485c in sasmodels for sasmodels/core.py
- Timestamp:
- Jan 26, 2018 10:16:16 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- bb4ff2a
- Parents:
- a69d8cd (diff), ecf895e (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/core.py
r7a516d0 ra69d8cd 320 320 print("\n".join(list_models(kind))) 321 321 322 def test_load(): 323 # type: () -> None 324 """Check that model load works""" 322 def test_composite_order(): 325 323 def test_models(fst, snd): 326 324 """Confirm that two models produce the same parameters""" 327 325 fst = load_model(fst) 328 326 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. 332 332 fst = [[x for x in p.name if x == x.lower()] for p in fst.info.parameters.kernel_parameters] 333 333 snd = [[x for x in p.name if x == x.lower()] for p in snd.info.parameters.kernel_parameters] 334 334 assert sorted(fst) == sorted(snd), "{} != {}".format(fst, snd) 335 335 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( 338 342 "cylinder+sphere", 339 343 "sphere+cylinder") 340 test_models(344 yield build_test( 341 345 "cylinder*sphere", 342 346 "sphere*cylinder") 343 test_models(347 yield build_test( 344 348 "cylinder@hardsphere*sphere", 345 349 "sphere*cylinder@hardsphere") 346 test_models(350 yield build_test( 347 351 "barbell+sphere*cylinder@hardsphere", 348 352 "sphere*cylinder@hardsphere+barbell") 349 test_models(353 yield build_test( 350 354 "barbell+cylinder@hardsphere*sphere", 351 355 "cylinder@hardsphere*sphere+barbell") 352 test_models(356 yield build_test( 353 357 "barbell+sphere*cylinder@hardsphere", 354 358 "barbell+cylinder@hardsphere*sphere") 355 test_models(359 yield build_test( 356 360 "sphere*cylinder@hardsphere+barbell", 357 361 "cylinder@hardsphere*sphere+barbell") 358 test_models(362 yield build_test( 359 363 "barbell+sphere*cylinder@hardsphere", 360 364 "cylinder@hardsphere*sphere+barbell") 361 test_models(365 yield build_test( 362 366 "barbell+cylinder@hardsphere*sphere", 363 367 "sphere*cylinder@hardsphere+barbell") 364 368 369 def test_composite(): 370 # type: () -> None 371 """Check that model load works""" 365 372 #Test the the model produces the parameters that we would expect 366 373 model = load_model("cylinder@hardsphere*sphere")
Note: See TracChangeset
for help on using the changeset viewer.