Serialization of dataclasses

Open
#628 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
python
Domain
backend

Research direction

Start with the issue's UCJ operator example, including np.savez_compressed, np.load, and UCJOpSpinBalanced, to understand the desired save/load behavior. Define which classes and data structures are in scope, then verify that representative classes can be saved and reconstructed without manually listing every field.

Written by the indexing model from the issue text.

Description

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"],
    )
Dominant language
Python
Stars
116
Forks
50
Avg merge
2h 1m
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Qiskit/ffsim

All issues in Qiskit/ffsim

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.