
    
Fg                        d dl Zd dlZd dlZd dl d Z ej                  d      j                  Zdddded	k(  rdnd
d
dddZej                         D ](  \  Z
Z ee
dz   edz          e
dv s ee
dz   edz          * ddddddddddd
ej                         D  ci c]  \  } }| |j                          c}} Zd Zd Zd Zd Zd  Zd! Zyc c}} w )"    N)*c                 l     t                   fd}t         fd|i      }|t                <   y)a  
    Dynamically construct deprecated classes as wrappers around renamed ones

    The deprecation warning added in their __new__-method will trigger upon
    construction of an instance of the class, but only once per session.

    We do this here (in __init__.py) because the base classes are defined in
    the SWIG interface, making it cumbersome to add the deprecation there.

    Parameters
    ----------
    deprecated_name : string
        Name of the class to be deprecated; _not_ present in SWIG interface.
    base_name : string
        Name of the class that is replacing deprecated_name; must already be
        imported into the current namespace.

    Returns
    -------
    None
        However, the deprecated class gets added to the faiss namespace
    c                 x    d d d}t        j                  |t        d       t        |   | g|i |}|S )NzThe class faiss.z" is deprecated in favour of faiss.!   )
stacklevel)warningswarnDeprecationWarningsuper__new__)clsargskwargsmsginstance
base_class	base_namedeprecated_names        t/home/kushmeetdev/apache_webroot/langgraph_flaskproject/venv/lib/python3.12/site-packages/faiss/array_conversions.pynew_methz-_make_deprecated_swig_class.<locals>.new_meth/   sM      11ST]S^^_`c-!<S1#GGG    r   N)globalstype)r   r   r   klazzr   s   ``  @r   _make_deprecated_swig_classr      s;    . 9%J :-)X1FGE "'GIor   lFloat32Float64Int8Int32   Int64UInt8UInt64)FloatDoubleCharIntLongLongLongByteUint64Vector)r&   r*   r,   VectorVectorfloat32float64int8int16int32int64uint8uint16uint32uint64)
r   r   r    Int16r!   r#   r$   UInt16UInt32r%   c                    | j                   j                  }|j                  d      rt        |       S |j	                  d      sJ t        j                  t        |dd          }t        j                  | j                         |      }| j                         dkD  r.t        t        |      | j                         |j                         |S )z' convert a C++ vector to a numpy array AlignedTabler.   Ndtyper   )	__class____name__
startswithAlignedTable_to_arrayendswithnprA   vector_name_mapemptysizememcpyswig_ptrdatanbytesv	classnamerA   as       r   vector_to_arrayrS   h   s    $$IN+$Q''h'''HH_Ys^45E
'Avvx!|x{AFFHahh/Hr   c                     t        |       S )N)rS   )rP   s    r   vector_float_to_arrayrU   u   s    1r   c                    | j                   \  }|j                  j                  }|j                  d      sJ t	        j
                  t        |dd          }|| j
                  k(  sJ d| j
                  d|d|d       |j                  |       |dkD  r/t        |j                         t        |       | j                         yy)	z  copy a numpy array to a vector r.   Nr?   zcannot copy a z array to a z (should be )r   )shaperB   rC   rF   rG   rA   rH   resizerK   rM   rL   rN   )rR   rP   nrQ   rA   s        r   copy_array_to_vectorr[   y   s    	
BA$$Ih'''HH_Ys^45EAGG (GGY	'( HHQK1uqvvx!ahh/ r   c                     | j                   \  }|j                         | j                  k(  sJ |j                  |       |dkD  r/t        |j	                         t        |       | j                         y y )Nr   )rX   itemsizerY   rK   getrL   rN   )rR   rP   rZ   s      r   copy_array_to_AlignedTabler_      sV    	
BA::<1::%%%HHQK1uquuwQXX. r   c                     | j                   dk(  rt        | j                        }n'| j                   dk(  rt        | j                        }nJ t	        | |       |S )Nr7   r6   )rA   AlignedTableUint16rJ   AlignedTableUint8r_   )rR   rP   s     r   array_to_AlignedTablerc      sJ    ww(qvv&	
G	aff%uq!$Hr   c                 B   | j                   j                  }|j                  d      sJ |dd j                         }t	        j
                  | j                         |      }|j                  dkD  r.t        t        |      | j                         |j                         |S )z* convert an AlignedTable to a numpy array r>      Nr@   r   )rB   rC   rD   lowerrG   rI   rJ   rK   rL   rM   rN   rO   s       r   rE   rE      sy    $$I///bcN  "E
'Avvzx{AFFHahh/Hr   )numpyrG   arrayr	   faiss.loaderr   r]   sizeof_longdeprecated_name_mapitemsdepr_prefixbase_prefixrf   rH   rS   rU   r[   r_   rc   rE   )krP   s   00r   <module>rp      s+      $'V ekk#'' "a'GW  !4 9 9 ; BKh 6h8NO //#K.$@$/.$@	BB  !4 9 9 ;<1q!'')|<
0 /s =s   C