Skip to content

Commit

Permalink
Merge pull request #7221 from bashtage/0.12-future-fixes
Browse files Browse the repository at this point in the history
MAINT: Backport fixes for 0.12.2 compat release
  • Loading branch information
bashtage committed Dec 21, 2020
2 parents b45c7e8 + 6b065c7 commit 2ccd1f8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
6 changes: 4 additions & 2 deletions statsmodels/tsa/arima/estimators/tests/test_gls.py
Expand Up @@ -203,5 +203,7 @@ def test_arma_kwargs():
_, res2_imle = gls(endog, exog=exog, order=(1, 0, 1), n_iter=1,
arma_estimator_kwargs=arma_estimator_kwargs)
assert_equal(res2_imle.arma_estimator_kwargs, arma_estimator_kwargs)
assert_equal(res2_imle.arma_results[1].minimize_results.message,
b'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH')
msg = res2_imle.arma_results[1].minimize_results.message
if isinstance(msg, bytes):
msg = msg.decode("utf-8")
assert_equal(msg, 'CONVERGENCE: REL_REDUCTION_OF_F_<=_FACTR*EPSMCH')
27 changes: 18 additions & 9 deletions statsmodels/tsa/statespace/dynamic_factor_mq.py
Expand Up @@ -1525,7 +1525,10 @@ def construct_endog(cls, endog_monthly, endog_quarterly):
if not isinstance(endog_monthly, (pd.Series, pd.DataFrame)):
raise ValueError('Given monthly dataset is not a'
' Pandas object. ' + base_msg)
elif not endog_monthly.index.is_all_dates:
elif endog_monthly.index.inferred_type not in (
"datetime64",
"period",
):
raise ValueError('Given monthly dataset has an'
' index with non-date values. ' + base_msg)
elif not getattr(endog_monthly.index, 'freqstr', 'N')[0] == 'M':
Expand All @@ -1544,7 +1547,10 @@ def construct_endog(cls, endog_monthly, endog_quarterly):
if not isinstance(endog_quarterly, (pd.Series, pd.DataFrame)):
raise ValueError('Given quarterly dataset is not a'
' Pandas object. ' + base_msg)
elif not endog_quarterly.index.is_all_dates:
elif endog_quarterly.index.inferred_type not in (
"datetime64",
"period",
):
raise ValueError('Given quarterly dataset has an'
' index with non-date values. ' + base_msg)
elif not getattr(endog_quarterly.index, 'freqstr', 'N')[0] == 'Q':
Expand All @@ -1569,13 +1575,16 @@ def construct_endog(cls, endog_monthly, endog_quarterly):
axis=1)

# Make sure we didn't accidentally get duplicate column names
columns = endog.columns.values
for name, count in endog.columns.value_counts().items():
if count == 1:
continue
mask = columns == name
columns[mask] = [f'{name}{i + 1}' for i in range(count)]
endog.columns = columns
column_counts = endog.columns.value_counts()
if column_counts.max() > 1:
columns = endog.columns.values.astype(object)
for name in column_counts.index:
count = column_counts.loc[name]
if count == 1:
continue
mask = columns == name
columns[mask] = [f'{name}{i + 1}' for i in range(count)]
endog.columns = columns
else:
endog = endog_monthly.copy()
shape = endog_monthly.shape
Expand Down

0 comments on commit 2ccd1f8

Please sign in to comment.