wavepacket.testing ================== .. py:module:: wavepacket.testing .. autoapi-nested-parse:: Utility classes and functions for writing Wavepacket tests. .. !! processed by numpydoc !! Classes ------- .. autoapisummary:: wavepacket.testing.DummyDof wavepacket.testing.DummyOperator Functions --------- .. autoapisummary:: wavepacket.testing.assert_close wavepacket.testing.random_state Package Contents ---------------- .. py:function:: assert_close(actual: wavepacket.grid.State, expected: wavepacket.grid.State, diff: float = 0) -> None Assertion helper: Verify that two states are on the same grid and similar to each other. :Parameters: **actual** : wp.grid.State The expected state **expected** : wp.grid.State The state to be tested. **diff** : float The maximum absolute difference between any coefficients of the two states. .. !! processed by numpydoc !! .. py:class:: DummyDof(dvr_array: wavepacket.typing.RealData, fbr_array: wavepacket.typing.RealData) Bases: :py:obj:`wavepacket.grid.DofBase` Empty DOF without transformations. .. !! processed by numpydoc !! .. py:method:: from_fbr(data: wavepacket.typing.ComplexData, index: int, is_ket: bool = True) -> wavepacket.typing.ComplexData Translates a dimension of the input coefficients from the FBR into the Wavepacket-default "weighted DVR" This function is not meant for public use. It does not handle errors explicitly, and is just awkward to use; you need to reach through the state abstraction and transform each index correctly. :Parameters: **data** : wp.typing.ComplexData The input coefficients of the state to transform. **index** : int The index of the coefficient array that should be transformed. **is_ket** : bool, default=True If the index is the coefficient for a ket state (True) or a bra state. :Returns: wpt.ComplexData The appropriately transformed coefficients. You generally need to wrap the result in a :py:class:`wavepacket.grid.State` before further use. .. !! processed by numpydoc !! .. py:method:: to_dvr(data: wavepacket.typing.ComplexData, index: int) -> wavepacket.typing.ComplexData Translates a dimension of the input coefficients from the Wavepacket-default "weighted DVR" into the DVR. This function is not meant for public use. It does not handle errors explicitly, and is just awkward to use; you need to reach through the state abstraction and transform each index correctly. :Parameters: **data** : wp.typing.ComplexData The input coefficients of the state to transform. **index** : int The index of the coefficient array that should be transformed. :Returns: wpt.ComplexData The appropriately transformed coefficients. You will generally not wrap the results into a :py:class:`wavepacket.grid.State`, because that class implicitly assumes a weighted DVR transformation. .. !! processed by numpydoc !! .. py:method:: from_dvr(data: wavepacket.typing.ComplexData, index: int) -> wavepacket.typing.ComplexData Translates a dimension of the input coefficients from the DVR into the Wavepacket-default "weighted DVR". This function is not meant for public use. It does not handle errors explicitly, and is just awkward to use; you need to reach through the state abstraction and transform each index correctly. :Parameters: **data** : wp.typing.ComplexData The input coefficients of the state to transform. **index** : int The index of the coefficient array that should be transformed. :Returns: wpt.ComplexData The appropriately transformed coefficients. They need to be wrapped in a :py:class:`wavepacket.grid.State` before further use. .. !! processed by numpydoc !! .. py:method:: to_fbr(data: wavepacket.typing.ComplexData, index: int, is_ket: bool = True) -> wavepacket.typing.ComplexData Translates a dimension of the input coefficients from the Wavepacket-default "weighted DVR" into the FBR. This function is not meant for public use. It does not handle errors explicitly, and is just awkward to use; you need to reach through the state abstraction and transform each index correctly. :Parameters: **data** : wp.typing.ComplexData The input coefficients of the state to transform. **index** : int The index of the coefficient array that should be transformed. **is_ket** : bool, default=True If the index is the coefficient for a ket state (True) or a bra state. :Returns: wpt.ComplexData The appropriately transformed coefficients. You will generally not wrap the results into a :py:class:`wavepacket.grid.State`, because that class implicitly assumes a weighted DVR transformation. .. !! processed by numpydoc !! .. py:class:: DummyOperator(grid: wavepacket.grid.Grid) Bases: :py:obj:`wavepacket.operator.OperatorBase` Empty operator that throws when it is applied. Used for testing where we need an operator, but do not get as far as actually doing something. .. !! processed by numpydoc !! .. py:method:: apply_to_wave_function(psi: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData Applies the operator on a wave function. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **psi** : wpt.ComplexData The coefficients describing the wave function on which the operator acts. **t** : float The time at which the operator should be evaluated. Only really needed for time-dependent operators, but to keep the interface uniform, this parameter is required. :Returns: wpt.ComplexData The coefficients of the resulting wave function. .. !! processed by numpydoc !! .. py:method:: apply_from_left(rho: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData Applies the operator on a density operator from the left. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **rho** : wpt.ComplexData The coefficients describing the density operator on which the operator acts. **t** : float The time at which the operator should be evaluated. Only really needed for time-dependent operators, but to keep the interface uniform, this parameter is required. :Returns: wpt.ComplexData The coefficients of the resulting density operator. .. !! processed by numpydoc !! .. py:method:: apply_from_right(rho: wavepacket.typing.ComplexData, t: float) -> wavepacket.typing.ComplexData Applies the operator on a density operator from the right. This function is mainly for Wavepacket-internal use. It ignores most error handling (usually done by the wrapping :py:class:`wavepacket.expression.ExpressionBase`), and operates directly on coefficients to avoid the creation of temporary states. :Parameters: **rho** : wpt.ComplexData The coefficients describing the density operator on which the operator acts. **t** : float The time at which the operator should be evaluated. Only really needed for time-dependent operators, but to keep the interface uniform, this parameter is required. :Returns: wpt.ComplexData The coefficients of the resulting density operator. .. !! processed by numpydoc !! .. py:function:: random_state(grid: wavepacket.grid.Grid, seed: int) -> wavepacket.grid.State Creates a random wave function. Note that this function does not employ high-quality randomization, it is only meant to create states without accidental symmetries or lots of code. .. !! processed by numpydoc !!