
    .i.#                        d dl Zd dlZd dlZd dlmZ d dlm	Z	 d dl
mZ d dlmZmZmZ  ej                   ej"                  ej$                  g      d        Zd Zd Zd	 Zd
 Zd Zej2                  j5                  dddgdej6                  gfdgej6                  gfdej6                  gej6                  ej6                  gfej6                  ej6                  gej6                  ej6                  gfg      d        Zej2                  j5                  dddgddd ej:                  dd       ej"                  dg      ddgddggej6                  ddigg      d        Zd Zd Z d Z!d Z"ej2                  j5                  ddd gd dg e        e       fdd gd dgd! e       fdd ej6                  gd dej6                  g e        e       fg      d"        Z#ej2                  j5                  d# ej"                  dgd$%      def ej"                  dej6                  g      def ej"                  dej6                  g      d&efg      d'        Z$d( Z%y))    N)
is_integer)IntegerArray)	Int8Dtype
Int32Dtype
Int64Dtype)paramsc                     | j                   S )zjFixture returning parametrized IntegerArray from given sequence.

    Used to test dtype conversions.
    )param)requests    k/var/www/app/trading-bot/venv/lib/python3.12/site-packages/pandas/tests/arrays/integer/test_construction.pyconstructorr      s     ==    c                  t    t        j                  dd gt                     } | d   t         j                  u sJ y )N   dtype)pdarrayr   NA)as    r   test_uses_pandas_nar      s,    
!T*,/AQ4255==r   c                    | j                   }t        j                  |       }| j                  t        j
                  d      }|r7t        j                  |t        |            }t        j                  ||       nFd}t        j                  t        |      5  t        j                  |t        |             d d d        t        j                  |       }t        j                  t	        j                  |       j                         t        |            }t        j                  ||       t        j                  |       j                         j                  d      }t	        j                  | j                               j!                  t	        j                   |j"                              }t        j                  |t        |            }t        j                  ||       y # 1 sw Y   /xY w)Nfloat)na_valuer   r   &Cannot cast NaN value to Integer dtypematchT)drop)r   r   Seriesto_numpynpnanstrtmassert_series_equalpytestraises
ValueErrorr   tolistdropnareset_indexastypetype)datausing_nan_is_nar   expectedarrresultmsgdroppeds           r   test_from_dtype_from_floatr5      sK   JJE yyH
--w-
7C3c%j1
vx06]]:S1 	-IIcU,	- yyHYYrxx~,,.c%jAF68, yy%%'333>Hhht{{}%,,RXXejj-ABGYYwc%j1F68,	- 	-s   !G''G1c                    t        j                  d| i      }|d   j                  d      }t        j                  t	        j
                  t         j                  dgt              d      }t        j                  ||       |d   j                  d      j                  }t	        j
                  t         j                  dgt              }t        j                  ||       t        ||d      D ]r  \  }}t        j                  |      rt        j                  |      r1J t        |      r||k(  sJ t        |      rQJ ||k(  sJ t        |      t        |      k(  rrJ  y )NAobjectr   r   )nameT)strict)r   	DataFramer,   r   r!   r   r   r8   r$   r%   valuesassert_numpy_array_equalzipisnullr   r-   )data_missingdfr2   r0   res         r   test_conversionsrD   8   s   	sL)	*BW^^H%Fyy255!*F;#FH68,
 W^^H%,,Fxx
&1H1FHT2 &199Q<99Q<<]6M6a= =6M67d1g%%%&r   c                  B   t        j                  g dd      } t        j                  g dd      }t        | |      }t        j                  dddt        j                  gd	      }t        j                  ||       d
}t        j                  t        |      5  t        | j                         |       d d d        t        j                  t        |      5  t        | |j                                d d d        t        j                  t        |      5  t        | j                  t              |       d d d        d}t        j                  t        |      5  t        |        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   SxY w# 1 sw Y   y xY w)Nr            int64r   FFFTboolr   rG   rH   Int64z@.* should be .* numpy array. Use the 'pd.array' function insteadr   z;__init__\(\) missing 1 required positional argument: 'mask')r!   r   r   r   r   r$   assert_extension_array_equalr&   r'   	TypeErrorr)   r,   r   )r<   maskr2   r0   r3   s        r   test_integer_array_constructorrQ   Q   s6   XXl'2F88/v>D&$'FxxAq"%%(8H##FH5
MC	y	, ,V]]_d+, 
y	, ,VT[[]+, 
y	, 1V]]5)401
HC	y	, V , ,, ,1 1 s0   E1E= F	F1E:=F	FFc                     t        j                  g dd      } t        j                  g dd      }t        | |      }|j                  | u sJ |j                  |u sJ t        | |d      }|j                  | usJ |j                  |usJ y )NrF   rJ   r   rK   rL   T)copy)r!   r   r   _data_mask)r<   rP   r2   s      r   #test_integer_array_constructor_copyrV   g   s    XXl'2F88/v>D&$'F<<6!!!<<4&$T2F<<v%%%<<t###r   za, br   c                 $   |rEt        j                  | d      }t        j                  |d      }t        j                  ||       y d}t	        j
                  t        |      5  t        j                  |d       d d d        y # 1 sw Y   y xY w)NrM   r   r   r   )r   r   r$   rN   r&   r'   r(   )r   br/   r2   r0   r3   s         r   !test_to_integer_array_none_is_nanrY   t   sm     !7+88AW-
