iodata.utils module¶
Utility functions module.
- exception BaseFileError(message, file=None, lineno=None)[source]¶
Bases:
Exception
Base class for all errors related to loading or dumping files.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception BaseFileWarning(message, file=None, lineno=None)[source]¶
Bases:
Warning
Base class for all warnings related to loading or dumping files.
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class Cube(origin, axes, data)[source]¶
Bases:
object
The volumetric data from a cube (or similar) file.
- __init__(origin, axes, data)¶
Method generated by attrs for class Cube.
-
axes:
ndarray
[Any
,dtype
[float
]]¶ A (3, 3) array where each row represents the spacing between two neighboring grid points along the first, second and third axis, respectively.
- property shape¶
Shape of the rectangular grid.
- exception DumpError(message, file=None, lineno=None)[source]¶
Bases:
BaseFileError
Raised when an error is encountered while dumping to a file.
- __init__(message, file=None, lineno=None)¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception DumpWarning(message, file=None, lineno=None)[source]¶
Bases:
BaseFileWarning
Raised when an IOData object is made compatible with a format when dumping to a file.
- __init__(message, file=None, lineno=None)¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception FileFormatError(message, file=None, lineno=None)[source]¶
Bases:
BaseFileError
Raise when a file or input format cannot be identified.
- __init__(message, file=None, lineno=None)¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class LineIterator(filename)[source]¶
Bases:
object
Iterator class for looping over lines and keeping track of the line number.
Use this class as a context manager, similar to the built-in
open
function:with LineIterator("filename.ext") as lit: for line in lit: ...
- exception LoadError(message, file=None, lineno=None)[source]¶
Bases:
BaseFileError
Raised when an error is encountered while loading from a file.
- __init__(message, file=None, lineno=None)¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception LoadWarning(message, file=None, lineno=None)[source]¶
Bases:
BaseFileWarning
Raised when incorrect content is encountered and fixed when loading from a file.
- __init__(message, file=None, lineno=None)¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception PrepareDumpError(message, file=None, lineno=None)[source]¶
Bases:
BaseFileError
Raised when an IOData object is incompatible with a format before dumping to a file.
- __init__(message, file=None, lineno=None)¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception PrepareDumpWarning(message, file=None, lineno=None)[source]¶
Bases:
BaseFileWarning
Raised when an IOData object is made compatible with a format before dumping to a file.
- __init__(message, file=None, lineno=None)¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception WriteInputError(message, file=None, lineno=None)[source]¶
Bases:
BaseFileError
Raised when an error is encountered while writing an input file.
- __init__(message, file=None, lineno=None)¶
- add_note()¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback()¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- check_dm(dm, overlap, eps=0.0001, occ_max=1.0)[source]¶
Check if the density matrix has eigenvalues in the proper range.
- Parameters:
- Raises:
ValueError – When the density matrix has wrong eigenvalues.
- derive_naturals(dm, overlap)[source]¶
Derive natural orbitals from a given density matrix.
- set_four_index_element(four_index_object, i0, i1, i2, i3, value)[source]¶
Assign values to a four index object, account for 8-fold index symmetry.
This function assumes physicists’ notation.
- Parameters:
four_index_object (
ndarray
[Any
,dtype
[float
]]) – The four-index object. It will be written to. shape=(nbasis, nbasis, nbasis, nbasis), dtype=floati0 (
int
) – The indices to assign to.i1 (
int
) – The indices to assign to.i2 (
int
) – The indices to assign to.i3 (
int
) – The indices to assign to.value (
float
) – The value of the matrix element to store.