Skip to content

Commit

Permalink
feat: Add deprecation warning on reload() and done() (#378)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeDongGeon1996 authored Apr 29, 2024
1 parent caa6c4f commit d89ffc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion stock_indicators/indicators/common/results.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
3 changes: 1 addition & 2 deletions stock_indicators/indicators/gator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down

0 comments on commit d89ffc7

Please sign in to comment.