L i" UddlmZddlmZddlmZmZmZmZddl m Z m Z m Z m Z mZmZmZmZmZmZddlmZmZmZddlmZer5ddlmZmZddlmZmZdd l m!Z!dd lm"Z"m#Z#dd l$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*eZ+d e,d <gdZ-Gddee e fZ.Gdde.e e fee e fZ/Gdde.e efee eefZ0Gdde/eefeeeeeefZ1y)) annotations)partial) TYPE_CHECKINGAnyProtocoloverload) CompliantExprTCompliantFrameTCompliantLazyFrameTDepthTrackingExprTEagerDataFrameT EagerExprTEagerSeriesT_co LazyExprT NativeFrameT NativeSeriesT)exclude_column_namesget_column_namespassthrough_column_names)is_numpy_array_2d)IterableSequence) TypeAliasTypeIs)CompliantSelectorNamespace)ImplementationVersion) ConcatMethod Into1DArray IntoDType IntoSchemaNonNestedLiteral_2DArrayr Incomplete)CompliantNamespaceDepthTrackingNamespaceEagerNamespace LazyNamespaceceZdZUded<ded<eddZddZddZddZdd Z dd Z dd Z dd Z dd Z ddZddZddZddZ d dZ d!dZed"dZddZd#dZd$dZy)%r%r_implementationr_versioncyNselfs c/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/narwhals/_compliant/namespace.py_exprzCompliantNamespace._expr8s-0cD|jjt|SNcontextr2from_column_namesrr/s r1allzCompliantNamespace.all;zz++,#zz++,DU,KUY+ZZr3cZ|jjtt||SN)r?r6r2r9rrr>s r1excludezCompliantNamespace.excludeA+zz++ ( 6,  r3c:|jj|d|iS)Nr7)r2from_column_indices)r0indicess r1nthzCompliantNamespace.nthFs-tzz--wEEEr3cyr-r.r/s r1lenzCompliantNamespace.lenIr3cyr-r.)r0valuedtypes r1litzCompliantNamespace.litJrMr3cyr-r.r0 ignore_nullsexprss r1all_horizontalz!CompliantNamespace.all_horizontalKr3cyr-r.rSs r1any_horizontalz!CompliantNamespace.any_horizontalNrWr3cyr-r.r0rUs r1sum_horizontalz!CompliantNamespace.sum_horizontalQrMr3cyr-r.r[s r1mean_horizontalz"CompliantNamespace.mean_horizontalRrMr3cyr-r.r[s r1min_horizontalz!CompliantNamespace.min_horizontalSrMr3cyr-r.r[s r1max_horizontalz!CompliantNamespace.max_horizontalTrMr3cyr-r.)r0itemshows r1concatzCompliantNamespace.concatUsr3cyr-r.)r0 separatorrTrUs r1 concat_strzCompliantNamespace.concat_strXrWr3cyr-r.r/s r1 selectorszCompliantNamespace.selectors[sADr3cyr-r.r[s r1coalescezCompliantNamespace.coalesce]rMr3cyr-r.r0datas r1 from_nativezCompliantNamespace.from_native_rMr3cy)z6Return `True` if `obj` can be passed to `from_native`.Nr.r0objs r1 is_nativezCompliantNamespace.is_native`s r3N)returnztype[CompliantExprT])rvr )r?strrvr )rIz Sequence[int]rvr )rOr"rPzIntoDType | Nonervr )rUr rTboolrvr )rUr rvr )rdzIterable[CompliantFrameT]rerrvr )rUr rhrwrTrxrvr )rvz$CompliantSelectorNamespace[Any, Any])rprrvr)rtrrvz TypeIs[Any])__name__ __module__ __qualname____annotations__propertyr2r:r@rErJrLrQrVrYr\r^r`rbrfrirkrmrqrur.r3r1r%r%3s## 00L[ F)Z$48 $48 LLKK.8D $14DH DDE3 r3r%c$eZdZddZddZddZy)r&cD|jjt|Sr5r8r/s r1r:zDepthTrackingNamespace.allir;r3cN|jjt||Sr5r=r>s r1r@zDepthTrackingNamespace.collrAr3cZ|jjtt||SrCrDr>s r1rEzDepthTrackingNamespace.excludeorFr3N)rvr )r?rwrvr )ryrzr{r:r@rEr.r3r1r&r&esL[ r3r&c@eZdZeddZeddZddZd dZy) r(c6|jjSr-r*_backend_versionr/s r1rzLazyNamespace._backend_versiony##4466r3cyr-r.r/s r1 _lazyframezLazyNamespace._lazyframe}s7:r3c8|jj|Sr-)r _is_nativerss r1ruzLazyNamespace.is_natives))#..r3c|jj|r|jj||Sdt|j}t |Nr6zUnsupported type: )rrrqtypery TypeErrorr0rpmsgs r1rqzLazyNamespace.from_nativesO ?? % %d +??..tT.B B"4:#6#6"9:nr3Nrvztuple[int, ...])rvztype[CompliantLazyFrameT])rtrrvzTypeIs[NativeFrameT])rpzNativeFrameT | Anyrvr )ryrzr{r}rrrurqr.r3r1r(r(us077::/r3r(c.eZdZeddZeddZeddZ d ddZ d ddZddZ e ddZ e dd Z dd Z e ddd Z e dd Z d dd Z d dZ d!dZd dZ d"dZy)#r'c6|jjSr-rr/s r1rzEagerNamespace._backend_versionrr3cyr-r.r/s r1 _dataframezEagerNamespace._dataframes36r3cyr-r.r/s r1_serieszEagerNamespace._seriess03r3Ncyr-r.)r0whenthen otherwises r1 _if_then_elsezEagerNamespace._if_then_elses r3c dfd }jj|tddtddS)Nc|j}|j}|j }2|||\}}j|j|j}3|||\}}j|j|j}nP|j}||||\}}}j|j|j|j}|j |gSr-)_evaluate_single_output_expr_align_full_broadcastrnative _with_native) df predicate_salignthen_sresult otherwise_sr predicater0rs r1funcz&EagerNamespace.when_then..funcs99)DK55E44T:F &+K&@# V++K,>,> N &+K&@# V++K,>,> N ==iH 38fk3Z0 V[++&& {7I7I''/0 0r3_evaluate_output_namescdgS)Nliteralr.)_dfs r1z*EagerNamespace.when_then..sYKr3_alias_output_names)revaluate_output_namesalias_output_namesr7)rr rvzSequence[EagerSeriesT_co])r2_from_callablegetattr)r0rrrrs```` r1 when_thenzEagerNamespace.when_thensQ 1 1(zz((").0G# 't-BDI )  r3cr|jj|xs|jj|Sr-)rrrrss r1ruzEagerNamespace.is_natives+))#.N$,,2I2I#2NNr3cyr-r.ros r1rqzEagerNamespace.from_nativesEHr3cyr-r.ros r1rqzEagerNamespace.from_nativesFIr3c(|jj|r|jj||S|jj|r|jj||Sdt |j }t |r)rrrqrrryrrs r1rqzEagerNamespace.from_natives} ?? % %d +??..tT.B B << " "4 (<<++D$+? ?"4:#6#6"9:nr3cyr-r.r0rpschemas r1 from_numpyzEagerNamespace.from_numpysWZr3cyr-r.rs r1rzEagerNamespace.from_numpysr3ct|r|jj|||S|jj||S)N)rr7r6)rrrrrs r1rzEagerNamespace.from_numpysB T "??--d64-P P||&&tT&::r3cyr-r.r0dfss r1_concat_diagonalzEagerNamespace._concat_diagonalrMr3cyr-r.rs r1_concat_horizontalz!EagerNamespace._concat_horizontalsr3cyr-r.rs r1_concat_verticalzEagerNamespace._concat_verticalrMr3c|Dcgc]}|j}}|dk(r|j|}n4|dk(r|j|}n|dk(r|j|}nt|j j ||Scc}w)N horizontalverticaldiagonalr6)rrrrNotImplementedErrorrrq)r0rdreitemrrs r1rfzEagerNamespace.concats(--tt{{-- , ,,S1F J **3/F J **3/F% %**64*@@.sBr)rvztype[EagerDataFrameT])rvztype[EagerSeriesT_co]r-)rrrrrzNativeSeriesT | Nonervr)rrrrrzEagerExprT | Nonervr)rtrrvz$TypeIs[NativeFrameT | NativeSeriesT])rprrvr )rprrvr)rpz"NativeFrameT | NativeSeriesT | Anyrv!EagerDataFrameT | EagerSeriesT_co).)rNonerprrvr)r!IntoSchema | Sequence[str] | Nonerpr#rvr )rrrpzInto1DArray | _2DArrayrvr)rzSequence[NativeFrameT]rvr)rzSequence[NativeFrameT | Any]rvr)rdzIterable[EagerDataFrameT]rerrvr )ryrzr{r}rrrrrrurrqrrrrrfr.r3r1r'r'sl7766 33 +/ (   W[ # +5 BS  @OHH II6 *ZZ )J 59 ;2 ;$; + ;T/ T A. A8D A  Ar3r'N)2 __future__r functoolsrtypingrrrrnarwhals._compliant.typingr r r r r rrrrrnarwhals._utilsrrrnarwhals.dependenciesrcollections.abcrrtyping_extensionsrrnarwhals._compliant.selectorsrrrnarwhals.typingrrr r!r"r#r$r|__all__r%r&r(r'r.r3r1rs"99    423H7 J  / />"AB/ d  (::; _0 01  *I56 )\ 9:(fA?J67 _oz< VWfAr3