Skip to content

Refactor Species #457

@K20shores

Description

@K20shores

Refactor Species in musica.mechanism_configuration to use composition instead of inheritance from _Species.

Acceptance Criteria

  • Species no longer inherits from _Species.
  • Internal C++ instance stored in self._instance.
  • All properties (name, HLC_298K_mol_m3_Pa, HLC_exponential_factor_K, diffusion_coefficient_m2_s, N_star, molecular_weight_kg_mol, density_kg_m3, tracer_type, other_properties) delegate to or update self._instance.
  • serialize() refactored as an instance method using only Python-visible data.
  • Public interface exposes only Python-native types.
  • Remove static method pattern from serialize().

Ideas

  • Use wrapper pattern from tuvx.py for encapsulating the C++ instance.
  • Implement property getters/setters for all attributes forwarding to self._instance.
  • Handle other_properties properly during serialization.
  • Refactor serialize() to instance method that accesses Python attributes only.

Tasks

  • Replace class Species(_Species) with class Species.
  • Instantiate _Species in __init__ and assign to self._instance.
  • Forward attribute access and mutation to self._instance via properties.
  • Convert serialize() to instance method, relying solely on Python attributes.
  • Ensure other_properties serialized correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions