def test_composite_order():
    """
    Check that mixture models produce the same result independent of ordder.
    """
    def test_models(fst, snd):
        """Confirm that two models produce the same parameters"""
        fst = load_model(fst)
        snd = load_model(snd)
        # Un-disambiguate parameter names so that we can check if the same
        # parameters are in a pair of composite models. Since each parameter in
        # the mixture model is tagged as e.g., A_sld, we ought to use a
        # regex subsitution s/^[A-Z]+_/_/, but removing all uppercase letters
        # is good enough.
        # TODO: check that the models produce the same results
        # Note that compare.py will give a misleading answer. For
        # "cylinder+sphere" the A_radius parameter will use the default
        # cylinder radius, but for "sphere+cylinder" it will use the default
        # sphere radius so a simple comparison of the two will appear to be
        # different unless you explicitly set radius, solvent, and solvent_sld
        # for the A and B models.
        fst = [[x for x in p.name if x == x.lower()]
               for p in fst.info.parameters.kernel_parameters]
        snd = [[x for x in p.name if x == x.lower()]
               for p in snd.info.parameters.kernel_parameters]
        assert sorted(fst) == sorted(snd), "{} != {}".format(fst, snd)

    test_models(
        "cylinder+sphere",
        "sphere+cylinder")
    test_models(
        "cylinder*sphere",
        "sphere*cylinder")
    test_models(
        "cylinder@hardsphere*sphere",
        "sphere*cylinder@hardsphere")
    test_models(
        "barbell+sphere*cylinder@hardsphere",
        "sphere*cylinder@hardsphere+barbell")
    test_models(
        "barbell+cylinder@hardsphere*sphere",
        "cylinder@hardsphere*sphere+barbell")
    test_models(
        "barbell+sphere*cylinder@hardsphere",
        "barbell+cylinder@hardsphere*sphere")
    test_models(
        "sphere*cylinder@hardsphere+barbell",
        "cylinder@hardsphere*sphere+barbell")
    test_models(
        "barbell+sphere*cylinder@hardsphere",
        "cylinder@hardsphere*sphere+barbell")
    test_models(
        "barbell+cylinder@hardsphere*sphere",
        "sphere*cylinder@hardsphere+barbell")