molsysmt.form.load_converter#
- molsysmt.form.load_converter(module, converter)[source]#
Resolve a converter that a form declares lazily, by submodule name.
A form’s _convert_to maps a target form to either the converter itself or, for the ones that would drag a third-party library in at import time, the name of the submodule holding it. This resolves the second case and leaves the first alone, so callers do not each need to know the difference.
- Parameters:
module (object) – Argument module.
converter (object) – Argument converter.
- Returns:
The converter.
- Return type:
callable
Notes
Importing <form>.to_x makes the submodule an attribute of the form package, shadowing the function of the same name. Around 1400 call sites do from molsysmt.form.<form> import to_x expecting the function, so this rebinds the attribute after loading. Without that, whether the name means the function or the module depends on whether some earlier conversion happened to import it – which is the kind of bug that appears far from its cause.