
    wdX                        d dl mZ ddlmZ ddlmZmZmZmZm	Z	m
Z
mZmZmZmZ ddlmZ d Z eee          dd	            Z G d
 d ee                    Ze                    ee          dd            Ze                    ee          dd            Z eeefeef          dd            Z eee          dd            Z eee          dd            Z ee
e
          	 	 	 dd            Z eee          dd            Z ee	e	          dd            Z eee          dd            Z eee          dd            ZdS )    )ABCMeta   )with_metaclass)
	DataShapeDateTimeFunctionOptionRecordStringTime	TimeDeltaTupleUnits)dispatchc                 :    | sdS dd                     |           z   S )zFormat the path for final display.

    Parameters
    ----------
    path : iterable of str
        The path to the values that are not equal.

    Returns
    -------
    fmtd : str
        The formatted path to put into the error message.
     zpath: _)join)paths    6lib/python3.11/site-packages/datashape/util/testing.py	_fmt_pathr      s&      rrwwt}}$$    TNc                    | j         }|j         }|d}|rt          t          ||                    D ]\  }\  }}	||	k    r|d|z  fz  }t          d|d|	t	          | j                   dk    rTdd                    t          t          |                    dd                    t          t          |                    nd	dt          |                    |d
z  }t          | j
        |j
        f||d| dS )a7  Assert that two dshapes are equal, providing an informative error
    message when they are not equal.

    Parameters
    ----------
    a, b : dshape
        The dshapes to check for equality.
    check_dim : bool, optional
        Check shapes for equality with respect to their dimensions.
        default: True
    check_tz : bool, optional
        Checks times and datetimes for equality with respect to timezones.
        default: True
    check_timedelta_unit : bool, optional
        Checks timedeltas for equality with respect to their unit (us, ns, ...).
        default: True
    check_str_encoding : bool, optional
        Checks strings for equality with respect to their encoding.
        default: True
    check_str_fixlen : bool, optional
        Checks string for equality with respect to their fixlen.
        default: True
    check_record_order : bool, optional
        Checks records for equality with respect to the order of the fields.
        default: True

    Raises
    ------
    AssertionError
        Raised when the two dshapes are not equal.
    N z
.shape[%d]zdimensions do not match:  !=    
z * r   )z.measure)	check_dimr   )shape	enumeratezipAssertionErrorlenr   mapstrr   assert_dshape_equalmeasure)
abr   r   kwargsashapebshapenadimbdims
             r   r%   r%   %   sd   B WFWF  (VV)<)<== 	 	OA|dt| q())$n "!'llQ.7 7!JJs3'7'78888!JJs3'7'7888  577 7 "$
 
 
 	KD				 	 
     r   c                   $    e Zd Zed             ZdS )Slottedc                 "    t          |d          S )N	__slots__)hasattr)clssubclss     r   __subclasshook__zSlotted.__subclasshook__g   s    v{+++r   N)__name__
__module____qualname__classmethodr6   r   r   r   r0   r0   f   s-        , , [, , ,r   r0   c                    t          |           t          |          k    rt          | |fd|i|S | j        |j        k    s*J d| j        d|j        dt          |                      |d}| j        D ]}t	          | |          t	          ||          k    slJ t          |           j                                        d|dt	          | |          dt	          ||          dt          |d|z   fz             	            d S )	Nr   zslots mismatch: r   r   r    zs do not match: .)type
_base_caser2   r   getattrr7   lower)r'   r(   r   r)   slots        r   _check_slotsrC   l   sO   Aww$q'' 5!Q44T4V444;!+%   	Q[[[)D///(       q$71d#3#33 	 	Q &&((((4    4    $#*.///	 	 	 	 r   c                 P    | |k    sJ | d|dt          |                      d S )Nr   r   )r   r'   r(   r   r)   s       r   r?   r?      s7    6;;QQQ9T???;;;;;;r   c                     t          |           t          |          k    rt          | |          S |rt          | ||           d S d S N)r>   r?   rC   )r'   r(   r   check_tzr)   s        r   r%   r%      sU    Aww$q''  !Q !Q4     ! !r   c                 0    |rt          | ||           d S d S rG   )rC   )r'   r(   r   check_timedelta_unitr)   s        r   r%   r%      s,     !Q4     ! !r   c                 .   |d}| j         |j         k    sSJ t          |           j                                        d| j         d|j         dt	          |dz                         |                    d           t          | j        |j        fi | d S )Nr   z units do not match: r   r   )z.unitz.tp)unitr>   r7   rA   r   appendr%   tprE   s       r   r%   r%      s     6QV  Q    !&&&!&&&)D:<M2N2N2N    	KKad--f-----r   c           
         |d}|r=| j         |j         k    s-J d| j         d|j         dt          |dz                         |r:| j        |j        k    s,J d| j        |j        t          |dz             fz              d S d S )Nr   zstring encodings do not match: r   r   )z	.encodingz(string fixlens do not match: %d != %d
%s)z.fixlen)encodingr   fixlen)r'   r(   r   check_str_encodingcheck_str_fixlenr)   s         r   r%   r%      s       zQZ' 	 	 	


