§
    ¹³Ùg-  ã                   ó:   — d Z ddlZddlmZ  G d„ de¦  «        ZdS )z$Container class for backend options.é    N)ÚMappingc                   ó˜   ‡ — e Zd ZdZdZd„ Zd„ Zd„ Zd„ Ze	d„ ¦   «         Z
d„ Zd	„ Zd
„ Zˆ fd„Zd„ Zˆ fd„Zd„ Zd„ Zd„ Zd„ Zˆ fd„Zˆ xZS )ÚOptionsaY  Base options object

    This class is what all backend options are based
    on. The properties of the class are intended to be all dynamically
    adjustable so that a user can reconfigure the backend on demand. If a
    property is immutable to the user (eg something like number of qubits)
    that should be a configuration of the backend class itself instead of the
    options.

    Instances of this class behave like dictionaries. Accessing an
    option with a default value can be done with the `get()` method:

    >>> options = Options(opt1=1, opt2=2)
    >>> options.get("opt1")
    1
    >>> options.get("opt3", default="hello")
    'hello'

    Key-value pairs for all options can be retrieved using the `items()` method:

    >>> list(options.items())
    [('opt1', 1), ('opt2', 2)]

    Options can be updated by name:

    >>> options["opt1"] = 3
    >>> options.get("opt1")
    3

    Runtime validators can be registered. See `set_validator`.
    Updates through `update_options` and indexing (`__setitem__`) validate
    the new value before performing the update and raise `ValueError` if
    the new value is invalid.

    >>> options.set_validator("opt1", (1, 5))
    >>> options["opt1"] = 4
    >>> options["opt1"]
    4
    >>> options["opt1"] = 10  # doctest: +ELLIPSIS
    Traceback (most recent call last):
    ...
    ValueError: ...
    ©Ú_fieldsÚ	validatorc                 ó   — | j         |         S ©N©r   )ÚselfÚkeys     úN/granary/edev/quantum/lib/python3.11/site-packages/qiskit/providers/options.pyÚ__getitem__zOptions.__getitem__i   s   € ØŒ|˜CÔ Ð ó    c                 ó*   — t          | j        ¦  «        S r
   )Úiterr   ©r   s    r   Ú__iter__zOptions.__iter__l   s   € Ý�D”LÑ!Ô!Ð!r   c                 ó*   — t          | j        ¦  «        S r
   )Úlenr   r   s    r   Ú__len__zOptions.__len__o   s   € Ý�4”<Ñ Ô Ð r   c                 ó$   —  | j         di ||i¤Ž d S )N© )Úupdate_options©r   r   Úvalues      r   Ú__setitem__zOptions.__setitem__t   s%   € ØˆÔÐ+Ð+˜s E˜lÐ+Ð+Ð+Ð+Ð+r   c                 ó   — | j         S r
   r   r   s    r   Ú__dict__zOptions.__dict__y   s
   € àŒ|Ðr   c                 ój   — 	 | j         |         S # t          $ r}t          d|› d�¦  «        |‚d }~ww xY w)NzOption z is not defined)r   ÚKeyErrorÚAttributeError)r   ÚnameÚexs      r   Ú__getattr__zOptions.__getattr__   sT   € ð	JØ”< Ô%Ð%øÝð 	Jð 	Jð 	JÝ Ð!@¨4Ð!@Ð!@Ð!@ÑAÔAÀrÐIøøøøð	Jøøøs   ‚ �
2™-­2c                 ó   — || j         |<   d S r
   r   r   s      r   Ú__setattr__zOptions.__setattr__‹   s   € Ø!ˆŒ�SÑÐÐr   c                 ó   — | j         | j        fS r
   r   r   s    r   Ú__getstate__zOptions.__getstate__�   s   € Ø”˜dœnÐ-Ð-r   c                 óš   •— |\  }}t          ¦   «                              d|¦  «         t          ¦   «                              d|¦  «         d S ©Nr   r   ©Úsuperr'   )r   Ústater   r   Ú	__class__s       €r   Ú__setstate__zOptions.__setstate__“   sG   ø€ Ø"Ñˆ�Ý‰Œ×Ò˜I wÑ/Ô/Ð/Ý‰Œ×Ò˜K¨Ñ3Ô3Ð3Ð3Ð3r   c                 óÔ   — |                       t          | ¦  «        ¦  «        }|                     | j                             ¦   «         | j                             ¦   «         f¦  «         |S )z}Return a copy of the Options.

        The returned option and validator values are shallow copies of the originals.
        )Ú__new__Útyper0   r   Úcopyr   )r   Úouts     r   Ú__copy__zOptions.__copy__˜   sU   € ð
 �lŠl�4 ™:œ:Ñ&Ô&ˆØ×Ò˜$œ,×+Ò+Ñ-Ô-¨t¬~×/BÒ/BÑ/DÔ/DÐEÑFÔFÐFØˆ
