symmray.utils_test ================== .. py:module:: symmray.utils_test .. autoapi-nested-parse:: Utility functions specifically for testing. Attributes ---------- .. autoapisummary:: symmray.utils_test.rand_herm symmray.utils_test.rand_posdef Functions --------- .. autoapisummary:: symmray.utils_test.hash_kwargs_to_int symmray.utils_test.rand_valid_tensordot symmray.utils_test.rand_matrix Module Contents --------------- .. py:function:: hash_kwargs_to_int(**kwargs) -> int Hash a set of keyword arguments to a deterministic integer, which can be used for seeding random number generators in tests, for example, allowing a varying but reproducible seed. .. py:function:: rand_valid_tensordot(symmetry, ndim_a=None, ndim_b=None, ncon=None, charge_a=None, charge_b=None, min_ndim=1, max_ndim=5, min_d=1, max_d=3, dimension_multiplier=1, subsizes=None, seed=None, **kwargs) Generate two random symmetric arrays and valid contraction ``axes``. For testing purposes. :param symmetry: Symmetry to use. :type symmetry: str or Symmetry :param ndim_a: Number of dimensions for the first array. If None, a random number is chosen between `min_ndim` and `max_ndim` (inclusive). :type ndim_a: int or None :param ndim_b: Number of dimensions for the second array. If None, a random number is chosen between `min_ndim` and `max_ndim` (inclusive). :type ndim_b: int or None :param ncon: Number of axes to contract. If None, a random number is chosen between 0 and min(ndim_a, ndim_b) (inclusive). :type ncon: int or None :param charge_a: Charge for the first array. If None, a random charge is chosen. :type charge_a: charge_like or None :param charge_b: Charge for the second array. If None, a random charge is chosen. :type charge_b: charge_like or None :param min_ndim: Minimum number of dimensions for each array. :type min_ndim: int :param max_ndim: Maximum number of dimensions for each array. :type max_ndim: int :param min_d: Minimum dimension for each index. This is multiplied by `dimension_multiplier` if that is not None. :type min_d: int :param max_d: Maximum dimension for each index. This is multiplied by `dimension_multiplier` if that is not None. :type max_d: int :param dimension_multiplier: Each index will have dimension `d * dimension_multiplier` where `d` is a random integer in [min_d, max_d]. Useful for generating flat arrays with exactly equally distributed charge sizes. :type dimension_multiplier: int, optional :param subsizes: Passed to `rand_index`. If "equal", all sectors will have equal size, required for flat arrays. :type subsizes: str or None :param seed: Random seed or generator. If None, a new generator is created. :type seed: int or np.random.Generator or None :param \*\*kwargs: Additional arguments passed to `get_rand`. :returns: * **a** (*AbelianArray*) -- First random array. * **b** (*AbelianArray*) -- Second random array. * **axes** (*tuple[tuple[int, ...], tuple[int, ...]]*) -- Axes to contract. .. py:function:: rand_matrix(symmetry, d, seed=None, subsizes='equal', dtype='float64', fermionic=False, flat=False, matrix_type='general', d_per_charge=False) Create a general, hermitian, or positive definite matrix (with conjugate indices) with the given symmetry and shape (d, d). For testing purposes. :param symmetry: Symmetry to use. :type symmetry: str or Symmetry :param d: Dimension of each index. If `d_per_charge` is True, this is the dimension per charge sector, else it is the total dimension. :type d: int :param seed: Random seed or generator. If None, a new generator is created. :type seed: int or np.random.Generator or None :param subsizes: Passed to `rand_index`. If "equal", all sectors will have equal size, required for flat arrays. :type subsizes: str or None :param dtype: Data type of the array. :type dtype: str or dtype :param fermionic: Whether the array should be fermionic. :type fermionic: bool :param flat: Whether to return a flat array (with a single index) instead of a block array. If True, `subsizes` must be "equal". :type flat: bool :param matrix_type: Type of matrix to generate. "general" generates a general matrix, "hermitian" generates a hermitian matrix, and "posdef" generates a positive definite matrix. :type matrix_type: {"general", "hermitian", "posdef"} :param d_per_charge: Whether `d` specifies the dimension per charge sector (True) or the total dimension (False). If True, the total dimension is determined by the symmetry and `d`, only valid for ZN. :type d_per_charge: bool .. py:data:: rand_herm .. py:data:: rand_posdef