
    z	i                     d    S r SSKJr  \R                  R                  S5      S 5       r1 SkrS rg)zCommon visualization utilities.    )	optionalszthe latex circuit drawerc                 N   SSK nUR                  R                  U R                  U R                  U R                  S5      5      nUR                  R                  X5      nUR                  R                  X3SS5      nUR                  5       nU(       a  U R                  U5      n U $ )z(Trim a PIL image and remove white space.r   N)r   r   g       @i)PILImagenewmodesizegetpixel
ImageChops
differenceaddgetbboxcrop)imager   
backgrounddiffbboxs        T/home/james-whalen/.local/lib/python3.13/site-packages/qiskit/visualization/utils.py_trimr      s{     uzz5::u~~f7MNJ>>$$U7D>>d#t4D<<>D

4 L    >   nbAgg'module://ipykernel.pylab.backend_inline)module://matplotlib_inline.backend_inlinec                 t    SSK nUR                  5       [        ;   a  UR                  R	                  U 5        gg)aY  Close the given matplotlib figure if the backend in use draws figures inline.

If the backend does not draw figures inline, this does nothing.  This function is to prevent
duplicate images appearing; the inline backends will capture the figure in preparation and
display it as well, whereas the drawers want to return the figure to be displayed.r   N)matplotlib.pyplotget_backendMATPLOTLIB_INLINE_BACKENDSpyplotclose)figure
matplotlibs     r   matplotlib_close_if_inliner"   '   s2     #==' >r   N)	__doc__qiskit.utilsr   
_optionalsHAS_PILrequire_in_callr   r   r"    r   r   <module>r)      sA    & 0 ##$>?
 @
 
(r   