Skip to content

API/test hygiene batch: reflectity_profile typo, MaterialMixture.sld type asymmetry, no-op assertions, doc mismatches #381

@rozyczko

Description

@rozyczko

Summary

Grouped small items, each cheap to fix now and expensive to fix after the API ossifies:

  1. Public API typo reflectity_profile in calculator_base.py:192, factory.py:43, project.py:668 — rename to reflectivity_profile with a deprecation alias.
  2. LSP wrinkle: Material.sld returns a Parameter while MaterialMixture.sld returns a float (material_mixture.py:159-165); both flow into Layer.material, so layer.material.sld.value works or crashes depending on material type. Return the Parameter consistently.
  3. No-op test assertions: tests/model/test_resolution_functions.py:41, 70, 115-120assert resolution_function.as_dict(), {...} (comma, not comparison; always passes) and bare as_dict() == {...} expressions without assert.
  4. mcmc_sample doc/API mismatch: the docstring (and bayesian.py:1335 load_posterior) advertises resume_state=, but fitting.py:358-437 has no such parameter — resume is either unimplemented or renamed.
  5. ResolutionFunction uses @abstractmethod without ABC (resolution_functions.py:23-28) — abstractness not enforced.
  6. Model.add_assemblies(*assemblies: list[BaseAssembly]) (model.py:151) — wrong annotation; each vararg is a BaseAssembly.
  7. molecular_weight docstring claims kilograms (special/calculations.py:66); value is u (g/mol). In neutron_scattering_length (:47-51) the variable inc holds the imaginary/absorption part, not the incoherent length.
  8. limits.py:33-41: percentage-based default limits produce inverted bounds (min > max) for negative values — latent, but unguarded.
  9. Project.as_dict side effect: the fitter property lazily constructs a MultiFitter and switches minimizer (project.py:283-290, hit from :871); serialization should be pure. Similarly get_index_air/si/sio2/d2o (:349-371) append materials from a getter.
  10. Stray pass at project.py:389; dead _flatten_list in fitting.py:499-512.

Found during deep code review (DEEP_ANALYSIS.md §3.1, §5, §7).

Metadata

Metadata

Assignees

No one assigned

    Labels

    [priority] lowLow importance[scope] maintenanceCode/tooling cleanup, no feature or bugfix (major.minor.PATCH)
    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions