Ë
    âQ(h¬6  ã                   óð   — d dl Z d dlmZmZ d dlZd dlmZ  G d„ de«      Z G d„ de«      Z	 G d„ d	e«      Z
 G d
„ d«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ d«      Z G d„ d«      Zy)é    N)ÚABCÚabstractmethod)Ú
MapWrapperc                   óJ   — e Zd ZdZd	d„Zd„ Zd„ Zed„ «       Zed„ «       Z	d„ Z
y)
Ú
VertexBasez"
    Base class for a vertex.
    Nc                 ó¦   — || _         t        | j                   «      | _        |�t        |«      | _        || _        yt        «       | _        || _        y)a  
        Initiation of a vertex object.

        Parameters
        ----------
        x : tuple or vector
            The geometric location (domain).
        nn : list, optional
            Nearest neighbour list.
        index : int, optional
            Index of vertex.
        N)ÚxÚhashÚsetÚnnÚindex)Úselfr	   r   r   s       ú^/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/scipy/optimize/_shgo_lib/_vertex.pyÚ__init__zVertexBase.__init__   sE   € ð ˆŒÜ˜Ÿ™“LˆŒ	àˆ>Ü˜"“gˆDŒGð ˆ�
ô “eˆDŒGàˆ�
ó    c                 ó   — | j                   S ©N)r
   ©r   s    r   Ú__hash__zVertexBase.__hash__$   s   € Ø�y‰yÐr   c                 óª   — |dvrt        t        | «      › d|› d�«      ‚|dk(  r0t        j                  | j                  «      | _        | j
                  S y )N)Úx_az object has no attribute 'ú'r   )ÚAttributeErrorÚtypeÚnpÚarrayr	   r   )r   Úitems     r   Ú__getattr__zVertexBase.__getattr__'   sY   € Ø�wÑÜ ¤D¨£J <ð 0%Ø%) F¨!ð"-ó .ð .à�5Š=Ü—x‘x §¡Ó'ˆDŒHØ—8‘8ˆOð r   c                 ó   — t        d«      ‚©NzKThis method is only implemented with an associated child of the base class.©ÚNotImplementedError©r   Úvs     r   ÚconnectzVertexBase.connect/   ó   € ä!ð #Hó Ið 	Ir   c                 ó   — t        d«      ‚r    r!   r#   s     r   Ú
disconnectzVertexBase.disconnect4   r&   r   c                 ór   — | j                   | _        | j                  j                  | «       | j                  S )a  Returns the star domain ``st(v)`` of the vertex.

        Parameters
        ----------
        v :
            The vertex ``v`` in ``st(v)``

        Returns
        -------
        st : set
            A set containing all the vertices in ``st(v)``
        )r   ÚstÚaddr   s    r   ÚstarzVertexBase.star9   s(   € ð —'‘'ˆŒØ�‰�‰�DÔØ�w‰wˆr   ©NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r%   r(   r,   © r   r   r   r   	   sG   „ ñóò.òð ñIó ðIð ñIó ðIór   r   c                   ó@   ‡ — e Zd ZdZ	 	 dˆ fd„	Zd„ Zd„ Zd„ Zd„ Zˆ xZ	S )ÚVertexScalarFieldz�
    Add homology properties of a scalar field f: R^n --> R associated with
    the geometry built from the VertexBase class
    c                 óF   •— t         ‰| �  |||¬«       d| _        d| _        y)aY  
        Parameters
        ----------
        x : tuple,
            vector of vertex coordinates
        field : callable, optional
            a scalar field f: R^n --> R associated with the geometry
        nn : list, optional
            list of nearest neighbours
        index : int, optional
            index of the vertex
        field_args : tuple, optional
            additional arguments to be passed to field
        g_cons : callable, optional
            constraints on the vertex
        g_cons_args : tuple, optional
            additional arguments to be passed to g_cons

        ©r   r   TN)Úsuperr   Ú	check_minÚ	check_max)	r   r	   Úfieldr   r   Ú
