403Webshell
Server IP : 209.209.40.120  /  Your IP : 216.73.217.112
Web Server : Microsoft-IIS/10.0
System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586
User : NEWWWW$ ( 0)
PHP Version : 8.3.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python312/Lib/site-packages/pandas/tests/extension/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python312/Lib/site-packages/pandas/tests/extension/__pycache__/test_sparse.cpython-312.pyc
�

/	�g[F���dZddlZddlZddlmZddlZddlmZddl	m
Zddlm
Z
ddlmZd�Zej"d��Zej"dej&g�	�d
��Zej"d��Zej"dej&g�	�d��Zej"dej&g�	�d
��Zej"dej&g�	�d��Zej"dej&g�	�d��Zej"d��Zej"dej&g�	�d��Zej"dej&g�	�d��ZGd�dej:�Zd�Zy)aj
This file contains a minimal set of tests for compliance with the extension
array interface test suite, and should contain no other tests.
The test suite for the full functionality of the array is located in
`pandas/tests/arrays/`.

The tests in this file are inherited from the BaseExtensionTests, and only
minimal tweaks should be applied to get the tests passing (by overwriting a
parent method).

Additional tests should either be added to one of the BaseExtensionTests
classes (if they are relevant for the extension interface for all dtypes), or
be added to the array-specific tests in `pandas/tests/arrays/`.

�N)�PerformanceWarning��SparseDtype)�SparseArray)�basec��tjjd�}tj|�r|j	d��}n1|jdddt��}|d|dk(r
|dxxdz
cc<||ddd�<|S)N��d)�size�)r�dtyper�)�np�random�default_rng�isnan�uniform�integers�int)�
fill_value�rng�datas   �DC:\Python312\Lib\site-packages\pandas/tests/extension/test_sparse.py�	make_datarsy��
�)�)�
�
��
"�C�	�x�x�
���{�{��{�$���|�|�A�s��C�|�8����7�d�1�g����G�q�L�G��D���A��J��K�c��t�S�Nr�rrr
r
*s
���=�r)�paramsc�Z�tt|j�|j��}|S)z*Length-100 PeriodArray for semantics test.�r)rr�param)�request�ress  rrr/s"���i��
�
�.�7�=�=�
I�C��Jrc�D�ttjd�dz�S)Nr
r	)rr�onesrrr�
data_for_twosr'6s���r�w�w�s�|�a�'�(�(rc�P�ttjdg|j��S)zLength 2 array with [NA, Valid]rr!�rr�nanr"�r#s r�data_missingr,;s�������{�w�}�}�=�=rc#� �K��fd�}|��y�w)z1Return different versions of data for count timesc3��K�t|�D].}tt�j��j�����0y�w)Nr!)�rangerrr")�count�_r#s  �r�genzdata_repeated.<locals>.genEs6������u��	R�A��i��
�
�6�7�=�=�Q�Q�	R�s�>ANr)r#r2s` r�
data_repeatedr3As�����R��I�s�c�4�tgd�|j��S)N)r	rrr!)rr"r+s r�data_for_sortingr5Ls���y�W�]�]�;�;rc�R�tdtjdg|j��S)Nr	rr!r)r+s r�data_missing_for_sortingr7Qs����2�6�6�1�~�'�-�-�@�@rc��d�S)Nc�Z�tj|�xrtj|�Sr)�pd�isna)�left�rights  r�<lambda>zna_cmp.<locals>.<lambda>Xs��r�w�w�t�}�?������rrrrr�na_cmpr?Vs��?�?rc
�x�tddtjtjddddg|j��S)Nrr	rr!r)r+s r�data_for_groupingrA[s,����1�b�f�f�b�f�f�a��A�q�9�g�m�m�T�Trc�`�tddtjdddddddg
|j��S)Nr�������r	rr!r)r+s r�data_for_comparerF`s,����1�b�f�f�b�"�a��A�q�!�<����W�Wrc���eZdZdedefd�Zejjdddg��fd��Z	ejjdddg��fd��Z
d	�Zd
�Zejjd�ejjdd
dgejj!ddgddg��g�ejjdddg��fd����Z�fd�Z�fd�Z�fd�Z�fd�Z�fd�Z�fd�Zd�Z�fd�Zd�Z�fd�Z�fd �Zejj;d!�"��fd#��Zd$�Zd%Z d&�Z!d'�Z"ejj;d(�"��fd)��Z#d*�Z$�fd+�Z%d,�Z&ejjd-d.d/g��fd0��Z'ejjPejjd1ejRejTejVg��fd2���Z,ejjP�fd3��Z-ejjd4d5�d6e.d7e/j`g�fd8�d9e.d7e/j`g�fed6e.d:d;gd;�<�fed9e.d:e/j`g�fg�d=��Z1ejjd>d6d9g�d?��Z2ejj;e3d@�A��fdB��Z4d6Z5d6Z6d6Z7d6Z8dC�Z9�fdD�Z:�fdE�Z;�fdF�Z<dGejTdHe.fdI�Z=dHe.fdJ�Z>dHe.fdK�Z?dHe.fdL�Z@ejj;dM�"��fdN��ZAejj;dO�"�ejjdPddg��fdQ���ZB�xZCS)R�TestSparseArray�op_name�returnc��y)NTr)�self�objrIs   r�_supports_reductionz#TestSparseArray._supports_reductionfs��r�skipnaTFc�\��|dvr<tjjd��}|jj	|�nZ|dvrV|j
jdk(r=|s;tjjd��}|jj	|�t�|�!|||�y)N��prod�median�var�std�sem�skew�kurt�,This should be viable but is not implemented��reason��sum�max�min�mean�fzgetting a non-nan float)	�pytest�mark�xfail�node�
add_markerr
�kind�super�test_reduce_series_numeric�rLr�all_numeric_reductionsrOr#rc�	__class__s      �rriz*TestSparseArray.test_reduce_series_numericis����!�&
�
��;�;�$�$�E�%��D�
�L�L�#�#�D�)�"�&C�C��
�
���3�&���;�;�$�$�,E�$�F�D��L�L�#�#�D�)�
��*�4�1G��Prc�\��|dvr<tjjd��}|jj	|�nZ|dvrV|j
jdk(r=|s;tjjd��}|jj	|�t�|�!|||�y)NrQrYrZr\raz$ExtensionArray NA mask are different)	rbrcrdrerfr
rgrh�test_reduce_framerjs      �rrnz!TestSparseArray.test_reduce_frame�s����!�&
�
��;�;�$�$�E�%��D�
�L�L�#�#�D�)�"�&C�C��
�
���3�&���;�;�$�$�,R�$�S�D��L�L�#�#�D�)�
��!�$�(>��Grc�j�|jttd�k(rtjd�yy)NrzCan't store nan in int array.)r
rrrb�skip�rLrs  r�_check_unsupportedz"TestSparseArray._check_unsupported�s'���:�:��S�!�,�,��K�K�7�8�-rc��tjd|ddi�}tjdgd�i�}tjdgd�i�jd�}|||g}tj|�}tj|D�cgc]}|j	d����c}�}tj||�ycc}w)N�Ar)rr	r)�a�b�c�categoryc�R�tj|�jt�Sr)r�asarray�astype�object)�ss rr>z:TestSparseArray.test_concat_mixed_dtypes.<locals>.<lambda>�s��r�z�z�!�}�3�3�F�;�r)r:�	DataFramer{�concat�apply�tm�assert_frame_equal)	rLr�df1�df2�df3�dfs�result�x�expecteds	         r�test_concat_mixed_dtypesz(TestSparseArray.test_concat_mixed_dtypes�s����l�l�C��b�q��?�+���l�l�C��+�,���l�l�C��1�2�9�9�*�E���C��o�����3����9�9�FI�J��Q�W�W�;�
<�J�
��	���f�h�/��
Ks�	Cz9ignore:The previous implementation of stack is deprecated�columnsrt�B)rtru)rtrv�outer�inner)�names�future_stackc�(��t�|�|||�yr)rh�
test_stack)rLrr�r�rls    �rr�zTestSparseArray.test_stack�s���	���4��,�7rc�H��|j|�t�|�	||�yr)rrrh�test_concat_columns�rLr�na_valuerls   �rr�z#TestSparseArray.test_concat_columns�s �������%�
��#�D�(�3rc�H��|j|�t�|�	||�yr)rrrh�'test_concat_extension_arrays_copy_falser�s   �rr�z7TestSparseArray.test_concat_extension_arrays_copy_false�s �������%�
��7��h�Grc�H��|j|�t�|�	||�yr)rrrh�
test_alignr�s   �rr�zTestSparseArray.test_align�� �������%�
���4��*rc�H��|j|�t�|�	||�yr)rrrh�test_align_framer�s   �rr�z TestSparseArray.test_align_frame�s �������%�
�� ��x�0rc�H��|j|�t�|�	||�yr)rrrh�test_align_series_framer�s   �rr�z'TestSparseArray.test_align_series_frame�s �������%�
��'��h�7rc�H��|j|�t�|�	||�yr)rrrh�
test_merger�s   �rr�zTestSparseArray.test_merge�r�rc���tj|tt|��D�cgc]}d|z��	c}��}t	j
|jj�rHt	j
|jd��r"t	j
|jd�s%J�|jd�|jdk(sJ�|jd�|jdk(sJ�ycc}w)Nr	)�indexrEr)
r:�Seriesr/�lenrr�valuesr�get�iloc)rLr�i�sers    r�test_getzTestSparseArray.test_get�s����i�i��E�#�d�)�4D�$E�q�Q��U�$E�F��
�8�8�C�J�J�)�)�*��8�8�C�G�G�A�J�'�B�H�H�S�X�X�a�[�,A�A�A��7�7�1�:����!��,�,�,��w�w�q�z�S�X�X�a�[�(�(�(��%Fs�C3
c�H��|j|�t�|�	||�yr)rrrh�test_reindexr�s   �rr�zTestSparseArray.test_reindex�s �������%�
���T�8�,rc���t|�}tttj|j
j��}tddg|��}|j	�}tj||�|jd�}tttj|j
j��}tddgd|��}tj|j	�|�y)NTF�r
r�rr
)rr�boolr:r;r
rr��assert_sp_array_equal�fillna�assert_equal)rLr,�sarr�expected_dtyper�r�s      r�	test_isnazTestSparseArray.test_isna�s����<�(��$�T�2�7�7�<�3E�3E�3P�3P�+Q�R����e�}�N�C�������
� � ���2��{�{�1�~��$�T�2�7�7�<�3E�3E�3P�3P�+Q�R����u�~�%�~�V��
����	�	��X�.rc���ttf}tj|d��5t�|�|�ddd�y#1swYyxYw�NF)�check_stacklevel)r�
FutureWarningr��assert_produces_warningrh�test_fillna_limit_backfill)rLr,�warnsrls   �rr�z*TestSparseArray.test_fillna_limit_backfill�s?���#�]�3��
�
'�
'���
F�	=��G�.�|�<�	=�	=�	=�s	�>�Ac���tj|j�r/|jtj
j
d���t�|�!|�y)Nz'returns array with different fill valuerZ)	rrr�applymarkerrbrcrdrh�test_fillna_no_op_returns_copy)rLrr#rls   �rr�z.TestSparseArray.test_fillna_no_op_returns_copy�sF���
�8�8�D�O�O�$�������!�!�)R�!�S�
�	��.�t�4r�UnsupportedrZc�"��t�|��yr)rh�test_fillna_series�rLr,rls  �rr�z"TestSparseArray.test_fillna_series�s���
	��"�$rc�j�|d}tj|ddgd��j|�}tj|j�rt|j|�}n|j}tj|j||g|��ddgd��}tj||�y)Nrr	)rtr�r�)
