Skip to content

Commit

Permalink
Merge pull request #312 from bashtage/property-cached
Browse files Browse the repository at this point in the history
ENH: Use property-cached in place of cached-property
  • Loading branch information
bashtage authored Aug 29, 2019
2 parents 5608ca2 + e8bc6e3 commit 46731c7
Show file tree
Hide file tree
Showing 13 changed files with 230 additions and 199 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ before_install:
- echo conda create --yes --quiet -n arch-test ${PKGS}
- conda create --yes --quiet -n arch-test ${PKGS}
- source activate arch-test
- pip install cached_property flake8 pytest pytest-xdist pytest-cov coverage coveralls codecov nbformat nbconvert!=5.4 jupyter_client ipython jupyter -q
- pip install property_cached flake8 pytest pytest-xdist pytest-cov coverage coveralls codecov nbformat nbconvert!=5.4 jupyter_client ipython jupyter -q
- if [[ "$STATSMODELS_MASTER" == true ]]; then sh ./ci/statsmodels-master.sh; fi;
- |
if [[ "$DOCBUILD" == true ]]; then
Expand Down
10 changes: 4 additions & 6 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ Module Contents
- `Bootstrapping <#bootstrap>`__
- `Multiple Comparison Tests <#multiple-comparison>`__

Python 2.7 Support
~~~~~~~~~~~~~~~~~~
Python 3
~~~~~~~~

Version 4.8 is the final version that officially supports or is tested
on Python 2.7, and is the final version that has Python 2.7 wheels. It
is time to move to Python 3.5+, and to enjoy the substantial improvement
available in recent Python releases.
``arch`` is Python 3 only. Version 4.8 is the final version that
supported Python 2.7.

.. _documentation-1:

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ build_script:
- cmd: conda update conda --quiet
- cmd: conda install numpy cython pytest pandas scipy patsy statsmodels matplotlib numba nbconvert nbformat pip pyyaml setuptools pyqt pyparsing --quiet
- cmd: python -m pip install --upgrade pip
- cmd: pip install pytest-xdist cached_property
- cmd: pip install pytest-xdist property_cached
- cmd: python setup.py develop

test_script:
Expand Down
6 changes: 3 additions & 3 deletions arch/univariate/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
data_scale_warning,
starting_value_warning)
from arch.utility.testing import WaldTestStatistic
from arch.vendor.cached_property import cached_property
from property_cached import cached_property

__all__ = ['implicit_constant', 'ARCHModelResult', 'ARCHModel', 'ARCHModelForecast', 'constraint']

Expand Down Expand Up @@ -664,13 +664,13 @@ def starting_values(self):
elif params.shape[0] > 1:
return params[:-1]

@abstractmethod
@cached_property
@abstractmethod
def num_params(self):
"""
Number of parameters in the model
"""
pass
return 0

@abstractmethod
def simulate(self, params, nobs, burn=500, initial_value=None, x=None,
Expand Down
2 changes: 1 addition & 1 deletion arch/univariate/mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from arch.univariate.volatility import (ARCH, EGARCH, FIGARCH, GARCH, HARCH,
ConstantVariance)
from arch.utility.array import cutoff_to_index, ensure1d, parse_dataframe
from arch.vendor.cached_property import cached_property
from property_cached import cached_property

__all__ = ['HARX', 'ConstantMean', 'ZeroMean', 'ARX', 'arch_model', 'LS']

Expand Down
12 changes: 10 additions & 2 deletions arch/utility/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from abc import ABCMeta
import datetime as dt

from property_cached import cached_property

import numpy as np
from pandas import (DataFrame, DatetimeIndex, NaT, Series, Timestamp,
to_datetime)
Expand Down Expand Up @@ -110,8 +112,14 @@ def __new__(mcs, name, bases, clsdict):
doc = getattr(getattr(mro_cls, attr), '__doc__')
if doc:
if isinstance(attribute, property):
clsdict[attr] = property(attribute.fget, attribute.fset,
attribute.fdel, doc)

if isinstance(attribute, cached_property):
attribute.func.__doc__ = doc
clsdict[attr] = cached_property(attribute.func)
else:
clsdict[attr] = property(attribute.fget,
attribute.fset,
attribute.fdel, doc)
else:
attribute.__doc__ = doc
break
Expand Down
2 changes: 1 addition & 1 deletion arch/utility/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from scipy.stats import chi2

from arch.vendor.cached_property import cached_property
from property_cached import cached_property

__all__ = ['WaldTestStatistic']

Expand Down
4 changes: 2 additions & 2 deletions arch/vendor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
try:
# Prefer system installed version if available
from cached_property import cached_property
from property_cached import cached_property
except ImportError:
from arch.vendor.cached_property import cached_property
from arch.vendor.property_cached import cached_property

__all__ = ['cached_property']
179 changes: 0 additions & 179 deletions arch/vendor/cached_property.py

This file was deleted.

Loading

0 comments on commit 46731c7

Please sign in to comment.