§
    º³Ùg‰)  ã                  ó”   — d Z ddlmZ ddlZddlZddlmZ ddlmZ ddl	m
Z
 ddlmZ  G d„ d	e¦  «        Z G d
„ d¦  «        Zdd„ZdS )z'Matplotlib circuit visualization style.é    )ÚannotationsN)ÚAny)ÚPath)Úwarn)Úuser_configc                  óf   ‡ — e Zd ZdZh d£Zddddddd	d
ddddddddœZdˆ fd„Zdˆ fd„Zˆ fd„Zˆ xZ	S )Ú	StyleDictz¢A dictionary for matplotlib styles.

    Defines additional abbreviations for key accesses, such as allowing
    ``"ec"`` instead of writing ``"edgecolor"``.
    >   ÚdpiÚnameÚmarginÚfigwidthÚfontsizeÚ	edgecolorÚ	linecolorÚ	showindexÚ	textcolorÚdisplaytextÚsubfontsizeÚdisplaycolorÚsubtextcolorÚcreglinecolorÚcreglinestyleÚgatefacecolorÚgatetextcolorÚbackgroundcolorÚbarrierfacecolorr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )ÚtcÚgtÚscÚlcÚccÚgcÚbcÚbgÚecÚfsÚsfsÚindexÚclineÚdisptexÚdispcolÚkeyr   ÚvalueÚreturnÚNonec                óº   •— || j         v r| j         |         }|| j        vrt          d|› d�t          d¦  «         t	          ¦   «                              ||¦  «        S )Nzstyle option (z) is not supportedé   )ÚABBREVIATIONSÚVALID_FIELDSr   ÚUserWarningÚsuperÚ__setitem__)Úselfr,   r-   Ú	__class__s      €úZ/granary/edev/quantum/lib/python3.11/site-packages/qiskit/visualization/circuit/qcstyle.pyr6   zStyleDict.__setitem__I   sn   ø€ à�$Ô$Ð$Ð$ØÔ$ SÔ)ˆCà�dÔ'Ð'Ð'ÝØ8 Ð8Ð8Ð8ÝØñô ð õ
 ‰wŒw×"Ò" 3¨Ñ.Ô.Ð.ó    c                ór   •— || j         v r| j         |         }t          ¦   «                              |¦  «        S ©N)r2   r5   Ú__getitem__)r7   r,   r8   s     €r9   r=   zStyleDict.__getitem__V   s6   ø€ à�$Ô$Ð$Ð$ØÔ$ SÔ)ˆCå‰wŒw×"Ò" 3Ñ'Ô'Ð'r:   c                ój  •‡— ddhŠ‰                      |                     ¦   «         ¦  «        D ]E}||                      ¦   «         v r"| |                              ||         ¦  «         Œ:||         | |<   ŒFt          ¦   «                              ˆfd„|                     ¦   «         D ¦   «         ¦  «         d S )Nr   r   c              3  ó.   •K  — | ]\  }}|‰v¯	||fV — Œd S r<   © )Ú.0r,   r-   Únested_attrss      €r9   ú	<genexpr>z#StyleDict.update.<locals>.<genexpr>g   s6   øè è € Ð_Ð_©