r:r~r�r;rrr
�_from_sequencer�r�)rLr,rr�r
r�s      r�test_fillna_framez!TestSparseArray.test_fillna_frames���!�!�_�
����L��1�v�>�?�F�F�z�R��
�7�7�<�*�*�+��� 2� 2�J�?�E� �&�&�E��<�<�!�0�0�*�j�1I�QV�0�W���V�
�
��	���f�h�/rzSparse[bool]c���|jddg�}tjd|id��}|jd}|j	|�}t|jd�r^|r.|jj|jjus0J�|jj|jjusJ�|jjj�|j�usJ�y)NrrtF��copy)rr�blocks)�taker:r~r�r��hasattr�_mgrr�rrt�_values�to_dense)rLr,�using_copy_on_write�arr�df�
filled_valr�s       r�test_fillna_copy_framez&TestSparseArray.test_fillna_copy_frames�������A��'��
�\�\�3��*�5�
1���W�W�T�]�
����:�&���2�7�7�H�%�"��y�y�~�~����);�);�;�;�;��y�y�~�~�V�]�]�-?�-?�?�?�?��t�t�|�|�$�$�&�#�,�,�.�8�8�8rc�H�|jddg�}tj|d��}|d}|j|�}|r|j|jusJ�|j|jusJ�|jj�|j�usJ�y)NrFr�r)r�r:r�r�r�r�)rLr,r�r�r�r�r�s       r�test_fillna_copy_seriesz'TestSparseArray.test_fillna_copy_series&s�������A��'���i�i��%�(����V�
����J�'����;�;�&�.�.�0�0�0��;�;�f�n�n�4�4�4��{�{�#�#�%�����7�7�7rzNot Applicablec�$��t�|�|�yr)rh�test_fillna_length_mismatchr�s  �rr�z+TestSparseArray.test_fillna_length_mismatch4s���
��+�L�9rc��|d|dk7sJ�t|�}|dd\}}tj|j||||g|j���}tjgd��}|j|�}tdd�}	tj|j||||g|	���}
tj||
�|j||||g|j��}tjgd��}|j||�}tj|j||||g|j���}
tj||
�y)	Nrrr	r�)TTFF�floatg)TFTT)�typer:r�r�r
r�array�whererr��assert_series_equal)rLrr��clsrurvr��condr��	new_dtyper��others            r�test_where_seriesz!TestSparseArray.test_where_series8s8���A�w�$�q�'�!�!�!��4�j���B�Q�x���1��i�i��*�*�A�q�!�Q�<�t�z�z�*�J�K���x�x�2�3�����4������-�	��9�9�����1�h��9���K�
��	���v�x�0��"�"�A�q�!�Q�<�t�z�z�"�B���x�x�1�2�����4��'���9�9�S�/�/��A�q�!��D�J�J�/�O�P��
���v�x�0rc���tjtd��5t�|�||�ddd�y#1swYyxYwr�)r�r�rrh�test_searchsorted)rLr5�	as_seriesrls   �rr�z!TestSparseArray.test_searchsortedNs=���
�
'�
'�(:�U�
S�	C��G�%�&6�	�B�	C�	C�	C�s	�7�Ac��|jd�}|jd|jd<|jd|jdk7sJ�y)Nrr)�shift�_sparse_values)rLrr�s   r�test_shift_0_periodsz$TestSparseArray.test_shift_0_periodsRsN�����A���!%�!4�!4�Q�!7����A���$�$�Q�'�6�+@�+@��+C�C�C�Cr�method�argmax�argminc�J��|j|�t�|�	|||�yr)rrrh�test_argmin_argmax_all_na)rLr�rr�rls    �rr�z)TestSparseArray.test_argmin_argmax_all_naYs$���	
����%�
��)�&�$��Ar�boxc�L��|j|�t�|�	||||�yr)rrrh�test_equals)rLrr�r�r�rls     �rr�zTestSparseArray.test_equals_s&���	
����%�
���D�(�I�s�;rc�$��t�|�|�yr)rh�&test_equals_same_data_different_object)rLrrls  �rr�z6TestSparseArray.test_equals_same_data_different_objectes���
��6�t�<rzfunc, na_action, expectedc��|Srr�r�s rr>zTestSparseArray.<lambda>l���q�rNg�?c��|Srrr�s rr>zTestSparseArray.<lambda>mr�r�ignorez1.0r*r!c��tdtjg�}|j||��}t	j
||�y)Nr��	na_action)rrr*�mapr��assert_extension_array_equal)rL�funcr�r�rr�s      r�test_mapzTestSparseArray.test_mapis8���A�r�v�v�;�'�����$�)��4��
�'�'���9rr�c��d}tjt|��5|jd�|��ddd�y#1swYyxYw)Nz-fill value in the sparse values not supported)�matchc�"�tjSr)rr*r�s rr>z1TestSparseArray.test_map_raises.<locals>.<lambda>}s
��r�v�v�rr�)rb�raises�
ValueErrorr�)rLrr��msgs    r�test_map_raiseszTestSparseArray.test_map_raisesxs=��>��
�]�]�:�S�
1�	<��H�H�%��H�;�	<�	<�	<�s	�<�Azno sparse StringDtype)rr[c�$��t�|�|�yr)rh�test_astype_string)rLr�nullable_string_dtyperls   �rrz"TestSparseArray.test_astype_strings���	��"�4�(rc�N�|jdk(rtjd�yy)Nrz=Incorrected expected from Series.combine and tested elsewhere)rrbrprqs  r�_skip_if_different_combinez*TestSparseArray._skip_if_different_combine�s"���?�?�a��
�K�K�W�X�	 rc�H��|j|�t�|�	||�yr)rrh�test_arith_series_with_scalar�rLr�all_arithmetic_operatorsrls   �rrz-TestSparseArray.test_arith_series_with_scalar�s!����'�'��-�
��-�d�4L�Mrc�H��|j|�t�|�	||�yr)rrh�test_arith_series_with_arrayrs   �rrz,TestSparseArray.test_arith_series_with_array�s!����'�'��-�
��,�T�3K�Lrc����|jjdk7rnD|jd�dvr1tjjd��}|j
|�t�|�!||�y)Nrr1)�mul�rmul�floordiv�	rfloordiv�pow�mod�rmodz result dtype.fill_value mismatchrZ)	r
r�striprbrcrdr�rh�test_arith_frame_with_scalar)rLrrr#rcrls     �rrz,TestSparseArray.test_arith_frame_with_scalar�sh����:�:� � �A�%��
%�
+�
+�C�
0�9
�
��;�;�$�$�,N�$�O�D�����%�
��,�T�3K�Lrr�rFc���|}|||�}t|tj�r8t|tj�sJ�t|jt�sJ�t|t
�sJ�|jjtjk(sJ�t|tj�rl||j|jj�}t||j�tj|��|tj��}n�tj|tj|j�tj|���}t||j�tj|��|tj��}t|tj�rtj|�}tj||�y)Nr�)�
isinstancer:r�r
rr�subtyper�bool_rr�r�rz�allr�r�)	rLr�rF�
comparison_opr��opr�rr�s	         r�_compare_otherzTestSparseArray._compare_other�sf�����$�e�,���e�R�Y�Y�'��f�b�i�i�0�0�0��f�l�l�K�8�8�8��f�k�2�2�2��|�|�#�#�r�x�x�/�/�/��e�R�Y�Y�'��,�7�7����9Q�9Q�R�J�"��#�,�,�.��
�
�5�0A�B�%��h�h��H�����2�:�:�.�9�9�:�B�J�J�u�<M�N��J�#��#�,�,�.��
�
�5�0A�B�%��h�h��H�
�e�R�Y�Y�'��y�y��*�H�
�����)rc���tj|�}|j|||d�|j|||d�|j|||d�|j|||tj�y)NrrrD)r:r�r&rr*)rLrFr$r�s    r�test_scalarzTestSparseArray.test_scalar�si���i�i�(�)�����C�!1�=�!�D����C�!1�=�!�D����C�!1�=�"�E����C�!1�=�"�&�&�Irc�4�|jjdk(r?|jdvr1tjjd��}|j
|�tjddd�}tj|�}|j||||�y)Nr)�eq�ge�le�Wrong fill_valuerZ�����
)r
r�__name__rbrcrdr�r�linspacer:r�r&)rLrFr$r#rcr�r�s       r�
test_arrayzTestSparseArray.test_array�s����!�!�,�,��1�m�6L�6L�Q
�7
�
�;�;�$�$�,>�$�?�D�����%��k�k�"�a��$���i�i�(�)�����C�!1�=�#�Frc�D�|jjdk(r@|jdk7r1tjjd��}|j
|�tj|�}|dz}|j||||�|dz}|j||||�y)Nr�gtr-rZrr	)
r
rr1rbrcrdr�r:r�r&)rLrFr$r#rcr�r�s       r�test_sparse_arrayz!TestSparseArray.test_sparse_array�s����!�!�,�,��1�m�6L�6L�PT�6T��;�;�$�$�,>�$�?�D�����%��i�i�(�)����"�����C�!1�=�#�F���"�����C�!1�=�#�FrzDifferent reprc�&��t�|�||�yr)rh�test_array_repr)rLrrrls   �rr8zTestSparseArray.test_array_repr�s���
����d�+rzresult does not match expected�as_indexc�&��t�|�||�yr)rh�test_groupby_extension_agg)rLr9rArls   �rr;z*TestSparseArray.test_groupby_extension_agg�s���	��*�8�5F�Gr)Dr1�
__module__�__qualname__�strr�rNrbrc�parametrizerirnrrr��filterwarningsr:�
MultiIndex�from_tuplesr�r�r�r�r�r�r�r�r�r�r�r�rdr�r��_combine_le_expected_dtyper�r�r�r�r�r�r��fails_arm_wheelsr�r�r~r�r�rrr*rr	�	TypeErrorr�series_scalar_exc�frame_scalar_exc�
divmod_exc�series_array_excrrrrr&r(r3r6r8r;�
__classcell__)rls@rrHrHes���������[�[���X��e�}�5�Q�6�Q�0�[�[���X��e�}�5�H�6�H�09�
0��[�[���C���[�[����
�#�J��M�M�%�%��Z�(��'�0B�
&�
�	
���[�[���^�d�E�]�;�8�<���8�4�H�+�1�8�+�)�-�/�=�
5��[�[���m��,�%�-�%�0�("0��9�8��[�[���.��/�:�0�:�1�,C�D��[�[���X��(�';�<�B�=�B�
�[�[�!�!��[�[���U�R�X�X�r�y�y�"�,�,�$G�H�<�I�"�<��[�[�!�!�=�"�=��[�[���#�
�$��S�"�&�&�M� :�;�
�(�K��b�f�f�
�$>�?�
�$��U�E�N�u�E�F�
�(�K������8�9�		
��:��:��[�[���[�4��*:�;�<�<�<��[�[���i�0G��H�)�I�)�
�����J���Y�N�M�M� "*��9�9�"*�0;�"*�HJ�K�J�G�;�G�	G�+�	G��[�[���.��/�,�0�,��[�[���>��?��[�[���Z�$���7�H�8�@�HrrHc�4�|j�tusJ�yr)�construct_array_typerr�s r�test_array_type_with_argrM�s���%�%�'�;�6�6�6r) �__doc__�numpyrrb�
pandas.errorsr�pandasr:r�pandas._testing�_testingr��
pandas.arraysr�pandas.tests.extensionrr�fixturer
r*rr'r,r3r5r7r?rArF�ExtensionTestsrHrMrrr�<module>rXs���� �
�,����%�'�
������������2�6�6�{�#��$�����)��)������2�6�6�{�#�>�$�>�
�����2�6�6�{�#��$�������2�6�6�{�#�<�$�<������2�6�6�{�#�A�$�A����@��@������2�6�6�{�#�U�$�U������2�6�6�{�#�X�$�X�NH�d�)�)�NH�b7r

Youez - 2016 - github.com/yon3zu
LinuXploit