Repository navigation
Description
Background
easyreflectometry releases up to 2.0.0 put every layer's material into the materials palette, including a surfactant layer's MaterialSolvated (a MaterialMixture). The Material editor reads material.sld.value from each palette entry, and a mixture's SLD is a computed float, so one mixture in the palette breaks the editor: QML shows only BackendWrapper.qml: Error: <NULL>. It happens after Add contrast of a model with a surfactant layer (the DSPC example projects invite exactly this), and when loading a project file saved in that state. The in-use check run before a material is removed also looks at the mixture instead of the surfactant's solvent, so it misses the solvent.
The fix belongs in reflectometry-lib (_palette_materials in easyreflectometry/project.py): a mixture is replaced by its constituents, an area-per-molecule layer adds only its solvent, and from_dict drops mixtures from older files' palettes. That fix is not released yet.
To ship 1.6.1 without a library release, the app has a shim:
EasyReflectometryApp/Backends/Py/lib_compat.pyreplacesProject._get_materials_from_modelandProject._get_materials_in_modelswith the fixed versions, and wrapsProject.from_dictso it drops mixtures from a loaded palette.EasyReflectometryApp/Backends/Py/__init__.pycallslib_compat.install()before anyProjectis used.- It is guarded: if
easyreflectometry.projectalready has_palette_materials,install()does nothing.
The shim patches private library methods, so a library release that renames or reshapes them could break it. tests/test_lib_compat.py covers that against the real library.
To do, once easyreflectometry 2.0.1 (with the palette fix) is on PyPI
- Require
easyreflectometry>=2.0.1inpyproject.toml. - Delete
EasyReflectometryApp/Backends/Py/lib_compat.pyand thelib_compatimport andinstall()call inEasyReflectometryApp/Backends/Py/__init__.py. - In
tests/test_lib_compat.py, keep the behaviour tests (Add contrast of a surfactant model, solvent counted as in use, old file with a mixture in the palette) by moving them to an existing test module. Droptest_the_palette_fix_is_in_placeandtest_the_patch_matches_the_fixed_library. - Update the CHANGELOG line under 1.6.1, "it needs easyreflectometry with the materials-palette fix", which will no longer apply.
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsIn Progress
Activity