
    i                        S SK rS SKrS SKrS SK7  S r\R                  " S5      R                  rSSSS\S	:X  a  SOS
S
SSS.r\R                  5        H,  u  r
r\" \
S-   \S-   5        \
S;   d  M  \" \
S-   \S-   5        M.     SSSSSSSSSSS.
\R                  5        V Vs0 s H  u  pXR                  5       _M     snn ErS rS rS rS rS  rS! rgs  snn f )"    N)*c                 n   ^ ^^ [        5       T   mUUU 4S jn[        T T4SU05      nU[        5       T '   g)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                 v   > ST ST S3n[         R                  " U[        SS9  [        TU ]  " U /UQ70 UD6nU$ )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        g/home/dmtnaga/Documents/work/airagagent/rag_env/lib/python3.13/site-packages/faiss/array_conversions.pynew_meth-_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                    U R                   R                  nUR                  S5      (       a  [        U 5      $ UR                  S5      (       a  [        R
                  " [        USS    5      n[        R                  " U R                  5       US9nU R                  5       S:  a.  [        [        U5      U R                  5       UR                  5        U$ UR                  S5      (       d   e[        R
                  " [        USS    5      n[        R                  " U R                  5       US9nU R                  5       S:  a.  [        [        U5      U R                  5       UR                  5        U$ )	z&convert a C++ vector to a numpy array AlignedTableMaybeOwnedVector   Ndtyper   r/   )	__class____name__
startswithAlignedTable_to_arraynprC   vector_name_mapemptysizememcpyswig_ptrdatanbytesendswithv	classnamerC   as       r   vector_to_arrayrV   h   s   $$IN++$Q''.//2389HHQVVXU+668a<8A;!((3h''''HH_Ys^45E
'Avvx!|x{AFFHahh/Hr   c                     [        U 5      $ )N)rV   )rS   s    r   vector_float_to_arrayrX   |   s    1r   c                 $   U R                   u  nUR                  R                  nUR                  S5      (       a  UR                  (       d   S5       e[
        R                  " [        USS    5      nX@R                  :X  d   SU R                  < SU< SU< S35       eUR                  U5        US	:  a.  [        UR                  5       [        U 5      U R                  5        gUR                  S
5      (       d   e[
        R                  " [        USS    5      nX@R                  :X  d   SU R                  < SU< SU< S35       eUR                  U5        US	:  a/  [        UR                  5       [        U 5      U R                  5        gg)zcopy a numpy array to a vector r@   z,cannot copy to an non-owned MaybeOwnedVectorrA   Nzcannot copy a z array to a z (should be )r   r/   rD   )shaperE   rF   rG   is_ownedrI   rC   rJ   resizerM   rO   rN   rP   rQ   )rU   rS   nrT   rC   s        r   copy_array_to_vectorr_      s;   	
BA$$I.//zzIIIz2389 	,E+	, 	
q51668Xa[!((3h''''HH_Ys^45EGG (GGY	'( HHQK1uqvvx!ahh/ r   c                     U R                   u  nUR                  5       U R                  :X  d   eUR                  U5        US:  a/  [        UR	                  5       [        U 5      U R                  5        g g )Nr   )r[   itemsizer]   rM   getrN   rP   )rU   rS   r^   s      r   copy_array_to_AlignedTablerc      sV    	
BA::<1::%%%HHQK1uquuwQXX. r   c                     U R                   S:X  a  [        U R                  5      nO(U R                   S:X  a  [        U R                  5      nO e[	        X5        U$ )Nr8   r7   )rC   AlignedTableUint16rL   AlignedTableUint8rc   )rU   rS   s     r   array_to_AlignedTablerg      sH    ww(qvv&	
G	aff%uq$Hr   c                 J   U R                   R                  nUR                  S5      (       d   eUSS R                  5       n[        R
                  " U R                  5       US9nUR                  S:  a.  [        [        U5      U R                  5       UR                  5        U$ )z)convert an AlignedTable to a numpy array r?      NrB   r   )rE   rF   rG   lowerrI   rK   rL   rM   rN   rO   rP   rR   s       r   rH   rH      s|    $$I////bcN  "E
'Avvzx{AFFHahh/Hr   )numpyrI   arrayr	   faiss.loaderr   ra   sizeof_longdeprecated_name_mapitemsdepr_prefixbase_prefixrj   rJ   rV   rX   r_   rc   rg   rH   )krS   s   00r   <module>rt      s$      $'V kk#'' "a'GW  !4 9 9 ;Kh 6h8NO //#K.$@$/.$@	B !<  !4 9 9 ;< ;q'')| ;<(06/W =s   #C