1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
U
­ý°dá$ã@spdZddlZddlZddlZddlmZddl    m
Z
m Z ddl m Z mZejdddZejjGdd    „d    ƒƒZdS)
z test feather-format compat éN)ÚArrowStringArrayÚ StringArray)Ú read_featherÚ
to_featherÚpyarrowz1.0.1)Z
minversionc@s¸eZdZdd„Zdd„Zdifdd„Zdd    „Zd
d „Zd d „Zdd„Z    dd„Z
dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zejjejd d!d"d#d$„ƒƒZd%d&„Zd'd(„ZdS))Ú TestFeatherc
Cs<tj||d$t ¡}t||ƒW5QRXW5QRXdS)N©Úmatch)ÚpytestÚraisesÚtmÚ ensure_cleanr)ÚselfÚdfÚexcÚerr_msgÚpath©rúSd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/tests/io/test_feather.pyÚcheck_error_on_writes
z TestFeather.check_error_on_writec
Cs8t t¡$t ¡}t||ƒW5QRXW5QRXdS©N)r Zexternal_error_raisedÚ    Exceptionr r)rrrrrrÚcheck_external_error_on_writes 
z)TestFeather.check_external_error_on_writeNc    KsJ|dkr |}t ¡,}t||f|Žt|f|Ž}t ||¡W5QRXdSr)r r rrÚassert_frame_equal)rrÚexpectedÚ write_kwargsZ read_kwargsrÚresultrrrÚcheck_round_trip#s 
 zTestFeather.check_round_tripc    CsHd}t dddg¡ddt d¡t dddg¡fD]}| |t|¡q0dS)Nz'feather only support IO with DataFrameséééÚfooÚ20130101)ÚpdÚSeriesÚ    TimestampÚnpÚarrayrÚ
ValueError)rÚmsgÚobjrrrÚ
test_error-sûzTestFeather.test_errorcCs(t tdƒttddƒƒt dd¡ d¡tjddd    d
d tjdgd d d gd tjd gt tdƒ¡tj    ttj
dddƒddtj    ttj
ddddƒddt  d¡tj t  d¡gtj    ttj
ddddƒdddœ ¡}tj dddd|d<tjddd|d<t ddd¡|d<|jjjjdkst‚| |¡dS)NÚabcrér éÚu1g@g@Úfloat64©Údtypegð?TFr"©Úperiods)Úfreqz
US/Eastern)r4ÚtzZ20130103Úns)r4r5) ÚstringÚintZuintÚfloatZfloat_with_nullÚboolZbool_with_nullÚcatÚdtÚdttzZ dt_with_nullZdtnsZ2013ÚM)r5r4r4z1 dayZ
timedeltasrZ    intervals)r#Ú    DataFrameÚlistÚranger&ÚarangeZastypeÚnanZ CategoricalZ DatetimeIndexÚ
date_ranger%ZNaTZ period_rangeZtimedelta_rangeZinterval_ranger>r2r6ÚzoneÚAssertionErrorr©rrrrrÚ
test_basic8s@ 
 
 ÿþýÿëÿzTestFeather.test_basiccCs2tjt d¡ dd¡tdƒd ¡}| |¡dS)Né r-r Zaaa©Úcolumns)r#r@r&rCÚreshaperAÚcopyrrHrrrÚtest_duplicate_columns[s$z"TestFeather.test_duplicate_columnscCs2t t d¡ dd¡¡ ¡}d}| |t|¡dS)NrJr-r ú%feather must have string column names)r#r@r&rCrMrNrr()rrr)rrrÚtest_stringify_columnsasz"TestFeather.test_stringify_columnsc    CsPt tdƒttddƒƒtdƒttddƒƒdœ¡}ddg}|j||||d    dS)