¨¨UÀsÐR^ÐG^ÐG^˜˜U�|ÐG^ÐG^ÐG^ÐG^Ð_Ð_r:   )ÚintersectionÚkeysÚupdater5   Úitems)r7   ÚotherÚattrrB   r8   s      @€r9   rF   zStyleDict.update]   s¯   øø€ ð '¨Ð6ˆØ ×-Ò-¨e¯jªj©l¬lÑ;Ô;ð 	)ð 	)ˆDØ�t—y’y‘{”{Ð"Ð"Ø�T”
×!Ò! %¨¤+Ñ.Ô.Ð.Ð.à" 4œ[��T‘
�
å‰Œ�ŠÐ_Ð_Ð_Ð_°e·k²k±m´mÐ_Ñ_Ô_Ñ_Ô_Ð_Ð_Ð_r:   )r,   r   r-   r   r.   r/   )r,   r   r.   r   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r3   r2   r6   r=   rF   Ú__classcell__)r8   s   @r9   r	   r	      sÓ   ø€ € € € € ðð ðð ð €Lð. ØØØØØØ ØØØØØØ Ø Ø!ðð €Mð$/ð /ð /ð /ð /ð /ð(ð (ð (ð (ð (ð (ð
`ð 
`ð 
`ð 
`ð 
`ð 
`ð 
`ð 
`ð 
`r:   r	   c                  ó   — e Zd ZdZd„ ZdS )ÚDefaultStylea?  Creates a Default Style dictionary

    The style dict contains numerous options that define the style of the
    output circuit visualization. The style dict is used by the `mpl` or
    `latex` output. The options available in the style dict are defined below:

    Attributes:
        name (str): The name of the style. The name can be set to ``iqp``,
            ``iqp-dark``, ``textbook``, ``bw``, ``clifford``, or the name of a
            user-created json file. This overrides the setting in the user config
            file (usually ``~/.qiskit/settings.conf``).
        textcolor (str): the color code to use for all text not inside a gate.
        subtextcolor (str): the color code to use for subtext.
        linecolor (str): the color code to use for lines.
        creglinecolor (str): The color code to use for classical register lines.
        gatetextcolor (str): The color code to use for gate text.
        gatefacecolor (str): The color code to use for a gate if no color
            specified in the 'displaycolor' dict.
        barrierfacecolor (str): The color code to use for barriers.
        backgroundcolor (str): The color code to use for the background.
        edgecolor (str): The color code to use for gate edges when using the
            `bw` style.
        fontsize (int): The font size to use for text.
        subfontsize (int): The font size to use for subtext.
        showindex (bool): If set to True, show the index numbers at the top.
        figwidth (int): The maximum width (in inches) for the output figure.
            If set to -1, the maximum displayable width will be used.
        dpi (int): The DPI to use for the output image.
        margin (list): A list of margin values to adjust spacing around output
            image. Takes a list of 4 ints: [x left, x right, y bottom, y top].
        creglinestyle (str): The style of line to use for classical registers.
            Choices are ``solid``, ``doublet``, or any valid matplotlib
            `linestyle` kwarg value.
        displaytext (dict): a dictionary of the text to use for certain element
            types in the output visualization. These items allow the use of
            LaTeX formatting for gate names. The 'displaytext' dict can contain
            any number of elements. User created names and labels may be used as
            keys, which allow these to have Latex formatting.
        displaycolor (dict): the color codes to use for each circuit element in
            the form (gate_color, text_color). Colors can also be entered without
            the text color, such as 'u1': '#FA74A6', in which case the text color
            will always be `gatetextcolor`. The `displaycolor` dict can contain
            any number of elements. User names and labels may be used as keys,
            which allows for custom colors for user-created gates.
    c                óâ   — d}t          t          ¦  «        j        dz  |z  }t          |d¦  «        5 }t	          j        |¦  «        }d d d ¦  «         n# 1 swxY w Y   t          di |¤Ž| _        d S )Nziqp.jsonÚstylesÚrr@   )r   Ú__file__ÚparentÚopenÚjsonÚloadr	   Ústyle)r7   Údefault_style_dictÚpathÚinfileÚdefault_styles        r9   Ú__init__zDefaultStyle.__init__™   s«   € Ø'ÐÝ•H‰~Œ~Ô$ xÑ/Ð2DÑDˆå�$˜‰_Œ_ð 	. Ý œI fÑ-Ô-ˆMð	.ð 	.ð 	.ñ 	.ô 	.ð 	.ð 	.ð 	.ð 	.ð 	.ð 	.øøøð 	.ð 	.ð 	.ð 	.õ Ð/Ð/ Ð/Ð/ˆŒ
ˆ
ˆ
s   ²AÁAÁAN)rJ   rK   rL   rM   r^   r@   r:   r9   rP   rP   j   s.   € € € € € ð,ð ,ð\0ð 0ð 0ð 0ð 0r:   rP   rY   údict | str | Noner.   útuple[StyleDict, float]c                óþ  — t          j        ¦   «         }| €|r|                     dd¦  «        } nd} t          | t          ¦  «        r|                      dd¦  «        }ndt          | t
          ¦  «        r#|                      d¦  «        r| dd…         }n/| }n,t          d| › dt          | ¦  «        › d	�t          d
¦  «         d}|dv rt          ¦   «         j        }�nõ|dz   }g }t          t          ¦  «        j        dz  |z  }|                     |¦  «         |rB|                     dd¦  «        }|r*|D ]'}|                     t          |¦  «        |z  ¦  «         Œ(t          d¦  «        |z  }|                     |¦  «         |D ]ö}|                     ¦   «         }	t"          j                             |	¦  «        rÁ	 t)          |	¦  «        5 }
t+          j        |
¦  «        }ddd¦  «         n# 1 swxY w Y   t/          |¦  «        } nË# t*          j        $ r5}t          d|› dt          |¦  «        › d�t          d
¦  «         Y d}~ nŒd}~wt2          t4          f$ r t          d|› d�t          d
¦  «         Y  n[w xY wŒ÷t          d|› dd                     t9          t
          |¦  «        ¦  «        › d�t          d
¦  «         t          ¦   «         j        }t          | t          ¦  «        r|                     | ¦  «         d}||fS )aˆ  Utility function to load style from json files.

    Args:
        style: Depending on the type, this acts differently:

            * If a string, it can specify a supported style name (such
              as "iqp" or "clifford"). It can also specify the name of
              a custom color scheme stored as JSON file. This JSON file
              _must_ specify a complete set of colors.
            * If a dictionary, it may specify the style name via a
              ``{"name": "<desired style>"}`` entry. If this is not given,
              the default style will be used. The remaining entries in the
              dictionary can be used to override certain specs.
              E.g. ``{"name": "iqp", "ec": "#FF0000"}`` will use the ``"iqp"``
              color scheme but set the edgecolor to red.

    Returns:
        A tuple containing the style as dictionary and the default font ratio.
    NÚcircuit_mpl_styleÚdefaultr   z.jsonéûÿÿÿzUnsupported style parameter "z
" of type z. Will use the default style.r1   )Úiqprc   rR   Úcircuit_mpl_style_pathÚ zCould not decode JSON in file 'z': z. Will use default style.zError loading JSON file 'z'. Will use default style.zStyle JSON file 'z'' not found in any of these locations: z, g      ú?)r   Ú
get_configÚgetÚ
isinstanceÚdictÚstrÚendswithr   Útyper4   rP   rY   r   rT   rU   ÚappendÚ
expanduserÚosr[   ÚisfilerV   rW   rX   r	   ÚJSONDecodeErrorÚOSErrorÚFileNotFoundErrorÚjoinÚmaprF   )rY   ÚconfigÚ
style_nameÚcurrent_styleÚstyle_pathsÚdefault_pathÚconfig_pathr[   Úcwd_pathÚexp_userr\   Ú
json_styleÚerrÚdef_font_ratios                 r9   Ú
load_stylerƒ   ¤   sÒ  € õ. Ô#Ñ%Ô%€FØ€}Øð 	Ø—J’JÐ2°IÑ>Ô>ˆEˆEàˆEõ �%�ÑÔð Ø—Y’Y˜v yÑ1Ô1ˆ
ˆ
Ý	�E�3Ñ	Ô	ð Ø�>Š>˜'Ñ"Ô"ð 	Ø˜s ˜sœˆJˆJàˆJˆJåð*¨Eð *ð *½TÀ%¹[¼[ð *ð *ð *åØñ		
ô 	
ð 	
ð ˆ
àÐ'Ð'Ð'Ý$™œÔ,ˆ‰ð   'Ñ)ˆ
Øˆå�H‘~”~Ô,¨xÑ7¸*ÑDˆØ×Ò˜<Ñ(Ô(Ð(ð ð 	@Ø Ÿ*š*Ð%=¸rÑBÔBˆKØð @Ø'ð @ð @�DØ×&Ò&¥t¨D¡z¤z°JÑ'>Ñ?Ô?Ð?Ð?õ ˜‘8”8˜jÑ(ˆØ×Ò˜8Ñ$Ô$Ð$àð !	1ð !	1ˆDà—’Ñ(Ô(ˆHÝŒw�~Š~˜hÑ'Ô'ð ðÝ˜h™œð 7¨6Ý%)¤Y¨vÑ%6Ô%6˜
ð7ð 7ð 7ñ 7ô 7ð 7ð 7ð 7ð 7ð 7ð 7øøøð 7ð 7ð 7ð 7õ %.¨jÑ$9Ô$9�MØ�EøÝÔ+ð ð ð Ýð2¸$ð 2ð 2Å3ÀsÁ8Ä8ð 2ð 2ð 2å#Øñ	ô ð ð �E�E�E�E�EøøøøÝÕ!2Ð3ð ð ð ÝØT°DÐTÐTÐTÝ#Øñô ð ð
 �E�Eðøøøðõ. ð* Jð *ð *Ø—9’9�S¥ kÑ2Ô2Ñ3Ô3ð*ð *ð *õ Øñô ð õ )™NœNÔ0ˆMõ
 �%�ÑÔð $Ø×Ò˜UÑ#Ô#Ð#ð €Nà˜.Ð(Ð(sB   Æ8HÇG(ÇHÇ(G,	Ç,HÇ/G,	Ç0HÈI5È*IÉ.I5É4I5)rY   r_   r.   r`   )rM   Ú
__future__r   rW   rq   Útypingr   Úpathlibr   Úwarningsr   Úqiskitr   rk   r	   rP   rƒ   r@   r:   r9   ú<module>r‰      s  ðð .Ð -à "Ð "Ð "Ð "Ð "Ð "à €€€Ø 	€	€	€	Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ð Ð ðM`ð M`ð M`ð M`ð M`�ñ M`ô M`ð M`ð`70ð 70ð 70ð 70ð 70ñ 70ô 70ð 70ðtr)ð r)ð r)ð r)ð r)ð r)r:   