Skip to content

Commit

Permalink
Merge branch 'main' into rmdebug
Browse files Browse the repository at this point in the history
  • Loading branch information
cqc-alec authored May 13, 2024
2 parents 925518b + 9f2a073 commit 552d97b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pytket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def package(self):
cmake.install()

def requirements(self):
self.requires("tket/1.2.122@tket/stable")
self.requires("tket/1.2.123@tket/stable")
self.requires("tklog/0.3.3@tket/stable")
self.requires("tkrng/0.3.3@tket/stable")
self.requires("tkassert/0.3.4@tket/stable")
Expand Down
4 changes: 4 additions & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Features:
* Add two new status values for circuits on backends: "CANCELLING" and "RETRYING".
* Use `lark` package instead of deprecated `lark-parser`.

Fixes:

* Escape underscores in qubit and bit names when converting to latex.

1.27.0 (April 2024)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion tket/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class TketConan(ConanFile):
name = "tket"
version = "1.2.122"
version = "1.2.123"
package_type = "library"
license = "Apache 2"
homepage = "https://github.com/CQCL/tket"
Expand Down
7 changes: 5 additions & 2 deletions tket/src/Circuit/latex_drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <boost/algorithm/string/replace.hpp>
#include <limits>

#include "tket/Circuit/Boxes.hpp"
Expand Down Expand Up @@ -287,14 +288,16 @@ std::string Circuit::to_latex_str() const {
unsigned n_lines = lines.size();
line_ids.insert({qb, n_lines});
LineBufferInfo& line = *lines.emplace(lines.end());
line.buffer << "\\lstick{" + qb.repr() + "} & ";
line.buffer << "\\lstick{" +
boost::replace_all_copy(qb.repr(), "_", "\\_") + "} & ";
line.is_quantum = true;
}
for (const Bit& cb : this->all_bits()) {
unsigned n_lines = lines.size();
line_ids.insert({cb, n_lines});
LineBufferInfo& line = *lines.emplace(lines.end());
line.buffer << "\\lstick{" + cb.repr() + "} & ";
line.buffer << "\\lstick{" +
boost::replace_all_copy(cb.repr(), "_", "\\_") + "} & ";
line.is_quantum = false;
}

Expand Down
8 changes: 8 additions & 0 deletions tket/test/src/Circuit/test_Circ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "tket/Transformations/Replacement.hpp"
#include "tket/Transformations/Transform.hpp"
#include "tket/Utils/MatrixAnalysis.hpp"
#include "tket/Utils/UnitID.hpp"

namespace tket {
namespace test_Circ {
Expand Down Expand Up @@ -2694,6 +2695,13 @@ SCENARIO("Confirm that LaTeX output compiles", "[latex][.long]") {
c.add_conditional_gate<unsigned>(
OpType::CU3, {1.04, 0.36, -0.36}, {0, 4}, {}, 0);

// https://github.com/CQCL/tket/issues/1363
Qubit q1("q_1", 0);
Bit c1("c_1", 0);
c.add_qubit(q1);
c.add_bit(c1);
c.add_measure(q1, c1);

c.to_latex_file("circ.tex");
int response = std::system("latexmk -pdf circ.tex -quiet");
REQUIRE(response == 0);
Expand Down

0 comments on commit 552d97b

Please sign in to comment.