Skip to content

Commit f1d8a63

Browse files
committed
pre-commit style fixes
1 parent f64d32e commit f1d8a63

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ Other enhancements
4242
- :func:`DataFrame.to_excel` argument ``merge_cells`` now accepts a value of ``"columns"`` to only merge :class:`MultiIndex` column header header cells (:issue:`35384`)
4343
- :meth:`DataFrame.corrwith` now accepts ``min_periods`` as optional arguments, as in :meth:`DataFrame.corr` and :meth:`Series.corr` (:issue:`9490`)
4444
- :meth:`DataFrame.cummin`, :meth:`DataFrame.cummax`, :meth:`DataFrame.cumprod` and :meth:`DataFrame.cumsum` methods now have a ``numeric_only`` parameter (:issue:`53072`)
45+
- :meth:`DataFrame.ewm` now allows ``adjust=False`` when ``times`` is provided (:issue:`54328`)
4546
- :meth:`DataFrame.fillna` and :meth:`Series.fillna` can now accept ``value=None``; for non-object dtype the corresponding NA value will be used (:issue:`57723`)
4647
- :meth:`DataFrame.pivot_table` and :func:`pivot_table` now allow the passing of keyword arguments to ``aggfunc`` through ``**kwargs`` (:issue:`57884`)
4748
- :meth:`Series.cummin` and :meth:`Series.cummax` now supports :class:`CategoricalDtype` (:issue:`52335`)
4849
- :meth:`Series.plot` now correctly handle the ``ylabel`` parameter for pie charts, allowing for explicit control over the y-axis label (:issue:`58239`)
4950
- Restore support for reading Stata 104-format and enable reading 103-format dta files (:issue:`58554`)
5051
- Support reading Stata 110-format (Stata 7) dta files (:issue:`47176`)
51-
- :meth:`DataFrame.ewm` now allows ``adjust=False`` when ``times`` is provided (:issue:`54328`)
5252

5353
.. ---------------------------------------------------------------------------
5454
.. _whatsnew_300.notable_bug_fixes:

pandas/core/window/ewm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,10 @@ def __init__(
377377
# But allow COM to still be calculated if the user passes other decay args
378378
if common.count_not_none(self.com, self.span, self.alpha) > 0:
379379
if not self.adjust:
380-
raise NotImplementedError('None of com, span, or alpha can be specified if '
381-
'times is provided and adjust=False')
380+
raise NotImplementedError(
381+
"None of com, span, or alpha can be specified if "
382+
"times is provided and adjust=False"
383+
)
382384
self._com = get_center_of_mass(self.com, self.span, None, self.alpha)
383385
else:
384386
self._com = 1.0

pandas/core/window/numba_.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def ewm(
151151
old_wt *= old_wt_factor ** deltas[start + j - 1]
152152
if not adjust and com == 1:
153153
# update alpha "on the fly" for irregular-interval time series
154-
new_wt = 1. - old_wt
154+
new_wt = 1.0 - old_wt
155155
else:
156156
weighted = old_wt_factor * weighted
157157
if is_observation:
@@ -329,7 +329,7 @@ def ewm_table(
329329
old_wt[j] *= old_wt_factor ** deltas[i - 1]
330330
if not adjust and com == 1:
331331
# update alpha "on the fly" for irregular-interval time series
332-
new_wt = 1. - old_wt[j]
332+
new_wt = 1.0 - old_wt[j]
333333
else:
334334
weighted[j] = old_wt_factor * weighted[j]
335335
if is_observations[j]:

pandas/tests/window/test_ewm.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def test_ewma_with_times_equal_spacing(halflife_with_times, times, min_periods):
103103

104104

105105
def test_ewma_with_times_variable_spacing(tz_aware_fixture, unit, adjust):
106-
#GH 54328
106+
# GH 54328
107107
tz = tz_aware_fixture
108108
halflife = "23 days"
109109
times = (
@@ -155,30 +155,44 @@ def test_ewm_getitem_attributes_retained(arg, adjust, ignore_na):
155155
def test_ewma_times_adjust_false_with_disallowed_com():
156156
# GH 54328
157157
with pytest.raises(
158-
NotImplementedError, match='None of com, span, or alpha can be specified if times is provided and adjust=False'
158+
NotImplementedError,
159+
match="None of com, span, or alpha can be specified if times is provided and adjust=False",
159160
):
160161
Series(range(1)).ewm(
161-
0.1, adjust=False, times=date_range("2000", freq="D", periods=1), halflife='1D'
162+
0.1,
163+
adjust=False,
164+
times=date_range("2000", freq="D", periods=1),
165+
halflife="1D",
162166
)
163167

164168

165169
def test_ewma_times_adjust_false_with_disallowed_alpha():
166170
# GH 54328
167171
with pytest.raises(
168-
NotImplementedError, match='None of com, span, or alpha can be specified if times is provided and adjust=False'
172+
NotImplementedError,
173+
match="None of com, span, or alpha can be specified if times is provided and adjust=False",
169174
):
170175
Series(range(1)).ewm(
171-
0.1, adjust=False, times=date_range("2000", freq="D", periods=1), alpha=0.5, halflife='1D'
176+
0.1,
177+
adjust=False,
178+
times=date_range("2000", freq="D", periods=1),
179+
alpha=0.5,
180+
halflife="1D",
172181
)
173182

174183

175184
def test_ewma_times_adjust_false_with_disallowed_span():
176185
# GH 54328
177186
with pytest.raises(
178-
NotImplementedError, match='None of com, span, or alpha can be specified if times is provided and adjust=False'
187+
NotImplementedError,
188+
match="None of com, span, or alpha can be specified if times is provided and adjust=False",
179189
):
180190
Series(range(1)).ewm(
181-
0.1, adjust=False, times=date_range("2000", freq="D", periods=1), span=10, halflife='1D'
191+
0.1,
192+
adjust=False,
193+
times=date_range("2000", freq="D", periods=1),
194+
span=10,
195+
halflife="1D",
182196
)
183197

184198

0 commit comments

Comments
 (0)