r   c                 ó�   •— t          ¦   «                              d|¦  «         t          ¦   «                              di ¦  «         d S r+   r,   )r   Úkwargsr/   s     €r   Ú__init__zOptions.__init__¡   s=   ø€ Ý‰Œ×Ò˜I vÑ.Ô.Ð.Ý‰Œ×Ò˜K¨Ñ,Ô,Ð,Ð,Ð,r   c                 ó¢   — d„ | j                              ¦   «         D ¦   «         }t          | ¦  «        j        › dd                     |¦  «        › d�S )Nc              3   ó*   K  — | ]\  }}|› d |›�V — ŒdS )ú=Nr   )Ú.0ÚkÚvs      r   ú	<genexpr>z#Options.__repr__.<locals>.<genexpr>¬   s0   è è € Ð?Ð?¡$ ! Q�A��˜��Ð?Ð?Ð?Ð?Ð?Ð?r   ú(z, ú))r   Úitemsr3   Ú__name__Újoin)r   rC   s     r   Ú__repr__zOptions.__repr__«   sO   € Ø?Ð?¨$¬,×*<Ò*<Ñ*>Ô*>Ð?Ñ?Ô?ˆÝ�t‘*”*Ô%Ð;Ð;¨¯	ª	°%Ñ(8Ô(8Ð;Ð;Ð;Ð;r   c                 ó„   — t          | t          ¦  «        r%t          |t          ¦  «        r| j        |j        k    S t          S r
   )Ú
isinstancer   r   ÚNotImplemented)r   Úothers     r   Ú__eq__zOptions.__eq__¯   s:   € Ý�d�GÑ$Ô$ð 	1­°E½7Ñ)CÔ)Cð 	1Ø”< 5¤=Ò0Ð0ÝÐr   c                 óœ  — || j         vrt          d|› d�¦  «        ‚t          |t          ¦  «        r#t	          |¦  «        dk    rt          d¦  «        ‚nmt          |t          ¦  «        r#t	          |¦  «        dk    rt          d¦  «        ‚n5t          |t          ¦  «        rnt          t          |¦  «        › d�¦  «        ‚|| j	        |<   dS )	ap  Set an optional validator for a field in the options

        Setting a validator enables changes to an options values to be
        validated for correctness when :meth:`~qiskit.providers.Options.update_options`
        is called. For example if you have a numeric field like
        ``shots`` you can specify a bounds tuple that set an upper and lower
        bound on the value such as::

            options.set_validator("shots", (1, 4096))

        In this case whenever the ``"shots"`` option is updated by the user
        it will enforce that the value is >=1 and <=4096. A ``ValueError`` will
        be raised if it's outside those bounds. If a validator is already present
        for the specified field it will be silently overridden.

        Args:
            field (str): The field name to set the validator on
            validator_value (list or tuple or type): The value to use for the
                validator depending on the type indicates on how the value for
                a field is enforced. If a tuple is passed in it must have a
                length of two and will enforce the min and max value
                (inclusive) for an integer or float value option. If it's a
                list it will list the valid values for a field. If it's a
                ``type`` the validator will just enforce the value is of a
                certain type.
        Raises:
            KeyError: If field is not present in the options object
            ValueError: If the ``validator_value`` has an invalid value for a
                given type
            TypeError: If ``validator_value`` is not a valid type
        zField 'z'' is not present in this options objecté   zŠA tuple validator must be of the form '(lower, upper)' where lower and upper are the lower and upper bounds inclusive of the numeric valuer   z-A list validator must have at least one entryzG is not a valid validator type, it must be a tuple, list, or class/typeN)
r   r!   rH   Útupler   Ú
ValueErrorÚlistr3   Ú	TypeErrorr   )r   ÚfieldÚvalidator_values      r   Úset_validatorzOptions.set_validator´   sý   € ðB ˜œÐ$Ð$ÝÐS UÐSÐSÐSÑTÔTÐTÝ�o¥uÑ-Ô-ð 	Ý�?Ñ#Ô# qÒ(Ð(Ý ð5ñô ð ð )õ ˜­Ñ.Ô.ð 		Ý�?Ñ#Ô# qÒ(Ð(Ý Ð!PÑQÔQÐQð )å˜­Ñ.Ô.ð 	ØåÝ˜Ñ(Ô(ð 7ð 7ð 7ñô ð ð !0ˆŒ�uÑÐÐr   c           
      ó  — |                      ¦   «         D ]Û\  }}| j                             |d¦  «        }t          |t          ¦  «        r=||d         k    s||d         k     r$t          d|› d|d         › d|d         › �¦  «        ‚Œrt          |t          ¦  «        r||vrt          d|› d|› �¦  «        ‚Œ¡t          |t          ¦  «        r%t          ||¦  «        st          d|› d	|› �¦  «        ‚ŒÜ| j	         
                    |¦  «         dS )
