File tree Expand file tree Collapse file tree 2 files changed +36
-7
lines changed
Expand file tree Collapse file tree 2 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ from pandas._typing import (
4949 StrDtypeArg ,
5050 TimedeltaDtypeArg ,
5151 TimestampDtypeArg ,
52+ UIntDtypeArg ,
5253 np_ndarray ,
5354 np_ndarray_anyint ,
5455 np_ndarray_bool ,
@@ -91,7 +92,7 @@ def array( # type: ignore[overload-overlap]
9192@overload
9293def array ( # type: ignore[overload-overlap]
9394 data : Sequence [int | np .integer | NAType | None ] | np_ndarray_anyint | IntegerArray ,
94- dtype : IntDtypeArg | None = None ,
95+ dtype : IntDtypeArg | UIntDtypeArg | None = None ,
9596 copy : bool = True ,
9697) -> IntegerArray : ...
9798@overload
@@ -143,12 +144,8 @@ def array( # type: ignore[overload-overlap]
143144) -> PeriodArray : ...
144145@overload
145146def array ( # type: ignore[overload-overlap]
146- data : (
147- Sequence [IntervalT | NAType | None ]
148- | IntervalIndex
149- | Series [Interval ]
150- | IntervalArray
151- ),
147+ # float("nan") also works, but I don't know how to put it in
148+ data : Sequence [IntervalT | None ] | IntervalArray | IntervalIndex | Series [Interval ],
152149 dtype : IntervalDtype | None = None ,
153150 copy : bool = True ,
154151) -> IntervalArray : ...
Original file line number Diff line number Diff line change 1+ import pandas as pd
2+ from pandas .core .arrays .interval import IntervalArray
3+ from typing_extensions import assert_type
4+
5+ from tests import check
6+
7+
8+ def test_constructor () -> None :
9+ itv = pd .Interval (0 , 1 )
10+ check (
11+ assert_type ( # type: ignore[assert-type] # I do not understand
12+ pd .array ([itv ]), IntervalArray
13+ ),
14+ IntervalArray ,
15+ )
16+ check (
17+ assert_type ( # type: ignore[assert-type] # I do not understand
18+ pd .array ([itv , None ]), IntervalArray
19+ ),
20+ IntervalArray ,
21+ )
22+
23+ check (
24+ assert_type ( # type: ignore[assert-type] # I do not understand
25+ pd .array (pd .array ([itv ])), IntervalArray
26+ ),
27+ IntervalArray ,
28+ )
29+
30+ check (assert_type (pd .array (pd .Index ([itv ])), IntervalArray ), IntervalArray )
31+
32+ check (assert_type (pd .array (pd .Series ([itv ])), IntervalArray ), IntervalArray )
You can’t perform that action at this time.
0 commit comments