field_argsÚg_consÚg_cons_argsÚ	__class__s	           €r   r   zVertexScalarField.__init__Q   s)   ø€ ô* 	‰Ñ˜˜r¨ÐÔ/ð ˆŒØˆ�r   c                 óÐ   — || urb|| j                   vrS| j                   j                  |«       |j                   j                  | «       d| _        d| _        d|_        d|_        yyy)zŒConnects self to another vertex object v.

        Parameters
        ----------
        v : VertexBase or VertexScalarField object
        TN)r   r+   r8   r9   r#   s     r   r%   zVertexScalarField.connectt   sY   € ð �D‰=˜Q d§g¡gÑ-Ø�G‰G�K‰K˜ŒNØ�D‰D�H‰H�TŒNð "ˆDŒNØ!ˆDŒNØˆAŒKØˆA�Kð .ˆ=r   c                 óÆ   — || j                   v rS| j                   j                  |«       |j                   j                  | «       d| _        d| _        d|_        d|_        y y )NT)r   Úremover8   r9   r#   s     r   r(   zVertexScalarField.disconnect…   sP   € Ø�—‘‰<Ø�G‰G�N‰N˜1ÔØ�D‰D�K‰K˜Ôð "ˆDŒNØ!ˆDŒNØˆAŒKØˆA�Kð r   c                 óˆ   ‡ — ‰ j                   r*t        ˆ fd„‰ j                  D «       «      ‰ _        d‰ _         ‰ j                  S )zMCheck whether this vertex is strictly less than all its
           neighboursc              3   óP   •K  — | ]  }‰j                   |j                   k  –— Œ y ­wr   ©Úf©Ú.0r$   r   s     €r   ú	<genexpr>z.VertexScalarField.minimiser.<locals>.<genexpr>”   ó   øè ø€ Ò:¨Q˜DŸF™F Q§S¡S�LÑ:ùó   ƒ#&F)r8   Úallr   Ú_minr   s   `r   Ú	minimiserzVertexScalarField.minimiser�   s3   ø€ ð �>Š>ÜÓ:°$·'±'Ô:Ó:ˆDŒIØ"ˆDŒNà�y‰yÐr   c                 óˆ   ‡ — ‰ j                   r*t        ˆ fd„‰ j                  D «       «      ‰ _        d‰ _         ‰ j                  S )z`
        Check whether this vertex is strictly greater than all its
        neighbours.
        c              3   óP   •K  — | ]  }‰j                   |j                   kD  –— Œ y ­wr   rD   rF   s     €r   rH   z.VertexScalarField.maximiser.<locals>.<genexpr>Ÿ   rI   rJ   F)r9   rK   r   Ú_maxr   s   `r   Ú	maximiserzVertexScalarField.maximiser™   s3   ø€ ð
 �>Š>ÜÓ:°$·'±'Ô:Ó:ˆDŒIØ"ˆDŒNà�y‰yÐr   )NNNr2   Nr2   )
r.   r/   r0   r1   r   r%   r(   rM   rQ   Ú__classcell__©r>   s   @r   r4   r4   K   s,   ø„ ñð
 GIØ*,õ!òFò"	òö	r   r4   c                   ó*   ‡ — e Zd ZdZ	 	 	 dˆ fd„	Zˆ xZS )ÚVertexVectorFieldz„
    Add homology properties of a scalar field f: R^n --> R^m associated with
    the geometry built from the VertexBase class.
    c
                 ó>   •— t         ‰
| �  |||	¬«       t        d«      ‚)Nr6   z&This class is still a work in progress)r7   r   r"   )r   r	   ÚsfieldÚvfieldr;   Úvfield_argsr<   r=   r   r   r>   s             €r   r   zVertexVectorField.__init__«   s%   ø€ ô 	‰Ñ˜˜r¨ÐÔ/ä!Ð"JÓKÐKr   )NNr2   r2   Nr2   NN)r.   r/   r0   r1   r   rR   rS   s   @r   rU   rU   ¥   s!   ø„ ñð
 @BØ(,Ø04÷Lñ Lr   rU   c                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)ÚVertexCacheBasez7Base class for a vertex cache for a simplicial complex.c                 óR   — t        j                  «       | _        d| _        d| _        y )Nr   éÿÿÿÿ)ÚcollectionsÚOrderedDictÚcacheÚnfevr   r   s    r   r   zVertexCacheBase.__init__µ   s    € ä ×,Ñ,Ó.ˆŒ
ØˆŒ	Øˆ�
r   c              #   óP   K  — | j                   D ]  }| j                   |   –— Œ y ­wr   )r`   r#   s     r   Ú__iter__zVertexCacheBase.__iter__»   s*   è ø€ Ø—‘ò 	 ˆAØ—*‘*˜Q‘-Óð	 àùs   ‚$&c                 ó    — | j                   dz   S )z%Returns the size of the vertex cache.é   ©r   r   s    r   ÚsizezVertexCacheBase.sizeÀ   s   € à�z‰z˜A‰~Ðr   c                 ó   — t        dt        | j                  «      › d�«      }t        d|z  «       t        dt        | j                  «      › d�«       t        d|z  «       | j                  D ]  }| j                  |   j                  «        Œ! y )NzVertex cache of size: ú:ú=)Úlenr`   ÚprintÚ	print_out)r   Úheadlenr$   s      r   rm   zVertexCacheBase.print_outÄ   sy   € ÜÐ.¬s°4·:±:«Ð.?¸qÐAÓBˆÜˆc�G‰mÔÜÐ&¤s¨4¯:©:£Ð&7°qÐ9Ô:Üˆc�G‰mÔØ—‘ò 	&ˆAØ�J‰J�q‰M×#Ñ#Õ%ñ	&r   N)r.   r/   r0   r1   r   rc   rg   rm   r2   r   r   r[   r[   ³   s   „ ÙAòòò
ó&r   r[   c                   ó0   ‡ — e Zd ZdZdˆ fd„	Zd„ Zd„ Zˆ xZS )Ú
VertexCubez‹Vertex class to be used for a pure simplicial complex with no associated
    differential geometry (single level domain that exists in R^n)c                 ó*   •— t         ‰| �  |||¬«       y )Nr6   )r7   r   )r   r	   r   r   r>   s       €r   r   zVertexCube.__init__Ð   s   ø€ Ü‰Ñ˜˜r¨ÐÕ/r   c                 ó˜   — || urF|| j                   vr7| j                   j                  |«       |j                   j                  | «       y y y r   )r   r+   r#   s     r   r%   zVertexCube.connectÓ   s9   € Ø�D‰=˜Q d§g¡gÑ-Ø�G‰G�K‰K˜ŒNØ�D‰D�H‰H�T�Nð .ˆ=r   c                 óŽ   — || j                   v r7| j                   j                  |«       |j                   j                  | «       y y r   )r   rA   r#   s     r   r(   zVertexCube.disconnectØ   s2   € Ø�—‘‰<Ø�G‰G�N‰N˜1ÔØ�D‰D�K‰K˜Õð r   r-   )r.   r/   r0   r1   r   r%   r(   rR   rS   s   @r   rp   rp   Í   s   ø„ ñFõ0òö
