diff --git a/mrmustard/lab_dev/circuit_components.py b/mrmustard/lab_dev/circuit_components.py index fba4fb48c..d0e1297df 100644 --- a/mrmustard/lab_dev/circuit_components.py +++ b/mrmustard/lab_dev/circuit_components.py @@ -82,10 +82,10 @@ def _serialize(self) -> tuple[dict[str, Any], dict[str, ArrayLike]]: serializable = {"class": f"{cls.__module__}.{cls.__qualname__}"} params = signature(cls).parameters if "name" in params: # assume abstract type, serialize the representation - rep_cls = type(self.ansatz) + ansatz_cls = type(self.ansatz) serializable["name"] = self.name serializable["wires"] = self.wires.sorted_args - serializable["rep_class"] = f"{rep_cls.__module__}.{rep_cls.__qualname__}" + serializable["ansatz_cls"] = f"{ansatz_cls.__module__}.{ansatz_cls.__qualname__}" return serializable, self.ansatz.to_dict() # handle modes parameter @@ -110,10 +110,10 @@ def _deserialize(cls, data: dict) -> CircuitComponent: r""" Deserialization when within a circuit. """ - if "rep_class" in data: - rep_class, wires, name = map(data.pop, ["rep_class", "wires", "name"]) - rep = locate(rep_class).from_dict(data) - return cls._from_attributes(Representation(rep, Wires(*map(set, wires))), name=name) + if "ansatz_cls" in data: + ansatz_cls, wires, name = map(data.pop, ["ansatz_cls", "wires", "name"]) + ansatz = locate(ansatz_cls).from_dict(data) + return cls._from_attributes(Representation(ansatz, Wires(*map(set, wires))), name=name) return cls(**data) diff --git a/tests/test_lab_dev/test_circuit_components.py b/tests/test_lab_dev/test_circuit_components.py index 24620c7ad..3abefac46 100644 --- a/tests/test_lab_dev/test_circuit_components.py +++ b/tests/test_lab_dev/test_circuit_components.py @@ -566,7 +566,7 @@ def test_serialize_default_behaviour(self): assert kwargs == { "class": f"{CircuitComponent.__module__}.CircuitComponent", "wires": cc.wires.sorted_args, - "rep_class": f"{PolyExpAnsatz.__module__}.PolyExpAnsatz", + "ansatz_cls": f"{PolyExpAnsatz.__module__}.PolyExpAnsatz", "name": name, } assert arrays == {"A": ansatz.A, "b": ansatz.b, "c": ansatz.c}