''96]]:S1 	'HHQg&	' 	' 	's   %BBr<   foobar      ?20130101rG   )periodsrH   rI   r   c                 Z   dj                  g d      }t        j                  t        t        f|      5  t        j                  | d       d d d        t        j                  t        t        f|      5  t        j                  |        d d d        y # 1 sw Y   IxY w# 1 sw Y   y xY w)N|)z#cannot convert float NaN to integerz#cannot be converted to IntegerDtypez)invalid literal for int\(\) with base 10:zvalues must be a 1D list-likezCannot pass scalarz!int\(\) argument must be a stringr   rM   r   )	joinr&   r'   r(   rO   r   r   r   _from_sequence)r<   r3   s     r   test_to_integer_array_errorrc      s     ((	
	C 

I.c	: (
w'( 

I.c	: ,##F+, ,( (, ,s   B6B!B!B*c                 *    | t        j                  ddgd            }|j                  t               k(  sJ  | t        j                  ddgd            }|j                  t	               k(  sJ  | ddg      }|j                  t               k(  sJ y )Nr   rG   int8r   int32)r!   r   r   r   r   r   r   r2   s     r   $test_to_integer_array_inferred_dtyperh      s    1a&78F<<9;&&&1a&89F<<:<''' !Q F<<:<'''r   c                      | ddgd      }|j                   t               k(  sJ  | t        j                  ddgd      d      }|j                   t	               k(  sJ y )Nr   rG   Int8r   re   Int32)r   r   r!   r   r   rg   s     r   #test_to_integer_array_dtype_keywordrl      sW    !Qv.F<<9;&&& 1a&7wGF<<:<'''r   c                     t        j                  ddgd      } t        j                  ddgd      }t	        j
                  | |       t        j                  t        d      5  t        j                  d	dgd       d d d        t        j                  t        j                  ddgd
      d      } | j                  t               k(  sJ y # 1 sw Y   QxY w)Nr\   g       @rM   r   r   rG   z!cannot safely cast non-equivalentr   g      ?float32)r   rb   r   r   r$   rN   r&   r'   rO   r!   r   r   r2   r0   s     r   test_to_integer_array_floatrp      s    ((#s7CFxxAg.H##FH5	y(K	L ?##S#Jg>? ((
#s9-WF <<:<'''? ?s   $CCc                     t        j                  g dd      } t        j                  ddt        j                  gd      }t        j                  | |       t        j                  t        d      5  t        j                  g dd       d d d        t        j                  t        d      5  t        j                  d	d
gd       d d d        y # 1 sw Y   GxY w# 1 sw Y   y xY w)N)12NrM   r   r   rG   z,invalid literal for int\(\) with base 10: .*r   )rr   rs    z1.5z2.0)
r   rb   r   r   r   r$   rN   r&   r'   r(   ro   s     r   test_to_integer_array_strru      s    (()9IFxxAruuW5H##FH5	I
 C 	##N'BC
 
I
 C 	##UEN'BC CC C
C Cs   3C0CCC(z5bool_values, int_values, target_dtype, expected_dtypeFTrM   c                    |st        j                  |d         rld}t        j                  t        |      5   | ||       d d d        t        j                  t        |      5  t        j                  ||       d d d        y  | ||      }|j                  |k(  sJ t        j                  ||      }t        j                  ||       y # 1 sw Y   xY w# 1 sw Y   y xY wNr   r   r   )
r!   isnanr&   r'   r(   r   r   r   r$   rN   )	r   bool_values
int_valuestarget_dtypeexpected_dtyper/   r3   r2   r0   s	            r   test_to_integer_array_boolr~      s     rxxB86]]:S1 	9<8	9]]:S1 	5HHZ|4	5L9F<<>)))xx
,7H##FH5	9 	9	5s   C&CCC%zvalues, to_dtype, result_dtyperJ   r   re   c                 "   |st        j                  | d         r~d}t        j                  t        |      5  t        j                  | |       d d d        t        j                  t        |      5  t        j                  |  |              d d d        y t        j                  | |      }|j                   |       k(  sJ t        j                  |  |             }t        j                  ||       y # 1 sw Y   xY w# 1 sw Y   y xY wrw   )r!   ry   r&   r'   r(   r   rb   r   r   r   r$   rN   )r<   to_dtyperesult_dtyper/   r3   r2   r0   s          r   test_to_integer_arrayr      s     rxxr
36]]:S1 	@''h?	@]]:S1 	3HHV<>2	3((x@F<<<>)))xxln5H##FH5	@ 	@	3s   C93D9DDc                      t        j                  t        j                  ddg      d      } t        j                  t        j                  ddgt              d      }t	        j
                  ||        y )NTFrM   r   )r   r   r!   r8   r$   rN   )r0   r2   s     r   test_integer_array_from_booleanr     sN    xx$/w?HXXbhhe}F;7KF##FH5r   )&numpyr!   r&   pandasr   pandas._testing_testingr$   pandas.api.typesr   pandas.core.arraysr   pandas.core.arrays.integerr   r   r   fixturer   rb   r   r   r5   rD   rQ   rV   markparametrizer"   rY   
date_rangerc   rh   rl   rp   ru   r~   r   r    r   r   <module>r      s       ' +  ,"="=>? @
-6&2,
$ 

TQK 
"&&
"&&"&&)*
&&"&&	BFFBFF+,	'' 		j!,%
Q!Q	#q	,,&	(((C  ;
A
jl;
A6
rvv	Arvv
jlK66" $	1#W	%tZ8	1bff+	j1	1bff+		266 6r   