r   rp   c                   ó&   ‡ — e Zd Zˆ fd„Zdd„Zˆ xZS )ÚVertexCacheIndexc                 ó8   •— t         ‰| �  «        t        | _        y)zÊ
        Class for a vertex cache for a simplicial complex without an associated
        field. Useful only for building and visualising a domain complex.

        Parameters
        ----------
        N)r7   r   rp   ÚVertex)r   r>   s    €r   r   zVertexCacheIndex.__init__ß   s   ø€ ô 	‰ÑÔÜ ˆ�r   c                 óà   — 	 | j                   |   S # t        $ rS | xj                  dz  c_        | j                  || j                  ¬«      }|| j                   |<   | j                   |   cY S w xY w)Nre   rf   )r`   ÚKeyErrorr   rw   ©r   r	   r   Úxvals       r   Ú__getitem__zVertexCacheIndex.__getitem__ê   sd   € ð		!Ø—:‘:˜a‘=Ð øÜò 	!Ø�JŠJ˜!‰O�JØ—;‘;˜q¨¯
©
�;Ó3ˆDð !ˆD�J‰J�q‰MØ—:‘:˜a‘=Ò ð	!ús   ‚ ‘AA-Á,A-r   )r.   r/   r0   r   r|   rR   rS   s   @r   ru   ru   Þ   s   ø„ ô	!÷
!r   ru   c                   ón   ‡ — e Zd Z	 	 dˆ fd„	Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zˆ xZS )ÚVertexCacheFieldc                 ó  •— t         ‰| �  «        d| _        t        | _        || _        || _        t        ||«      | _        || _	        || _
        t        ||«      | _        t        «       | _        t        «       | _        d| _        || _        t%        |«      | _        |dk(  r7| j(                  | _        |€| j,                  | _        y| j0                  | _        y| j2                  | _        |€| j4                  | _        y| j6                  | _        y)a  
        Class for a vertex cache for a simplicial complex with an associated
        field.

        Parameters
        ----------
        field : callable
            Scalar or vector field callable.
        field_args : tuple, optional
            Any additional fixed parameters needed to completely specify the
            field function
        g_cons : dict or sequence of dict, optional
            Constraints definition.
            Function(s) ``R**n`` in the form::
        g_cons_args : tuple, optional
            Any additional fixed parameters needed to completely specify the
            constraint functions
        workers : int  optional
            Uses `multiprocessing.Pool <multiprocessing>`) to compute the field
             functions in parallel.

        r]   Fre   N)r7   r   r   r4   rw   r:   r;   ÚFieldWrapperÚwfieldr<   r=   ÚConstraintWrapperÚwgconsr   ÚgpoolÚfpoolÚsfc_lockÚworkersr   Ú_mapwrapperÚ
