
    rh                        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        j/var/www/html/ai-insurance-compliance-backend/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      rt	        j
                  t        |dd          }t	        j                  | j                         |      }| j                         dkD  r.t        t        |      | j                         |j                         |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 AlignedTableMaybeOwnedVector   Ndtyper   r.   )	__class____name__
startswithAlignedTable_to_arraynprB   vector_name_mapemptysizememcpyswig_ptrdatanbytesendswithv	classnamerB   as       r   vector_to_arrayrU   h   s   $$IN+$Q''./2389HHQVVXU+668a<8A;!((3h'''HH_Ys^45E
'Avvx!|x{AFFHahh/Hr   c                     t        |       S )N)rU   )rR   s    r   vector_float_to_arrayrW   |   s    1r   c                    | j                   \  }|j                  j                  }|j                  d      r|j                  sJ d       t        j                  t        |dd          }|| j                  k(  sJ d| j                  d|d|d       |j                  |       |d	kD  r.t        |j                         t        |       | j                         y|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?   z,cannot copy to an non-owned MaybeOwnedVectorr@   Nzcannot copy a z array to a z (should be )r   r.   rC   )shaperD   rE   rF   is_ownedrH   rB   rI   resizerL   rN   rM   rO   rP   )rT   rR   nrS   rB   s        r   copy_array_to_vectorr^      s9   	
BA$$I./zzIIIz2389 	,E+	, 	
q51668Xa[!((3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   )rZ   itemsizer\   rL   getrM   rO   )rT   rR   r]   s      r   copy_array_to_AlignedTablerb      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   )rB   AlignedTableUint16rK   AlignedTableUint8rb   )rT   rR   s     r   array_to_AlignedTablerf      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>      NrA   r   )rD   rE   rF   lowerrH   rJ   rK   rL   rM   rN   rO   rQ   s       r   rG   rG      sy    $$I///bcN  "E
'Avvzx{AFFHahh/Hr   )numpyrH   arrayr	   faiss.loaderr   r`   sizeof_longdeprecated_name_mapitemsdepr_prefixbase_prefixri   rI   rU   rW   r^   rb   rf   rG   )krR   s   00r   <module>rs      s+      $'V ekk#'' "a'GW  !4 9 9 ; BKh 6h8NO //#K.$@$/.$@	BB  !4 9 9 ;<1q!'')|<(06/W =s   C