Skip to content

Commit

Permalink
fix snapshot_type not being parsed (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseclectic authored Apr 22, 2019
1 parent 34f363d commit e497c6d
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/framework/operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,14 +749,14 @@ Op json_to_op_noise_switch(const json_t &js) {
//------------------------------------------------------------------------------

Op json_to_op_snapshot(const json_t &js) {
std::string type;
JSON::get_value(type, "type", js); // LEGACY: TO REMOVE
JSON::get_value(type, "snapshot_type", js);
if (type == "expectation_value_pauli" ||
type == "expectation_value_pauli_with_variance")
std::string snapshot_type;
JSON::get_value(snapshot_type, "snapshot_type", js); // LEGACY: to remove in 0.3
JSON::get_value(snapshot_type, "type", js);
if (snapshot_type == "expectation_value_pauli" ||
snapshot_type == "expectation_value_pauli_with_variance")
return json_to_op_snapshot_pauli(js);
if (type == "expectation_value_matrix" ||
type == "expectation_value_matrix_with_variance")
if (snapshot_type == "expectation_value_matrix" ||
snapshot_type == "expectation_value_matrix_with_variance")
return json_to_op_snapshot_matrix(js);
// Default snapshot: has "type", "label", "qubits"
return json_to_op_snapshot_default(js);
Expand All @@ -766,7 +766,8 @@ Op json_to_op_snapshot(const json_t &js) {
Op json_to_op_snapshot_default(const json_t &js) {
Op op;
op.type = OpType::snapshot;
JSON::get_value(op.name, "type", js);
JSON::get_value(op.name, "type", js); // LEGACY: to remove in 0.3
JSON::get_value(op.name, "snapshot_type", js);
// If missing use "default" for label
op.string_params.push_back("default");
JSON::get_value(op.string_params[0], "label", js);
Expand Down

0 comments on commit e497c6d

Please sign in to comment.