proc_gpoolÚprocess_gpoolÚproc_fpool_nogÚprocess_fpoolÚproc_fpool_gÚpproc_gpoolÚpproc_fpool_nogÚpproc_fpool_g)r   r:   r;   r<   r=   r‡   r>   s         €r   r   zVertexCacheField.__init__ø   sé   ø€ ô0 	‰ÑÔØˆŒ
Ü'ˆŒØˆŒ
Ø$ˆŒÜ" 5¨*Ó5ˆŒàˆŒØ&ˆÔÜ'¨°Ó<ˆŒÜ“UˆŒ
ô “UˆŒ
ØˆŒàˆŒÜ% gÓ.ˆÔà�aŠ<Ø!%§¡ˆDÔØˆ~Ø%)×%8Ñ%8�Õ"à%)×%6Ñ%6�Õ"à!%×!1Ñ!1ˆDÔØˆ~Ø%)×%9Ñ%9�Õ"à%)×%7Ñ%7�Õ"r   c           
      ó¦  — 	 | j                   |   S # t        $ r¶ | xj                  dz  c_        | j                  || j                  || j                  | j
                  | j                  | j                  ¬«      }|| j                   |<   | j                  j                  |«       | j                  j                  |«       | j                   |   cY S w xY w)Nre   )r:   r   r   r;   r<   r=   )r`   ry   r   rw   r:   r;   r<   r=   r„   r+   r…   rz   s       r   r|   zVertexCacheField.__getitem__0  s¨   € ð	!Ø—:‘:˜a‘=Ð øÜò 
	!Ø�JŠJ˜!‰O�JØ—;‘;˜q¨¯
©
°rÀÇÁØ*.¯/©/Ø&*§k¡kØ+/×+;Ñ+;ð ó =ˆDð
 !ˆD�J‰J�q‰MØ�J‰J�N‰N˜4Ô Ø�J‰J�N‰N˜4Ô Ø—:‘:˜a‘=Ò ð
	!ús   ‚ ‘B<CÃCc                 ó@   — | j                   j                  «       }|d= |S )NÚpool)Ú__dict__Úcopy)r   Ú	self_dicts     r   Ú__getstate__zVertexCacheField.__getstate__?  s"   € Ø—M‘M×&Ñ&Ó(ˆ	Ø�fÐØÐr   c                 ó|   — | j                   �| j                  «        | j                  «        | j                  «        y r   )r<   rŠ   rŒ   Úproc_minimisersr   s    r   Úprocess_poolszVertexCacheField.process_poolsD  s0   € Ø�;‰;Ð"Ø×ÑÔ Ø×ÑÔØ×ÑÕr   c                 óð   — d|_         t        | j                  | j                  «      D ]L  \  }}t	        j
                   ||j                  g|¢­Ž dk  «      sŒ0t        j                  |_        d|_          y  y ©NTg        F)	ÚfeasibleÚzipr<   r=   r   Úanyr   ÚinfrE   )r   r$   ÚgÚargss       r   Úfeasibility_checkz"VertexCacheField.feasibility_checkJ  s_   € ØˆŒ
Ü˜4Ÿ;™;¨×(8Ñ(8Ó9ò 	‰GˆAˆtä�v‰v‘a˜Ÿ™�o ’o¨Ñ+Õ,Ü—f‘f�”Ø"�”
Ùñ	r   c                 ó:  — 	  | j                   |j                  g| j                  ¢­Ž |_        | xj                  dz  c_        t        j                  |j                  «      rt        j                  |_        yy# t
        $ r t        j                  |_        Y ŒVw xY w)zšCompute the scalar field values of a vertex object `v`.

        Parameters
        ----------
        v : VertexBase or VertexScalarField object
        re   N)	r:   r   r;   rE   ra   r   r   r    Úisnanr#   s     r   Úcompute_sfieldzVertexCacheField.compute_sfieldS  sp   € ð	Ø�$—*‘*˜QŸU™UÐ5 T§_¡_Ò5ˆAŒCØ�IŠI˜‰N�Iô �8‰8�A—C‘CŒ=Ü—&‘&ˆA�Cð øô ò 	Ü—&‘&ˆAŽCð	ús   ‚AA9 Á9BÂBc                 ó~   — | j                   �"| j                  D ]  }| j                  |«       Œ t        «       | _        y)zProcess all constraints.N)r<   r„   r£   r   r#   s     r   r‰   zVertexCacheField.proc_gpoolc  s8   € à�;‰;Ð"Ø—Z‘Zò *�Ø×&Ñ& qÕ)ð*ô “Uˆ�
r   c                 óö   — g }| j                   D ]  }|j                  |j                  «       Œ | j                  | j                  j
                  |«      }t        | j                   |«      D ]  \  }}||_        Œ y)z$Process all constraints in parallel.N)r„   Úappendr   rˆ   rƒ   Úgconsrž   r�   )r   Úgpool_lr$   ÚGr¡   s        r   rŽ   zVertexCacheField.pproc_gpoolk  sm   € àˆØ—‘ò 	"ˆAØ�N‰N˜1Ÿ5™5Õ!ð	"ð ×Ñ˜TŸ[™[×.Ñ.°Ó8ˆÜ˜Ÿ
™
 AÓ&ò 	‰DˆAˆqØˆA�Jñ	r   c                 ó€   — | j                   D ]   }|j                  sŒ| j                  |«       Œ" t        «       | _         y)z6Process all field functions with constraints supplied.N)r…   r�   r¦   r   r#   s     r   r�   zVertexCacheField.proc_fpool_gu  s5   € à—‘ò 	'ˆAØ�z‹zØ×#Ñ# AÕ&ð	'ô “Uˆ�
r   c                 óf   — | j                   D ]  }| j                  |«       Œ t        «       | _         y)z9Process all field functions with no constraints supplied.N)r…   r¦   r   r#   s     r   r‹   zVertexCacheField.proc_fpool_nog}  s.   € à—‘ò 	#ˆAØ×Ñ Õ"ð	#ô “Uˆ�
r   c                 ó¶  — | j                   j                   g }| j                  D ]?  }|j                  r|j	                  |j
                  «       Œ+t        j                  |_        ŒA | j                  | j                   j                  |«      }t        ||«      D ]/  \  }}t        |«      }|| |   _        | xj                  dz  c_        Œ1 t        «       | _        y)zT
        Process all field functions with constraints supplied in parallel.
        re   N)r�   Úfuncr…   r�   r©   r   r   r    rE   rˆ   rž   Útuplera   r   ©r   Úfpool_lr$   ÚFÚvarE   Úvts          r   r�   zVertexCacheField.pproc_fpool_g„  s®   € ð 	�‰×ÒØˆØ—‘ò 	ˆAØ�zŠzØ—‘˜qŸu™uÕ%ä—f‘f�•ð		ð
 ×Ñ˜TŸ[™[×-Ñ-¨wÓ7ˆÜ˜ !“_ò 	‰EˆB�Ü�r“ˆBØˆD�‰HŒJØ�IŠI˜‰NŽIð	ô
 “Uˆ�
r   c                 ór  — | j                   j                   g }| j                  D ]  }|j                  |j                  «       Œ | j                  | j                   j                  |«      }t        ||«      D ]/  \  }}t        |«      }|| |   _        | xj                  dz  c_	        Œ1 t        «       | _        y)zW
        Process all field functions with no constraints supplied in parallel.
        re   N)r�   r°   r…   r©   r   rˆ   rž   r±   rE   ra   r   r²   s          r   r�   z VertexCacheField.pproc_fpool_nog—  sš   € ð 	�‰×ÒØˆØ—‘ò 	"ˆAØ�N‰N˜1Ÿ5™5Õ!ð	"à×Ñ˜TŸ[™[×-Ñ-¨wÓ7ˆÜ˜ !“_ò 	‰EˆB�Ü�r“ˆBØˆD�‰HŒJØ�IŠI˜‰NŽIð	ô
 “Uˆ�
r   c                 óR   — | D ]"  }|j                  «        |j                  «        Œ$ y)zCheck for minimisers.N)rM   rQ   r#   s     r   r™   z VertexCacheField.proc_minimisers§  s#   € àò 	ˆAØ�K‰KŒMØ�K‰K�Mñ	r   )Nr2   Nr2   re   r   )r.   r/   r0   r   r|   r—   rš   r£   r¦   r‰   rŽ   r�   r‹   r�   r�   r™   rR   rS   s   @r   r~   r~   ÷   sK   ø„ ØKMØõ68óp!òò
òòò òòòòò&ö r   r~   c                   ó   — e Zd ZdZd„ Zd„ Zy)r‚   z=Object to wrap constraints to pass to `multiprocessing.Pool`.c                 ó    — || _         || _        y r   )r<   r=   )r   r<   r=   s      r   r   zConstraintWrapper.__init__°  s   € ØˆŒØ&ˆÕr   c                 ó¢   — d}t        | j                  | j                  «      D ])  \  }}t        j                   ||g|¢­Ž dk  «      sŒ&d} |S  |S rœ   )rž   r<   r=   r   rŸ   )r   Úv_x_aÚ	vfeasibler¡   r¢   s        r   rª   zConstraintWrapper.gcons´  sZ   € Øˆ	Ü˜4Ÿ;™;¨×(8Ñ(8Ó9ò 	‰GˆAˆtä�v‰v‘a˜�o ’o¨Ñ+Õ,Ø!�	ØØÐð	ð
 Ðr   N)r.   r/   r0   r1   r   rª   r2   r   r   r‚   r‚   ®  s   „ ÙGò'ór   r‚   c                   ó   — e Zd ZdZd„ Zd„ Zy)r€   z7Object to wrap field to pass to `multiprocessing.Pool`.c                 ó    — || _         || _        y r   )r:   r;   )r   r:   r;   s      r   r   zFieldWrapper.__init__À  s   € ØˆŒ
Ø$ˆ�r   c                 óÊ   — 	  | j                   |g| j                  ¢­Ž }t        j
                  |«      rt        j                  }|S # t        $ r t        j                  }Y ŒBw xY wr   )r:   r;   Ú	Exceptionr   r    r¥   )r   r¼   Úv_fs      r   r°   zFieldWrapper.funcÄ  sU   € ð	Ø�$—*‘*˜UÐ5 T§_¡_Ò5ˆCô �8‰8�CŒ=Ü—&‘&ˆCàˆ
øô ò 	Ü—&‘&ŠCð	ús   ‚A ÁA"Á!A"N)r.   r/   r0   r1   r   r°   r2   r   r   r€   r€   ¾  s   „ ÙAò%ór   r€   )r^   Úabcr   r   Únumpyr   Úscipy._lib._utilr   r   r4   rU   r[   rp   ru   r~   r‚   r€   r2   r   r   ú<module>rÆ      s€   ðÛ ß #ã å 'ô?�ô ?ôDW˜
ô WôtL˜
ô L÷&ñ &ô4�ô ô"!�ô !ô2t�ô t÷nñ ÷ ò r   