Skip to content

Remove the materials-palette shim (lib_compat) once easyreflectometry 2.0.1 is released #387

Open

Description

@rozyczko

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.py replaces Project._get_materials_from_model and Project._get_materials_in_models with the fixed versions, and wraps Project.from_dict so it drops mixtures from a loaded palette.
  • EasyReflectometryApp/Backends/Py/__init__.py calls lib_compat.install() before any Project is used.
  • It is guarded: if easyreflectometry.project already 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.1 in pyproject.toml.
  • Delete EasyReflectometryApp/Backends/Py/lib_compat.py and the lib_compat import and install() call in EasyReflectometryApp/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. Drop test_the_palette_fix_is_in_place and test_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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [priority] high[scope] bug

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions