diff --git a/src/stim/diagram/detector_slice/detector_slice_set.cc b/src/stim/diagram/detector_slice/detector_slice_set.cc index c85f2124..643c8087 100644 --- a/src/stim/diagram/detector_slice/detector_slice_set.cc +++ b/src/stim/diagram/detector_slice/detector_slice_set.cc @@ -409,6 +409,7 @@ FlattenedCoords FlattenedCoords::from(const DetectorSliceSet &set, float desired } float characteristic_distance = pick_characteristic_distance(used, result.qubit_coords); + result.unit_distance = desired_unit_distance; float scale = desired_unit_distance / characteristic_distance; for (auto &c : result.qubit_coords) { c *= scale; diff --git a/src/stim/diagram/detector_slice/detector_slice_set.h b/src/stim/diagram/detector_slice/detector_slice_set.h index 0a93ac7a..76314eba 100644 --- a/src/stim/diagram/detector_slice/detector_slice_set.h +++ b/src/stim/diagram/detector_slice/detector_slice_set.h @@ -81,6 +81,7 @@ struct FlattenedCoords { std::vector> qubit_coords; std::map> det_coords; Coord<2> size; + float unit_distance; static FlattenedCoords from(const DetectorSliceSet &set, float desired_unit_distance); }; diff --git a/src/stim/diagram/timeline/timeline_svg_drawer.cc b/src/stim/diagram/timeline/timeline_svg_drawer.cc index 6b3ff19b..59a3ab02 100644 --- a/src/stim/diagram/timeline/timeline_svg_drawer.cc +++ b/src/stim/diagram/timeline/timeline_svg_drawer.cc @@ -483,9 +483,27 @@ void DiagramTimelineSvgDrawer::reserve_drawing_room_for_targets(SpanRef{-dp.xyz[1], dp.xyz[0]}; + if (2 * dp2.xyz[0] + 3 * dp2.xyz[1] < 0) { + dp2 *= -1; + } + auto p3 = p1 + dp * 0.2 + dp2 * 0.2; + auto p4 = p2 + dp * -0.2 + dp2 * 0.2; + svg_out << "C"; + svg_out << p3.xyz[0] << " " << p3.xyz[1] << ","; + svg_out << p4.xyz[0] << " " << p4.xyz[1] << ","; + svg_out << p2.xyz[0] << " " << p2.xyz[1] << " "; + } } svg_out << "\""; + write_key_val(svg_out, "fill", "none"); write_key_val(svg_out, "stroke", "black"); write_key_val(svg_out, "stroke-width", "5"); svg_out << "/>\n"; diff --git a/src/stim/diagram/timeline/timeline_svg_drawer.test.cc b/src/stim/diagram/timeline/timeline_svg_drawer.test.cc index 86750d23..0b48c352 100644 --- a/src/stim/diagram/timeline/timeline_svg_drawer.test.cc +++ b/src/stim/diagram/timeline/timeline_svg_drawer.test.cc @@ -381,3 +381,22 @@ TEST(diagram_timeline_svg_drawer, anticommuting_detector_circuit) { circuit, ss, 0, UINT64_MAX, DiagramTimelineSvgDrawerMode::SVG_MODE_TIME_DETECTOR_SLICE, {&empty_filter}); expect_string_is_identical_to_saved_file(ss.str(), "anticommuting_detslice.svg"); } + +TEST(diagram_timeline_svg_drawer, bezier_curves) { + CoordFilter empty_filter; + std::stringstream ss; + auto circuit = Circuit(R"CIRCUIT( + QUBIT_COORDS(0, 0) 0 + QUBIT_COORDS(1, 0) 1 + QUBIT_COORDS(2, 0) 2 + QUBIT_COORDS(3, 0) 3 + CX 0 1 + CX 2 3 + TICK + CX 0 2 + CX 1 3 + )CIRCUIT"); + DiagramTimelineSvgDrawer::make_diagram_write_to( + circuit, ss, 0, UINT64_MAX, DiagramTimelineSvgDrawerMode::SVG_MODE_TIME_SLICE, {&empty_filter}); + expect_string_is_identical_to_saved_file(ss.str(), "bezier_time_slice.svg"); +} diff --git a/src/stim/stabilizers/tableau_iter.test.cc b/src/stim/stabilizers/tableau_iter.test.cc index 16063bd7..4d93c9d3 100644 --- a/src/stim/stabilizers/tableau_iter.test.cc +++ b/src/stim/stabilizers/tableau_iter.test.cc @@ -116,29 +116,30 @@ TEST_EACH_WORD_SIZE_W(tableau_iter, iter_tableau, { TableauIterator iter1_signs(1, true); TableauIterator iter2(2, false); TableauIterator iter3(3, false); - int s1 = 0; int n1 = 0; - int n2 = 0; - int n3 = 0; while (iter1.iter_next()) { n1++; } ASSERT_EQ(n1, 6); + int s1 = 0; while (iter1_signs.iter_next()) { s1++; } ASSERT_EQ(s1, 24); + int n2 = 0; while (iter2.iter_next()) { n2++; } ASSERT_EQ(n2, 720); + // Note: disabled because it takes 2-3 seconds. + // int n3 = 0; // while (iter3.iter_next()) { // n3++; // } - // ASSERT_EQ(n3, 1451520); // Note: disabled because it takes 2-3 seconds. + // ASSERT_EQ(n3, 1451520); }) TEST_EACH_WORD_SIZE_W(tableau_iter, iter_tableau_distinct, { diff --git a/testdata/anticommuting_detslice.svg b/testdata/anticommuting_detslice.svg index 22ae3db5..76e9814f 100644 --- a/testdata/anticommuting_detslice.svg +++ b/testdata/anticommuting_detslice.svg @@ -34,7 +34,7 @@ R R - + MXX diff --git a/testdata/bezier_time_slice.svg b/testdata/bezier_time_slice.svg new file mode 100644 index 00000000..1f132c86 --- /dev/null +++ b/testdata/bezier_time_slice.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testdata/circuit_all_ops_detslice.svg b/testdata/circuit_all_ops_detslice.svg index ec3b633a..a917974c 100644 --- a/testdata/circuit_all_ops_detslice.svg +++ b/testdata/circuit_all_ops_detslice.svg @@ -283,100 +283,100 @@ S S - + - + - + - + - + - + - + √XX √XX - + √XX √XX - + √YY √YY - + √YY √YY - + √ZZ √ZZ - + √ZZ √ZZ - + - + - + - + - + - + - + - + - + - + EX @@ -384,7 +384,7 @@ EZ 0.01 - + EEX @@ -395,7 +395,7 @@ DEP1 0.02 - + DEP2 @@ -404,7 +404,7 @@ PAULI_CHANNEL_1 0.01,0.02,0.03 - + PAULI_CHANNEL_20 @@ -425,19 +425,19 @@ HERALDED_PAULI_CHANNEL_1 0.01,0.02,0.03,0.04 - + MPPX MPPY MPPZ - + MPPZ MPPZ - + SPPX @@ -446,7 +446,7 @@ SPPZ SPPX - + SPP†X @@ -475,29 +475,29 @@ RY R - + MXX MXX - + MXX MXX - + MYY MYY - + MZZ MZZ H - + @@ -505,7 +505,7 @@ S H - + @@ -513,7 +513,7 @@ S H - + @@ -537,17 +537,17 @@ MRX MY - + MZZ MZZ - + MYY MYY - + MPPX diff --git a/testdata/circuit_all_ops_timeslice.svg b/testdata/circuit_all_ops_timeslice.svg index ec3b633a..a917974c 100644 --- a/testdata/circuit_all_ops_timeslice.svg +++ b/testdata/circuit_all_ops_timeslice.svg @@ -283,100 +283,100 @@ S S - + - + - + - + - + - + - + √XX √XX - + √XX √XX - + √YY √YY - + √YY √YY - + √ZZ √ZZ - + √ZZ √ZZ - + - + - + - + - + - + - + - + - + - + EX @@ -384,7 +384,7 @@ EZ 0.01 - + EEX @@ -395,7 +395,7 @@ DEP1 0.02 - + DEP2 @@ -404,7 +404,7 @@ PAULI_CHANNEL_1 0.01,0.02,0.03 - + PAULI_CHANNEL_20 @@ -425,19 +425,19 @@ HERALDED_PAULI_CHANNEL_1 0.01,0.02,0.03,0.04 - + MPPX MPPY MPPZ - + MPPZ MPPZ - + SPPX @@ -446,7 +446,7 @@ SPPZ SPPX - + SPP†X @@ -475,29 +475,29 @@ RY R - + MXX MXX - + MXX MXX - + MYY MYY - + MZZ MZZ H - + @@ -505,7 +505,7 @@ S H - + @@ -513,7 +513,7 @@ S H - + @@ -537,17 +537,17 @@ MRX MY - + MZZ MZZ - + MYY MYY - + MPPX diff --git a/testdata/detslice-with-ops_surface_code.svg b/testdata/detslice-with-ops_surface_code.svg index 00cf1382..e79153bd 100644 --- a/testdata/detslice-with-ops_surface_code.svg +++ b/testdata/detslice-with-ops_surface_code.svg @@ -1038,99 +1038,99 @@ H H - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1166,99 +1166,99 @@ H H - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/testdata/observable_slices.svg b/testdata/observable_slices.svg index 216cd488..6bff67cb 100644 --- a/testdata/observable_slices.svg +++ b/testdata/observable_slices.svg @@ -96,11 +96,11 @@ CXYZ CXYZ - + - + @@ -112,11 +112,11 @@ CXYZ CXYZ - + - + @@ -128,11 +128,11 @@ CXYZ CXYZ - + - + diff --git a/testdata/surface_code_full_time_detector_slice.svg b/testdata/surface_code_full_time_detector_slice.svg index 38bf0c6c..ace2226d 100644 --- a/testdata/surface_code_full_time_detector_slice.svg +++ b/testdata/surface_code_full_time_detector_slice.svg @@ -1768,163 +1768,163 @@ H H - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1976,163 +1976,163 @@ H H - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2184,163 +2184,163 @@ H H - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2392,163 +2392,163 @@ H H - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2600,163 +2600,163 @@ H H - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/testdata/surface_code_time_detector_slice.svg b/testdata/surface_code_time_detector_slice.svg index 5fb628df..01fbf938 100644 --- a/testdata/surface_code_time_detector_slice.svg +++ b/testdata/surface_code_time_detector_slice.svg @@ -452,43 +452,43 @@ - + - + - + - + - + - + - + - + - + - + @@ -540,163 +540,163 @@ H H - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/testdata/surface_code_time_slice.svg b/testdata/surface_code_time_slice.svg index 7f7c6e39..38ede396 100644 --- a/testdata/surface_code_time_slice.svg +++ b/testdata/surface_code_time_slice.svg @@ -188,27 +188,27 @@ - + - + - + - + - + - + @@ -244,99 +244,99 @@ H H - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +