Skip to content

Pretty MSDs #1669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions qualtran/bloqs/basic_gates/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def adjoint(self) -> 'ZPowGate':

def wire_symbol(self, reg: Optional[Register], idx: Tuple[int, ...] = tuple()) -> 'WireSymbol':
if reg is None:
return Text('')
return TextBox(f'Z^{self.exponent}')
return Text(f'Z^{self.exponent}')
return TextBox("Z")

def __str__(self):
return f'Z**{self.exponent}'
Expand Down
2 changes: 1 addition & 1 deletion qualtran/symbolics/math_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def sabs(x: sympy.Expr) -> sympy.Expr: ...


def sabs(x: SymbolicFloat) -> SymbolicFloat:
return cast(SymbolicFloat, abs(x))
return cast(SymbolicFloat, abs(sympy.pi if isinstance(x, sympy.Symbol) else x))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x is marked as SymbolicFloat. It can be either a float or an arbitrary symbolic expression. We cannot assume that any symbol is always pi.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is a float, it returns the absolute.

If it is a symbol, the symbol represents a rotation angle, no?

If so, it doesn't matter what we assume, unless it's an incredibly small angle (which the visualisation would not be able to cope with)...

Based on my current insight into the codebase, for smin(self.cost_dtype.num_frac, ignoring_small_angle_rots) to be influenced by the choice of angle in sabs(), one would need a very, very, very small angle; something like pi/10000. Additionally, it does not seem possible to leave this particular operation unresolved, as the mathematical expression would not simplify at all, yielding the super long ugly labels that are currently being printed in MSDs.



@overload
Expand Down