From 36fff32631175033c712f823d258ee11e51aed60 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Fri, 22 Sep 2023 13:13:09 -0600 Subject: [PATCH] Fixed printing --- README.md | 28 ++-------------------------- README.qmd | 8 +------- src/defm-common.hpp | 4 +++- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 9b2bf1f..83cf39f 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ obj = m.new_defm(id, y, x, column_major = False) obj ``` - + Adding terms via formula @@ -59,33 +59,21 @@ m.term_formula(obj, "{y0}") m.term_formula(obj, "{y1}") m.term_formula(obj, "{0y0, y1}") obj.init() -obj.print() # Right now, printing shows at the end of the screen +obj.print() ``` Num. of Arrays : 6 - Support size : 6 - Support size range : [4, 4] - Transform. Fun. : no - Model terms (3) : - - Motif {y0⁺} - - Motif {y1⁺} - - Motif {y0⁻, y1⁺} - Model rules (1) : - - Markov model of order 0 - Model Y variables (2): - 0) y0 - 1) y1 ``` python @@ -112,15 +100,3 @@ y [1, 0], [1, 0], [1, 1]]) - -Currently, the C++ code uses `printf` to print to the screen, which is a -different buffer from Python (the problem will be solved using this). - -``` python -# Checking if the data is recovered -m.print_y(obj) -``` - - 0 0 diff --git a/README.qmd b/README.qmd index 8e39eb9..539b06b 100644 --- a/README.qmd +++ b/README.qmd @@ -81,7 +81,7 @@ m.term_formula(obj, "{y0}") m.term_formula(obj, "{y1}") m.term_formula(obj, "{0y0, y1}") obj.init() -obj.print() # Right now, printing shows at the end of the screen +obj.print() ``` ```{python} @@ -95,11 +95,5 @@ Notice the first two columns coincide with the `y` array: y ``` -Currently, the C++ code uses `printf` to print to the screen, which is a different buffer from Python (the problem will be solved using [this](https://pybind11.readthedocs.io/en/stable/advanced/pycpp/utilities.html?highlight=print#using-python-s-print-function-in-c){target="_blank"}). - -```{python} -# Checking if the data is recovered -m.print_y(obj) -``` [`cibuildwheel`]: https://cibuildwheel.readthedocs.io diff --git a/src/defm-common.hpp b/src/defm-common.hpp index 016cfe7..f87720e 100644 --- a/src/defm-common.hpp +++ b/src/defm-common.hpp @@ -1,6 +1,8 @@ #ifndef DEFM_COMMON_H #define DEFM_COMMON_H +using namespace pybind11::literals; + inline void pyprinter(const char * fmt, ...) { @@ -13,7 +15,7 @@ inline void pyprinter(const char * fmt, ...) va_end(args); // Passing to pyprint - pybind11::print(std::string(buffer)); + pybind11::print(std::string(buffer), pybind11::arg("end") = ""); }