Skip to content

Commit

Permalink
Fixed printing
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Sep 22, 2023
1 parent 7dd4384 commit 36fff32
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 34 deletions.
28 changes: 2 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ obj = m.new_defm(id, y, x, column_major = False)
obj
```

<pydefm._core.DEFM at 0x7f3678119eb0>
<pydefm._core.DEFM at 0x7fd9a41dcaf0>

Adding terms via formula

Expand All @@ -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
Expand All @@ -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 <a
href="https://pybind11.readthedocs.io/en/stable/advanced/pycpp/utilities.html?highlight=print#using-python-s-print-function-in-c"
target="_blank">this</a>).

``` python
# Checking if the data is recovered
m.print_y(obj)
```

0 0
8 changes: 1 addition & 7 deletions README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
4 changes: 3 additions & 1 deletion src/defm-common.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef DEFM_COMMON_H
#define DEFM_COMMON_H

using namespace pybind11::literals;

inline void pyprinter(const char * fmt, ...)
{

Expand All @@ -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") = "");

}

Expand Down

0 comments on commit 36fff32

Please sign in to comment.