AJJJ	$2G(H(H(H	 	 	
  x18# 	 	7!(Id\.A$B$B; 	 	 	 	 	r   c                 H    |d}|dz  }t          | j        |j        fd|i|S )Nr   )z.tyr   )r%   tyrE   s       r   r%   r%      s9     FNDqtQT??????r   c           	         | j         }|j         }t          |          t          |          k    sCJ dt          |          t          |          | j        |j        t          |          fz              |st	          |          }t	          |          }|d}t          t          ||                    D ]W\  }\  \  }}	\  }
}||
k    sJ d|||
t          |          fz              t          |	|f|dt          |          z  fz   |d| Xd S )Nz:records have mismatched field counts: %d != %d
%r != %r
%sr   z<record field name at position %d does not match: %r != %r
%sz[%s])r   check_record_order)	fieldsr"   namesr   sortedr   r    r%   repr)r'   r(   rW   r   r)   afieldsbfieldsr,   anameafieldbnamebfields               r   r%   r%      sh   hGhGw<<3w<<' 
 
FLL#g,,)D//J
 	

 
 

  "//// 1:!!2# 2# 
 
--OUF_eV ~ 	 	K5%4O 	 	 	
 		
 $u++-//1		
 	

 	
 	
 	
 	

 
r   c           	         t          | j                  t          |j                  k    sCJ dt          | j                  t          |j                  | |t          |          fz              |d}|dz  }t          t	          | j        |j                            D ]\  }\  }}t          ||fd|d|z  fz   i|  d S )Nz9tuples have mismatched field counts: %d != %d
%r != %r
%sr   )z.dshapesr   z[%d])r"   dshapesr   r   r    r%   )r'   r(   r   r)   r,   r*   r+   s          r   r%   r%      s    qy>>S^^+ 
 
E	NNC	NNAq)D//I
 	

 
 

  KD(QY	)B)BCC 
 
FF	
 	
 !%	
 		
 	
 	
 	

 
r   c           	         t          | j                  t          |j                  k    sCJ dt          | j                  t          |j                  | |t          |          fz              |d}t          t	          | j        |j                            D ]\  }\  }}t          ||fd|d|z  fz   i|  t          | j        |j        fd|dz   i| d S )Nz6functions have different arities: %d != %d
%r != %r
%sr   r   z.argtypes[%d])z.restype)r"   argtypesr   r   r    r%   restype)r'   r(   r   r)   r,   aargbargs          r   r%   r%      s'   qz??c!*oo- 
 
B
OOS__aIdOOF
 	

 
 

  $SQZ%@%@AA 
 
<D$	
 	
 1,..	
 39	
 	
 	
 	

 				  M! 	    r   )TNrG   )NT)NTT)abcr   py2helpr   	coretypesr   r   r   r	   r
   r   r   r   r   r   r   r   r%   r0   registerrC   objectr?   r   r   r   <module>rn      s         $ $ $ $ $ $                              % % %$ 
)Y= = =  =@, , , , ,nnW%% , , , gw//   0/( ff--< < < .-< 
8T
Xt,--! ! ! .-! 
)Y! ! !  !
 
%	. 	. 	. 	. 
&& "+/)-	   * 
&&@ @ @ @ 
&&
 
 
 
@ 
%
 
 
 
$ 
(H     r   