mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
docs(user): create printing and drawing howto
This commit is contained in:
@@ -24,6 +24,7 @@ Concrete Framework's documentation
|
||||
:caption: How to
|
||||
|
||||
user/howto/COMPILING_AND_EXECUTING.md
|
||||
user/howto/PRINTING_AND_DRAWING.md
|
||||
user/howto/REDUCE_NEEDED_PRECISION.md
|
||||
user/howto/DEBUG_SUPPORT_SUBMIT_ISSUES.md
|
||||
user/howto/FAQ.md
|
||||
|
||||
49
docs/user/howto/PRINTING_AND_DRAWING.md
Normal file
49
docs/user/howto/PRINTING_AND_DRAWING.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Printing and Drawing
|
||||
|
||||
Sometimes, it can be useful to print or draw fhe circuits, we provide methods to just do that. Please read [Compiling and Executing](../howto/COMPILING_AND_EXECUTING.md) before reading further to see how you can compile your function into an fhe circuit.
|
||||
|
||||
## Printing
|
||||
|
||||
To print your circuit, you can do the following:
|
||||
|
||||
<!--python-test:skip-->
|
||||
```python
|
||||
print(circuit)
|
||||
```
|
||||
|
||||
## Drawing
|
||||
|
||||
To draw your circuit, you can do the following:
|
||||
|
||||
<!--python-test:skip-->
|
||||
```python
|
||||
drawing = circuit.draw()
|
||||
```
|
||||
|
||||
This method will draw the circuit on a temporary PNG file and return the path to this file.
|
||||
|
||||
To show the drawing, you can use the following code in a jupyter notebook.
|
||||
|
||||
<!--python-test:skip-->
|
||||
```python
|
||||
from PIL import Image
|
||||
drawing = Image.open(circuit.draw())
|
||||
drawing.show()
|
||||
drawing.close()
|
||||
```
|
||||
|
||||
Additionally, you can use the `show` option of the `draw` method to show the drawing with matplotlib. Beware that this will clear the matplotlib plots you have.
|
||||
|
||||
<!--python-test:skip-->
|
||||
```python
|
||||
circuit.draw(show=True)
|
||||
```
|
||||
|
||||
Lastly, you can save the drawing to a specific path like this:
|
||||
|
||||
<!--python-test:skip-->
|
||||
```python
|
||||
destination = "/tmp/path/of/your/choice.png"
|
||||
drawing = circuit.draw(save_to=destination)
|
||||
assert drawing == destination
|
||||
```
|
||||
Reference in New Issue
Block a user