From 58a0a5745792e1c6346131f93f0a190a7ff0201d Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Fri, 26 Jan 2024 20:12:58 -0500 Subject: [PATCH 1/2] adding upgrade for pandas deprecation warning, adding pyarrow>=0.17.0 at minimum requirement as defined in dev requirements for pandas==1.3.0 version --- requirements.txt | 1 + requirements_dev.txt | 7 +++++++ tests/utils.py | 24 +++++++++++++----------- yfinance/utils.py | 2 +- 4 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 requirements_dev.txt diff --git a/requirements.txt b/requirements.txt index b8768416b..9f91edc83 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,3 +9,4 @@ frozendict>=2.3.4 beautifulsoup4>=4.11.1 html5lib>=1.1 peewee>=3.16.2 +pyarrow>=0.17.0 diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 000000000..0565cb00a --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,7 @@ +pytest +requests-cache +requests-ratelimiter +scipy +appdirs +scipy>=1.2 + diff --git a/tests/utils.py b/tests/utils.py index f9e54c09d..48bb5edad 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -8,6 +8,8 @@ python -m unittest tests.utils.TestTicker """ +from unittest import TestSuite + # import pandas as pd # import numpy as np @@ -34,16 +36,16 @@ def test_storeTzNoRaise(self): tkr = 'AMZN' tz1 = "America/New_York" tz2 = "London/Europe" - cache = yf.utils.get_tz_cache() + cache = yf.cache.get_tz_cache() cache.store(tkr, tz1) cache.store(tkr, tz2) def test_setTzCacheLocation(self): - self.assertEqual(yf.utils._DBManager.get_location(), self.tempCacheDir.name) + self.assertEqual(yf.cache._TzDBManager.get_location(), self.tempCacheDir.name) tkr = 'AMZN' tz1 = "America/New_York" - cache = yf.utils.get_tz_cache() + cache = yf.cache.get_tz_cache() cache.store(tkr, tz1) self.assertTrue(os.path.exists(os.path.join(self.tempCacheDir.name, "tkr-tz.db"))) @@ -60,10 +62,10 @@ def test_tzCacheRootStore(self): tz1 = "America/New_York" # During attempt to store, will discover cannot write - yf.utils.get_tz_cache().store(tkr, tz1) + yf.cache.get_tz_cache().store(tkr, tz1) # Handling the store failure replaces cache with a dummy - cache = yf.utils.get_tz_cache() + cache = yf.cache.get_tz_cache() self.assertTrue(cache.dummy) cache.store(tkr, tz1) @@ -71,19 +73,19 @@ def test_tzCacheRootLookup(self): # Test that if cache path in read-only filesystem, no exception. tkr = 'AMZN' # During attempt to lookup, will discover cannot write - yf.utils.get_tz_cache().lookup(tkr) + yf.cache.get_tz_cache().lookup(tkr) # Handling the lookup failure replaces cache with a dummy - cache = yf.utils.get_tz_cache() + cache = yf.cache.get_tz_cache() self.assertTrue(cache.dummy) cache.lookup(tkr) def suite(): - suite = unittest.TestSuite() - suite.addTest(TestCache('Test cache')) - suite.addTest(TestCacheNoPermission('Test cache no permission')) - return suite + ts: TestSuite = unittest.TestSuite() + ts.addTest(TestCache('Test cache')) + ts.addTest(TestCacheNoPermission('Test cache no permission')) + return ts if __name__ == '__main__': diff --git a/yfinance/utils.py b/yfinance/utils.py index 53eac44a9..90d70136b 100644 --- a/yfinance/utils.py +++ b/yfinance/utils.py @@ -772,7 +772,7 @@ def fix_Yahoo_dst_issue(df, interval): f_pre_midnight = (df.index.minute == 0) & (df.index.hour.isin([22, 23])) dst_error_hours = _np.array([0] * df.shape[0]) dst_error_hours[f_pre_midnight] = 24 - df.index[f_pre_midnight].hour - df.index += _pd.TimedeltaIndex(dst_error_hours, 'h') + df.index += _pd.to_timedelta(dst_error_hours, 'h') return df From 5aef8addab52cc660eef46d7b831832de1991f00 Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Mon, 29 Jan 2024 17:43:12 -0500 Subject: [PATCH 2/2] removing dev requirements (they are included by extras) --- requirements.txt | 1 - requirements_dev.txt | 7 ------- 2 files changed, 8 deletions(-) delete mode 100644 requirements_dev.txt diff --git a/requirements.txt b/requirements.txt index 9f91edc83..b8768416b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,3 @@ frozendict>=2.3.4 beautifulsoup4>=4.11.1 html5lib>=1.1 peewee>=3.16.2 -pyarrow>=0.17.0 diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index 0565cb00a..000000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,7 +0,0 @@ -pytest -requests-cache -requests-ratelimiter -scipy -appdirs -scipy>=1.2 -