zUpdate options with kwargsNé   r   zSpecified value for 'z"' is not a valid value, must be >=z or <=zSpecified value for z' is not a valid choice, must be one of z is not of required type )rC   r   ÚgetrH   rN   rO   rP   r3   rQ   r   Úupdate)r   ÚfieldsÚ
field_namerR   Úfield_validators        r   r   zOptions.update_optionsê   sy  € à!'§¢¡¤ð 	ð 	ÑˆJ˜Ø"œn×0Ò0°¸TÑBÔBˆOÝ˜/­5Ñ1Ô1ð Ø˜?¨1Ô-Ò-Ð-°¸ÈÔ9KÒ1KÐ1KÝ$ðT°
ð Tð TØ%4°QÔ%7ðTð TØ?NÈqÔ?QðTð Tñô ð ð 2Lõ
 ˜O­TÑ2Ô2ð 
Ø Ð/Ð/Ý$ð<¨zð <ð <Ø*9ð<ð <ñô ð ð 0õ
 ˜O­TÑ2Ô2ð Ý! %¨Ñ9Ô9ð Ý#Øe¨zÐeÐeÐTcÐeÐeñô ð øð 	Œ×Ò˜FÑ#Ô#Ð#Ð#Ð#r   c           
      ó~  •— t          ¦   «                              ¦   «         }| j        s|S t          j        ¦   «         }|                     |¦  «         |                     d¦  «         | j                             ¦   «         D ]©\  }}t          |t          ¦  «        r,|                     d|› d|d         › d|d         › d�¦  «         ŒFt          |t          ¦  «        r|                     d|› d|› d�¦  «         Œxt          |t          ¦  «        r|                     d|› d	|› d�¦  «         Œª|                     ¦   «         S )
Nz
Where:
ú	z is >= r   z and <= rV   ú
z is one of z is of type )r-   Ú__str__r   ÚioÚStringIOÚwriterC   rH   rN   rP   r3   Úgetvalue)r   Úno_validatorÚout_strrR   r   r/   s        €r   r_   zOptions.__str__  sL  ø€ Ý‘w”w—’Ñ(Ô(ˆØŒ~ð 	&ØÐå”k‘m”mˆGØ�MŠM˜,Ñ'Ô'Ð'Ø�MŠM˜,Ñ'Ô'Ð'Ø $¤× 4Ò 4Ñ 6Ô 6ð Eð E‘��uÝ˜e¥UÑ+Ô+ð EØ—M’MÐ"S uÐ"SÐ"S°U¸1´XÐ"SÐ"SÀuÈQÄxÐ"SÐ"SÐ"SÑTÔTÐTÐTÝ ¥tÑ,Ô,ð EØ—M’MÐ"B uÐ"BÐ"B¸Ð"BÐ"BÐ"BÑCÔCÐCÐCÝ ¥tÑ,Ô,ð EØ—M’MÐ"C uÐ"CÐ"C¸%Ð"CÐ"CÐ"CÑDÔDÐDøØ×#Ò#Ñ%Ô%Ð%r   )rD   Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r   r   r   r   Úpropertyr   r%   r'   r)   r0   r6   r9   rF   rK   rT   r   r_   Ú__classcell__)r/   s   @r   r   r      sO  ø€ € € € € ð*ð *ðb )€Ið!ð !ð !ð"ð "ð "ð!ð !ð !ð
,ð ,ð ,ð
 ðð ñ „Xðð
	Jð 	Jð 	Jð"ð "ð "ð
.ð .ð .ð4ð 4ð 4ð 4ð 4ð
ð ð ð-ð -ð -ð -ð -ð<ð <ð <ðð ð ð
40ð 40ð 40ðl$ð $ð $ð0&ð &ð &ð &ð &ð &ð &ð &ð &r   r   )rh   r`   Úcollections.abcr   r   r   r   r   ú<module>rm      sf   ðð +Ð *à 	€	€	€	Ø #Ð #Ð #Ð #Ð #Ð #ð~&ð ~&ð ~&ð ~&ð ~&ˆgñ ~&ô ~&ð ~&ð ~&ð ~&r   