Skip to content

ModelCollection DEFAULT_ELEMENTS passes the calculator interface as the 'sample' argument #371

@rozyczko

Description

@rozyczko

Summary

src/easyreflectometry/model/model_collection.py:16-18:

def DEFAULT_ELEMENTS(interface):
    return (Model(interface),)

Model.__init__'s first positional parameter is sample, not interface (model/model.py:66-76). Constructing ModelCollection(interface=<real interface>) with no models therefore builds a Model whose sample is a calculator-interface object.

Notes

  • Latent because the only test of the default path uses interface=None (tests/model/test_model_collection.py::test_default), and Model(None) is harmless.
  • Peer collections do it correctly with keywords (sample/collections/sample.py:21 uses Multilayer(interface=interface)), as does ModelCollection.add_model.

Suggested fix

return (Model(interface=interface),) plus a test constructing the collection with a real calculator.

Found during deep code review (DEEP_ANALYSIS.md §5.1).

Metadata

Metadata

Assignees

No one assigned

    Labels

    [priority] mediumNormal/default priority[scope] bugBug report or fix (major.minor.PATCH)
    No fields configured for issues without a type.

    Projects

    Status
    Bugs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions