diff --git a/stock_indicators/indicators/common/results.py b/stock_indicators/indicators/common/results.py index 0b065f6a..2d653666 100644 --- a/stock_indicators/indicators/common/results.py +++ b/stock_indicators/indicators/common/results.py @@ -1,5 +1,6 @@ from datetime import datetime as PyDateTime from typing import Callable, Iterable, List, Optional, Type, TypeVar +from warnings import warn from stock_indicators._cslib import CsResultBase from stock_indicators._cstypes import DateTime as CsDateTime @@ -35,8 +36,10 @@ def __init__(self, data: Iterable, wrapper_class: Type[_T]): def reload(self): """ Reload a C# array of the results to perform more operations. - It is usually called after `done()` + It is usually called after `done()`. + This method is deprecated. It will be removed in the next version. """ + warn('This method is deprecated.', DeprecationWarning, stacklevel=2) if self._csdata is None: self._csdata = [ _._csdata for _ in self ] return self @@ -45,7 +48,9 @@ def done(self): """ Remove a C# array of the results after finishing all operations. It is not necessary but saves memory. + This method is deprecated. It will be removed in the next version. """ + warn('This method is deprecated.', DeprecationWarning, stacklevel=2) self._csdata = None return self diff --git a/stock_indicators/indicators/gator.py b/stock_indicators/indicators/gator.py index 8878798d..d363bf21 100644 --- a/stock_indicators/indicators/gator.py +++ b/stock_indicators/indicators/gator.py @@ -32,8 +32,7 @@ def get_gator(quotes): results = CsIndicator.GetGator[Quote](CsList(Quote, quotes)) else: # Get C# objects. - if isinstance(quotes, IndicatorResults): - quotes.reload() + if isinstance(quotes, IndicatorResults) and quotes._csdata is not None: cs_results = quotes._csdata else: cs_results = [ q._csdata for q in quotes ]