@@ -83,52 +83,25 @@ def test_unparseable_strings_with_dt64_dtype(self):
83
83
# test for None or an empty generator.
84
84
# test_constructor_pass_none tests None but only with the index also
85
85
# passed.
86
- (lambda : Series (), True ),
87
- (lambda : Series (None ), True ),
88
- (lambda : Series ({}), True ),
89
- (lambda : Series (()), False ), # creates a RangeIndex
90
- (lambda : Series ([]), False ), # creates a RangeIndex
91
- (lambda : Series (_ for _ in []), False ), # creates a RangeIndex
92
- (lambda : Series (data = None ), True ),
93
- (lambda : Series (data = {}), True ),
94
- (lambda : Series (data = ()), False ), # creates a RangeIndex
95
- (lambda : Series (data = []), False ), # creates a RangeIndex
96
- (lambda : Series (data = (_ for _ in [])), False ), # creates a RangeIndex
86
+ (lambda idx : Series (index = idx ), True ),
87
+ (lambda idx : Series (None , index = idx ), True ),
88
+ (lambda idx : Series ({}, index = idx ), True ),
89
+ (lambda idx : Series ((), index = idx ), False ), # creates a RangeIndex
90
+ (lambda idx : Series ([], index = idx ), False ), # creates a RangeIndex
91
+ (lambda idx : Series (( _ for _ in []), index = idx ), False ), # RangeIndex
92
+ (lambda idx : Series (data = None , index = idx ), True ),
93
+ (lambda idx : Series (data = {}, index = idx ), True ),
94
+ (lambda idx : Series (data = (), index = idx ), False ), # creates a RangeIndex
95
+ (lambda idx : Series (data = [], index = idx ), False ), # creates a RangeIndex
96
+ (lambda idx : Series (data = (_ for _ in []), index = idx ), False ), # RangeIndex
97
97
],
98
98
)
99
- def test_empty_constructor (self , constructor , check_index_type ):
99
+ @pytest .mark .parametrize ("empty_index" , [None , None ])
100
+ def test_empty_constructor (self , constructor , check_index_type , empty_index ):
100
101
# TODO: share with frame test of the same name
101
- expected = Series ()
102
- result = constructor ()
103
-
104
- assert result .dtype == object
105
- assert len (result .index ) == 0
106
- tm .assert_series_equal (result , expected , check_index_type = check_index_type )
107
-
108
- @pytest .mark .parametrize (
109
- "constructor,check_index_type" ,
110
- [
111
- # NOTE: some overlap with test_constructor_empty but that test does not
112
- # test for None or an empty generator.
113
- # test_constructor_pass_none tests None but only with the index also
114
- # passed.
115
- (lambda : Series (index = []), True ),
116
- (lambda : Series (None , index = []), True ),
117
- (lambda : Series ({}, index = []), True ),
118
- (lambda : Series ((), index = []), False ), # creates a RangeIndex
119
- (lambda : Series ([], index = []), False ), # creates a RangeIndex
120
- (lambda : Series ((_ for _ in []), index = []), False ), # creates a RangeIndex
121
- (lambda : Series (data = None , index = []), True ),
122
- (lambda : Series (data = {}, index = []), True ),
123
- (lambda : Series (data = (), index = []), False ), # creates a RangeIndex
124
- (lambda : Series (data = [], index = []), False ), # creates a RangeIndex
125
- (lambda : Series (data = (_ for _ in []), index = []), False ), # RangeIndex
126
- ],
127
- )
128
- def test_empty_constructor_with_index (self , constructor , check_index_type ):
129
- # GH 49573
130
- expected = Series ()
131
- result = constructor ()
102
+ # GH 49573 (addition of empty_index parameter)
103
+ expected = Series (index = empty_index )
104
+ result = constructor (empty_index )
132
105
133
106
assert result .dtype == object
134
107
assert len (result .index ) == 0
0 commit comments