gL iQ>ddlmZddlmZddlZddlmZddlZddlm Z m Z m Z ddl Z ddl mZddlmZmZddlmZdd lmZdd lmZe rdd lmZdd lmZmZmZe dd ZeddZe d ddZ eddZ!edddZ"ddZ#ddZ$y)) annotations)contextmanagerN)Path)IO TYPE_CHECKINGAny)using_copy_on_write)PYPYWARNING_CHECK_DISABLED)ChainedAssignmentError) set_option) get_handle) Generator) BaseBufferCompressionOptionsFilePathc#pKt|d|d5}|jdddy#1swYyxYww)a& Open a compressed file and return a file object. Parameters ---------- path : str The path where the file is read from. compression : {'gzip', 'bz2', 'zip', 'xz', 'zstd', None} Name of the decompression to use Returns ------- file object rbF) compressionis_textN)rhandle)pathrrs ^/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pandas/_testing/contexts.pydecompress_filer$s6& D$K G6mms6* 636c#Kddldfd }tjjd}|| d||y#||wxYww)a Context manager for temporarily setting a timezone. Parameters ---------- tz : str A string representing a valid timezone. Examples -------- >>> from datetime import datetime >>> from dateutil.tz import tzlocal >>> tzlocal().tzname(datetime(2021, 1, 1)) # doctest: +SKIP 'IST' >>> with set_timezone('US/Eastern'): ... tzlocal().tzname(datetime(2021, 1, 1)) ... 'EST' rNctdr9| tjd=y|tjd<j yy#t$rYywxYw)NtzsetTZ)hasattrosenvironKeyErrorr)tztimes rsetTZzset_timezone..setTZSsU 4 !z 4($& 4   " sA AAr)returnNone)r$r r!get)r#r%orig_tzr$s @r set_timezoner*;sB, jjnnT"G "I  ggs2AA A A  Ac+dKttj}|d}tt j |z}||z }|j t|}|jdd}|r+|jdd| d|dvrd}t|fd|i|} |t|ts|j|jr|jyy#t|ts|j|jr|jwwxYww)az Gets a temporary path and agrees to remove on close. This implementation does not use tempfile.mkstemp to avoid having a file handle. If the code using the returned path wants to delete the file itself, windows requires that no program has a file handle to it. Parameters ---------- filename : str (optional) suffix of the created file. return_filelike : bool (default False) if True, returns a file-like which is *always* cleaned. Necessary for savefig and other functions which want to append extensions. **kwargs Additional keywords are passed to open(). Nencodingmodezw+bbzutf-8)rtempfile gettempdirstruuiduuid4touchpop setdefaultopen isinstancecloseis_fileunlink)filenamereturn_filelikekwargsfolderr handle_or_strr-s r ensure_cleanrBfs ,(%%' (F4::< 8+H H DJJL!$iMzz*d+H&%(  6&> 9HT?H?? --    ! <<> KKM --    ! <<> KKM s B!D0$C*(AD0*AD--D0c+Kddl}hd}||vr td|j|fi| d|j|y#|j|wxYww)au Context manager to temporarily register a CSV dialect for parsing CSV. Parameters ---------- name : str The name of the dialect. kwargs : mapping The parameters for the dialect. Raises ------ ValueError : the name of the dialect conflicts with a builtin one. See Also -------- csv : Python's CSV library. rN> excel-tabunixexcelz Cannot override builtin dialect.)csv ValueErrorregister_dialectunregister_dialect)namer?rG_BUILTIN_DIALECTSs rwith_csv_dialectrMs_(6   ;<<C((%  t$t$s+AAAAAc#Kddlm}| |j}|j}|j}t d|||_ d||_t d|y#||_t d|wxYww)Nr) expressionszcompute.use_numexpr)pandas.core.computationrO _MIN_ELEMENTS USE_NUMEXPRr )use min_elementsexprolduseoldmins r use_numexprrXst;))   F   F$c*%D2 #(&1$(&1sAA3AA3A00A3c0ddlm}|s ddlm}|Stst r|s ddlm}|Stst r|r||dj |Str t}d}nt}d}|r|g|}||dj |g|S)Nrassert_produces_warning nullcontext|)matchzYA value is trying to be set on a copy of a DataFrame or Series through chained assignmentr ) pandas._testingr[ contextlibr]r r joinr r FutureWarning)warnextra_warnings extra_matchr[r]warningr_s rraises_chained_assignment_errorrhs7 *} &*} (n& ((;'   ,G-  $G,E 00G& ((E0K01  c ^ddlm}|rtr ddlm}|S|sd}|t fd|i|S)aq Assert that a warning is raised in the CoW warning mode. Parameters ---------- warn : bool, default True By default, check that a warning is raised. Can be turned off by passing False. match : str The warning message to match against, if different from the default. kwargs Passed through to assert_produces_warning rrZr\zSetting a value on a viewr_)r`r[r rar]rc)rdr_r?r[r]s rassert_cow_warningrks58 )*} + "= H H HHri)rzFilePath | BaseBufferrrr&z Generator[IO[bytes], None, None])r#r2r&Generator[None, None, None])NF)r>boolr?rr&zGenerator[Any, None, None])rKr2r&rl)N)r&rl)Trn)TN)% __future__rrarr pathlibrr0typingrrrr3pandas._configr pandas.compatr r pandas.errorsr pandasr pandas.io.commonrcollections.abcrpandas._typingrrrrr*rBrMrXrhrkrnrirrys"%   .1') .@%,''T+0,$(,