Imagine that you would like to create a Label and format it as a string. One possible way that you might think to go about this is to write something like Label("Gx:0!1.2;foo") to mean a "Gx" gate on qubit 0 with a time value of 1.2 and the argument foo. The normal way to do this would be Label('Gx', (0,), 1.2, ("foo",)) which would create a LabelTupWithArgs and not a LabelStr. We actually cannot create a LabelStr with args. This may be fine.
To get the parser to execute we need to specify Label(("Gx:0", "!1.2", ";foo")) which is quite clunky.
I would like to be able to create a LabelStr with a nonzero time value, Y, by Label('Gx!Y'). That will make a LabelStr at the moment but the time value will be 0.
This can break the hashing mechanism used by to_nice_serialization()
from pygsti.baseobjs.label import Label as L
tmp = L("Gx", time=1.2)
native = tmp.to_native()
print(native) # Gx!1.2
back = L(native)
back.time != tmp.time # 0.0 != 1.2
back.name != tmp.name # Gx!1.2 != Gx. So a different cache value if we go through to_nice_serialization which calls to_native() on the Labels.
Imagine that you would like to create a Label and format it as a string. One possible way that you might think to go about this is to write something like
Label("Gx:0!1.2;foo")to mean a "Gx" gate on qubit 0 with a time value of 1.2 and the argument foo. The normal way to do this would beLabel('Gx', (0,), 1.2, ("foo",))which would create a LabelTupWithArgs and not a LabelStr. We actually cannot create a LabelStr with args. This may be fine.To get the parser to execute we need to specify
Label(("Gx:0", "!1.2", ";foo"))which is quite clunky.I would like to be able to create a
LabelStrwith a nonzero time value,Y, byLabel('Gx!Y'). That will make a LabelStr at the moment but the time value will be 0.This can break the hashing mechanism used by
to_nice_serialization()