pyzx
pyzx copied to clipboard
`print_matrix` only prints the matix if it's the last output operation in a cell
The function print_matrix
returns a Label
widget (and says so in the documentation). However, it really only prints the matrix if it's the last function called in a cell which produces any output. In particular, the following behaviour is unintutive based on the function name.
This only prints the matrix of c2
:
print_matrix(c1)
print_matrix(c2)
This draws the circuit of c
but does not print its matrix (but reversing the order works):
print_matrix(c)
zx.draw(c)
Suggestion: either change the name of the function, or change it so it does actually print the matrix when it is run.
Hmm yes, maybe splitting it up into two functions, one that just returns the Label, and the other that also prints it and has this name would be the thing to do here.
Hmm yes, maybe splitting it up into two functions, one that just returns the Label, and the other that also prints it and has this name would be the thing to do here.
I've added a get_matrix_label
separate from print_label
in #213 as requested, but I'm not really sure that it is all that necessary. Is there really a use case for getting the Label
but not immediately also display
ing it? If not, we can just drop get_matrix_label
so as to not increase complexit in the API.
Yeah I guess we don't really need the `get_matrix_label' function. If you want to change back your PR so that it always just displays, then that is fine.
I've removed get_matrix_label
from #213.