iodata.prepare module

Preparation of IOData instances before they are dumped.

The prepare_* functions below can be used as building blocks in prepare_dump functions. When the allow_changes argument is set to True, they can return a new IOData instance with some modified attributes. Otherwise, they can raise an error if a conversion is needed. When no conversion is needed, no errors or warnings are raised, and the same IOData object is returned.

prepare_segmented(data, keep_sp, allow_changes, filename, fmt)[source]

If needed, convert generalized contractions to segmented ones.

Parameters:
  • data (IOData) – The IOData instance with the orbital basis set.

  • keep_sp (bool) – Set to True if SP-shells should not be segmented.

  • allow_changes (bool) – Whether conversion of the IOData object to a compatible form is allowed or not.

  • filename (str) – The file to be written to, only used for error messages.

  • fmt (str) – The file format whose dump function is calling this function, only used for error messages.

Returns:

data – The given data object if no conversion took place, or a shallow copy with some new attributes.

Raises:
  • ValueError – If the given data object has no orbital basis set.

  • PrepareDumpError – If allow_changes == False and a conversion is required.

  • PrepareDumpWarning – If allow_changes == True and a conversion is required.

prepare_unrestricted_aminusb(data, allow_changes, filename, fmt)[source]

If molecular orbitals have aminusb set, they are converted to unrestricted.

Parameters:
  • data (IOData) – The IOData instance with the molecular orbitals.

  • allow_changes (bool) – Whether conversion of the IOData object to a compatible form is allowed or not.

  • filename (str) – The file to be written to, only used for error messages.

  • fmt (str) – The file format whose dump function is calling this function, only used for error messages.

Returns:

data – The given data object if no conversion took place, or a shallow copy with some new attributes.

Raises:
  • ValueError – If the given data object has no molecular orbitals, or if the orbitals are generalized.

  • PrepareDumpError – If allow_changes == False and a conversion is required.

  • PrepareDumpWarning – If allow_changes == True and a conversion is required.