Skip to content

Commit 352d6a7

Browse files
authored
Merge pull request statsmodels#5976 from bashtage/restore-resettable-cache
MAINT: Restore ResettableCache
2 parents e820295 + 33a935d commit 352d6a7

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
global-include *.csv *.py *.txt *.pyx *.pyx.in *.pxd *.pxi *.c *.h
1+
global-include *.csv *.py *.txt *.pyx *.pyx.in *.pxd *.pxi *.c *.h *.pkl
22
include MANIFEST.in
33
include README.rst
44

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128
'statsmodels.stats.tests': ['*.txt'],
129129
'statsmodels.stats.libqsturng': ['*.r', '*.txt', '*.dat'],
130130
'statsmodels.stats.libqsturng.tests': ['*.csv', '*.dat'],
131-
'statsmodels.sandbox.regression.tests': ['*.dta', '*.csv']
131+
'statsmodels.sandbox.regression.tests': ['*.dta', '*.csv'],
132+
'statsmodels.tsa.statespace.tests.results': ['*.pkl']
132133
}
133134

134135
##############################################################################

statsmodels/tools/decorators.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33

44
import warnings
55

6-
__all__ = ['cache_readonly', 'cache_writable', 'deprecated_alias']
6+
__all__ = ['cache_readonly', 'cache_writable', 'deprecated_alias',
7+
'ResettableCache']
8+
9+
10+
class ResettableCache(dict):
11+
"""DO NOT USE. BACKWARD COMPAT ONLY"""
12+
def __init__(self, *args, **kwargs):
13+
super(ResettableCache, self).__init__(*args, **kwargs)
14+
self.__dict__ = self
715

816

917
def deprecated_alias(old_name, new_name, remove_version=None, msg=None,
Binary file not shown.

statsmodels/tsa/statespace/tests/test_save.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
"""
22
Tests of save / load / remove_data state space functionality.
33
"""
4-
54
import pickle
6-
import tempfile
75
import os
6+
import tempfile
87

98
import pytest
109

1110
from statsmodels import datasets
1211
from statsmodels.tsa.statespace import (sarimax, structural, varmax,
1312
dynamic_factor)
1413
from numpy.testing import assert_allclose
14+
15+
current_path = os.path.dirname(os.path.abspath(__file__))
1516
macrodata = datasets.macrodata.load_pandas().data
1617

1718

@@ -134,3 +135,9 @@ def test_varmax_pickle(temp_filename):
134135
assert_allclose(res.params, res2.params)
135136
assert_allclose(res.bse, res2.bse)
136137
assert_allclose(res.llf, res2.llf)
138+
139+
140+
def test_existing_pickle():
141+
pkl_file = os.path.join(current_path, 'results', 'sm-0.9-sarimax.pkl')
142+
loaded = sarimax.SARIMAXResults.load(pkl_file)
143+
assert isinstance(loaded, sarimax.SARIMAXResultsWrapper)

0 commit comments

Comments
 (0)