xnn.common.config.schema.normalize_subtracted_dispersion#

xnn.common.config.schema.normalize_subtracted_dispersion(spec, model)[source]#

Validate and normalize Config.subtracted_dispersion.

A bare name ("d4") or True becomes {"name": "d4"}; None and False mean no record. The keys must be the constructor options of the named term (DFTD4 / DFTD3) plus the annotations dataset and note, so a misspelled option is caught here rather than dropped silently at run time. A record contradicts a model that includes the term itself (model.extra["dispersion"]): the labels cannot both have had it subtracted and be fitted with it.

Parameters:
  • spec (dict, str, bool or None) – The record as given in the config.

  • model (ModelConfig) – The model section, checked for a built-in dispersion term.

Returns:

The normalized record, with name set.

Return type:

dict or None

Raises:

ValueError – For an unknown term name, an unknown option key, or a model that already includes dispersion.