Skip to content

Serialization of dataclasses #628

Description

@kevinsung

We should support saving and loading most classes. Here is an example of what I've used for the UCJ operators:

    np.savez_compressed(
        operator_path,
        diag_coulomb_mats=lucj_op.diag_coulomb_mats,
        orbital_rotations=lucj_op.orbital_rotations,
        final_orbital_rotation=lucj_op.final_orbital_rotation,
    )

    operator_data = np.load(data_dir / lucj_operator_task.dirpath / "operator.npz")
    lucj_op = ffsim.UCJOpSpinBalanced(
        diag_coulomb_mats=operator_data["diag_coulomb_mats"],
        orbital_rotations=operator_data["orbital_rotations"],
        final_orbital_rotation=operator_data["final_orbital_rotation"],
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions