@@ -102,7 +102,8 @@ def test_ewma_with_times_equal_spacing(halflife_with_times, times, min_periods):
102
102
tm .assert_frame_equal (result , expected )
103
103
104
104
105
- def test_ewma_with_times_variable_spacing (tz_aware_fixture , unit ):
105
+ def test_ewma_with_times_variable_spacing (tz_aware_fixture , unit , adjust ):
106
+ #GH 54328
106
107
tz = tz_aware_fixture
107
108
halflife = "23 days"
108
109
times = (
@@ -112,8 +113,11 @@ def test_ewma_with_times_variable_spacing(tz_aware_fixture, unit):
112
113
)
113
114
data = np .arange (3 )
114
115
df = DataFrame (data )
115
- result = df .ewm (halflife = halflife , times = times ).mean ()
116
- expected = DataFrame ([0.0 , 0.5674161888241773 , 1.545239952073459 ])
116
+ result = df .ewm (halflife = halflife , times = times , adjust = adjust ).mean ()
117
+ if adjust :
118
+ expected = DataFrame ([0.0 , 0.5674161888241773 , 1.545239952073459 ])
119
+ else :
120
+ expected = DataFrame ([0.0 , 0.23762518642226227 , 1.534926369128742 ])
117
121
tm .assert_frame_equal (result , expected )
118
122
119
123
@@ -148,13 +152,33 @@ def test_ewm_getitem_attributes_retained(arg, adjust, ignore_na):
148
152
assert result == expected
149
153
150
154
151
- def test_ewma_times_adjust_false_raises ():
152
- # GH 40098
155
+ def test_ewma_times_adjust_false_with_disallowed_com ():
156
+ # GH 54328
157
+ with pytest .raises (
158
+ NotImplementedError , match = 'None of com, span, or alpha can be specified if times is provided and adjust=False'
159
+ ):
160
+ Series (range (1 )).ewm (
161
+ 0.1 , adjust = False , times = date_range ("2000" , freq = "D" , periods = 1 ), halflife = '1D'
162
+ )
163
+
164
+
165
+ def test_ewma_times_adjust_false_with_disallowed_alpha ():
166
+ # GH 54328
167
+ with pytest .raises (
168
+ NotImplementedError , match = 'None of com, span, or alpha can be specified if times is provided and adjust=False'
169
+ ):
170
+ Series (range (1 )).ewm (
171
+ 0.1 , adjust = False , times = date_range ("2000" , freq = "D" , periods = 1 ), alpha = 0.5 , halflife = '1D'
172
+ )
173
+
174
+
175
+ def test_ewma_times_adjust_false_with_disallowed_span ():
176
+ # GH 54328
153
177
with pytest .raises (
154
- NotImplementedError , match = " times is not supported with adjust=False."
178
+ NotImplementedError , match = 'None of com, span, or alpha can be specified if times is provided and adjust=False'
155
179
):
156
180
Series (range (1 )).ewm (
157
- 0.1 , adjust = False , times = date_range ("2000" , freq = "D" , periods = 1 )
181
+ 0.1 , adjust = False , times = date_range ("2000" , freq = "D" , periods = 1 ), span = 10 , halflife = '1D'
158
182
)
159
183
160
184
0 commit comments