Nr,rr-Zxyzé)Úcol1Zcol2Úcol3Zcol4rSrT)rrL)r#r@rArBr)rrrLrrrÚtest_read_columnsfs  üÿzTestFeather.test_read_columnscCsBt ddgddgddgdœ¡}|dd    g}|j||dd    gd
dS) NrrÚxÚyTF)ÚAÚBÚCrYrXrK)r#r@r)rrrrrrÚ!test_read_columns_different_orderss z-TestFeather.test_read_columns_different_ordercCs"t ddddgi¡}| |¡dS)NÚarç@)r#r@rrHrrrÚtest_unsupported_otherysz"TestFeather.test_unsupported_othercCs4t dt d¡i¡}|j|dd|j|dddS)NrXi †T)Z use_threadsF)r#r@r&rCrrHrrrÚtest_rw_use_threads~szTestFeather.test_rw_use_threadsc    CsÊt ddddgi¡}| |¡d}dddgtjdddtd    ƒdddgtj d
d d g¡fD]}||_| |t    |¡qXd ddg|_d|j_
d}| |t    |¡d ddg|_tj d
g¡|_ d}| |t    |¡dS)NrXrrr zsfeather does not support serializing .* for the index; you can \.reset_index\(\) to make the index into column\(s\)r-r"r3r,)r\r)r\r)Úbrrr!z=feather does not serialize index meta-data on a default indexrP) r#r@rrErAZ
MultiIndexÚ from_tuplesÚindexrr(ÚnamerL)rrr)rbrrrÚtest_write_with_indexƒs(
ÿ û  z!TestFeather.test_write_with_indexcCs*t ¡ ¡}t |jt¡}t ||¡dSr)r Ú makeDataFrameÚ reset_indexZround_trip_pathlibrrr©rrrrrrÚtest_path_pathlib¢s zTestFeather.test_path_pathlibcCs*t ¡ ¡}t |jt¡}t ||¡dSr)r rerfZround_trip_localpathrrrrgrrrÚtest_path_localpath§s zTestFeather.test_path_localpathcCs"t ¡ ¡}|j|ddiddS)NÚversionr)r)r rerfrrHrrrÚtest_passthrough_keywords¬s z%TestFeather.test_passthrough_keywordsúkhttps://raw.githubusercontent.com/pandas-dev/pandas/main/pandas/tests/io/data/feather/feather-0_3_1.featherT)ÚurlZcheck_before_testcCs$d}t|ƒ}t|ƒ}t ||¡dS)Nrl)rr r)rZ feather_filermrÚresrrrÚtest_http_path°s
ÿzTestFeather.test_http_pathc sòt d¡‰t tjdtjdgddtjdddgddtjdtjdgd    dtjdd
dgd    dd d dgd d d gd ddgd ddgdœ¡}|dkrÂttjd ddgtj    dƒ}ttjd dtj
gtj    dƒ}n(t ˆ d ddg¡ƒ}t ˆ d ddg¡ƒ}t   ¡4}t||ƒt d|¡t||d}W5QRXW5QRXt tjdtjdgddtjdddgddtjdtjdgd    dtjdd
dgd    dtjd d tj
gddtjd d d gdd||dœ¡‰|dkrâddlm‰t ‡‡‡fdd„ˆjDƒ¡‰t  |ˆ¡dS)Nrrr ZInt64r1rgø?g@ZFloat64r]TFr\r`Úc)r\r`rpÚdÚeÚfÚgÚhÚpythonzmode.string_storage©Ú dtype_backendÚbooleanr)ÚArrowExtensionArraycs$i|]}|ˆˆjˆ|ddƒ“qS)T)Z from_pandas)r')Ú.0Úcol©rzrÚparrÚ
<dictcomp>ðsÿz?TestFeather.test_read_feather_dtype_backend.<locals>.<dictcomp>)r
Ú importorskipr#r@r$r&rDrr'Zobject_ZNArr r rZoption_contextrZ pandas.arraysrzrLr)rZstring_storagerxrZ string_arrayZstring_array_narrrr}rÚtest_read_feather_dtype_backendÂsP
øÿ 
 
 øÿ
 þÿz+TestFeather.test_read_feather_dtype_backendc
Csfd}t dttddƒƒi¡}t d¡6}| |¡tjt    |dt
|ddW5QRXW5QRXdS)    NzPdtype_backend numpy is invalid, only 'numpy_nullable' and 'pyarrow' are allowed.r9rr-z tmp.featherrÚnumpyrw) r#r@rArBr r rr
r r(r)rr)rrrrrÚtest_invalid_dtype_backendøsÿ 
z&TestFeather.test_invalid_dtype_backend)Ú__name__Ú
__module__Ú __qualname__rrrr+rIrOrQrUr[r^r_rdrhrirkr
ÚmarkÚnetworkr rorrƒrrrrrs.
 # û
6r)Ú__doc__r‚r&r
Zpandasr#Zpandas._testingZ_testingr Zpandas.core.arraysrrZpandas.io.feather_formatrrr€rr‡Z
single_cpurrrrrÚ<module>s