From f67c5025629e04ca87a62fb1bf1c63ad191a4e00 Mon Sep 17 00:00:00 2001 From: Oleg Polakow Date: Sat, 16 Oct 2021 13:42:00 +0200 Subject: [PATCH] Hotfix clashing module names --- tests/test_portfolio.py | 2 +- tests/test_utils.py | 414 +++++++++---------- vectorbt/__init__.py | 2 +- vectorbt/_settings.py | 2 +- vectorbt/base/array_wrapper.py | 6 +- vectorbt/base/column_grouper.py | 2 +- vectorbt/data/base.py | 2 +- vectorbt/data/custom.py | 2 +- vectorbt/data/updater.py | 2 +- vectorbt/generic/plots_builder.py | 2 +- vectorbt/generic/plotting.py | 2 +- vectorbt/generic/stats_builder.py | 2 +- vectorbt/indicators/factory.py | 4 +- vectorbt/messaging/telegram.py | 2 +- vectorbt/portfolio/base.py | 4 +- vectorbt/portfolio/nb.py | 4 +- vectorbt/portfolio/trades.py | 2 +- vectorbt/records/base.py | 2 +- vectorbt/returns/accessors.py | 2 +- vectorbt/signals/factory.py | 2 +- vectorbt/signals/nb.py | 2 +- vectorbt/utils/__init__.py | 6 +- vectorbt/utils/{array.py => array_.py} | 0 vectorbt/utils/{attr.py => attr_.py} | 0 vectorbt/utils/{datetime.py => datetime_.py} | 0 vectorbt/utils/{enum.py => enum_.py} | 0 vectorbt/utils/{image.py => image_.py} | 0 vectorbt/utils/{math.py => math_.py} | 0 vectorbt/utils/{module.py => module_.py} | 0 vectorbt/utils/{random.py => random_.py} | 0 vectorbt/utils/{requests.py => requests_.py} | 0 vectorbt/utils/{schedule.py => schedule_.py} | 2 +- 32 files changed, 236 insertions(+), 236 deletions(-) rename vectorbt/utils/{array.py => array_.py} (100%) rename vectorbt/utils/{attr.py => attr_.py} (100%) rename vectorbt/utils/{datetime.py => datetime_.py} (100%) rename vectorbt/utils/{enum.py => enum_.py} (100%) rename vectorbt/utils/{image.py => image_.py} (100%) rename vectorbt/utils/{math.py => math_.py} (100%) rename vectorbt/utils/{module.py => module_.py} (100%) rename vectorbt/utils/{random.py => random_.py} (100%) rename vectorbt/utils/{requests.py => requests_.py} (100%) rename vectorbt/utils/{schedule.py => schedule_.py} (99%) diff --git a/tests/test_portfolio.py b/tests/test_portfolio.py index 0c174756..b43e3158 100644 --- a/tests/test_portfolio.py +++ b/tests/test_portfolio.py @@ -9,7 +9,7 @@ import vectorbt as vbt from vectorbt.portfolio.enums import * from vectorbt.generic.enums import drawdown_dt -from vectorbt.utils.random import set_seed +from vectorbt.utils.random_ import set_seed from vectorbt.portfolio import nb from tests.utils import record_arrays_close diff --git a/tests/test_utils.py b/tests/test_utils.py index a53f53ca..a8848654 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -14,15 +14,15 @@ checks, config, decorators, - math, - array, - random, + math_, + array_, + random_, mapping, - enum, + enum_, params, - attr, - datetime, - schedule, + attr_, + datetime_, + schedule_, tags, template ) @@ -1481,7 +1481,7 @@ def not_compare(a, b): vbt.settings.caching.reset() -# ############# attr.py ############# # +# ############# attr_.py ############# # class TestAttr: def test_deep_getattr(self): @@ -1510,20 +1510,20 @@ def c(self): return 0 with pytest.raises(Exception): - _ = attr.deep_getattr(A(), 'a') + _ = attr_.deep_getattr(A(), 'a') with pytest.raises(Exception): - _ = attr.deep_getattr(A(), ('a',)) + _ = attr_.deep_getattr(A(), ('a',)) with pytest.raises(Exception): - _ = attr.deep_getattr(A(), ('a', 1)) + _ = attr_.deep_getattr(A(), ('a', 1)) with pytest.raises(Exception): - _ = attr.deep_getattr(A(), ('a', (1,))) - assert attr.deep_getattr(A(), ('a', (1,), {'y': 1})) == 2 - assert attr.deep_getattr(C(), 'c') == 0 - assert attr.deep_getattr(C(), ['c']) == 0 - assert attr.deep_getattr(C(), ['b', ('b', (1,))]) == 1 - assert attr.deep_getattr(C(), ['b', ('a',), ('a', (1,), {'y': 1})]) == 2 - assert attr.deep_getattr(C(), 'b.b_prop') == 1 - assert callable(attr.deep_getattr(C(), 'b.a.a', call_last_attr=False)) + _ = attr_.deep_getattr(A(), ('a', (1,))) + assert attr_.deep_getattr(A(), ('a', (1,), {'y': 1})) == 2 + assert attr_.deep_getattr(C(), 'c') == 0 + assert attr_.deep_getattr(C(), ['c']) == 0 + assert attr_.deep_getattr(C(), ['b', ('b', (1,))]) == 1 + assert attr_.deep_getattr(C(), ['b', ('a',), ('a', (1,), {'y': 1})]) == 2 + assert attr_.deep_getattr(C(), 'b.b_prop') == 1 + assert callable(attr_.deep_getattr(C(), 'b.a.a', call_last_attr=False)) # ############# checks.py ############# # @@ -1962,7 +1962,7 @@ def test_assert_dict_valid(self): checks.assert_dict_valid(dict(a=2, b=3, c=dict(d=4, f=5)), [['a', 'b', 'c'], ['d', 'e']]) -# ############# math.py ############# # +# ############# math_.py ############# # class TestMath: def test_is_close(self): @@ -1970,130 +1970,130 @@ def test_is_close(self): b = 0.1 + 0.2 # test scalar - assert math.is_close_nb(a, a) - assert math.is_close_nb(a, b) - assert math.is_close_nb(-a, -b) - assert not math.is_close_nb(-a, b) - assert not math.is_close_nb(a, -b) - assert math.is_close_nb(1e10 + a, 1e10 + b) + assert math_.is_close_nb(a, a) + assert math_.is_close_nb(a, b) + assert math_.is_close_nb(-a, -b) + assert not math_.is_close_nb(-a, b) + assert not math_.is_close_nb(a, -b) + assert math_.is_close_nb(1e10 + a, 1e10 + b) # test np.nan - assert not math.is_close_nb(np.nan, b) - assert not math.is_close_nb(a, np.nan) + assert not math_.is_close_nb(np.nan, b) + assert not math_.is_close_nb(a, np.nan) # test np.inf - assert not math.is_close_nb(np.inf, b) - assert not math.is_close_nb(a, np.inf) - assert not math.is_close_nb(-np.inf, b) - assert not math.is_close_nb(a, -np.inf) - assert not math.is_close_nb(-np.inf, -np.inf) - assert not math.is_close_nb(np.inf, np.inf) - assert not math.is_close_nb(-np.inf, np.inf) + assert not math_.is_close_nb(np.inf, b) + assert not math_.is_close_nb(a, np.inf) + assert not math_.is_close_nb(-np.inf, b) + assert not math_.is_close_nb(a, -np.inf) + assert not math_.is_close_nb(-np.inf, -np.inf) + assert not math_.is_close_nb(np.inf, np.inf) + assert not math_.is_close_nb(-np.inf, np.inf) def test_is_close_or_less(self): a = 0.3 b = 0.1 + 0.2 # test scalar - assert math.is_close_or_less_nb(a, a) - assert math.is_close_or_less_nb(a, b) - assert math.is_close_or_less_nb(-a, -b) - assert math.is_close_or_less_nb(-a, b) - assert not math.is_close_or_less_nb(a, -b) - assert math.is_close_or_less_nb(1e10 + a, 1e10 + b) + assert math_.is_close_or_less_nb(a, a) + assert math_.is_close_or_less_nb(a, b) + assert math_.is_close_or_less_nb(-a, -b) + assert math_.is_close_or_less_nb(-a, b) + assert not math_.is_close_or_less_nb(a, -b) + assert math_.is_close_or_less_nb(1e10 + a, 1e10 + b) # test np.nan - assert not math.is_close_or_less_nb(np.nan, b) - assert not math.is_close_or_less_nb(a, np.nan) + assert not math_.is_close_or_less_nb(np.nan, b) + assert not math_.is_close_or_less_nb(a, np.nan) # test np.inf - assert not math.is_close_or_less_nb(np.inf, b) - assert math.is_close_or_less_nb(a, np.inf) - assert math.is_close_or_less_nb(-np.inf, b) - assert not math.is_close_or_less_nb(a, -np.inf) - assert not math.is_close_or_less_nb(-np.inf, -np.inf) - assert not math.is_close_or_less_nb(np.inf, np.inf) - assert math.is_close_or_less_nb(-np.inf, np.inf) + assert not math_.is_close_or_less_nb(np.inf, b) + assert math_.is_close_or_less_nb(a, np.inf) + assert math_.is_close_or_less_nb(-np.inf, b) + assert not math_.is_close_or_less_nb(a, -np.inf) + assert not math_.is_close_or_less_nb(-np.inf, -np.inf) + assert not math_.is_close_or_less_nb(np.inf, np.inf) + assert math_.is_close_or_less_nb(-np.inf, np.inf) def test_is_less(self): a = 0.3 b = 0.1 + 0.2 # test scalar - assert not math.is_less_nb(a, a) - assert not math.is_less_nb(a, b) - assert not math.is_less_nb(-a, -b) - assert math.is_less_nb(-a, b) - assert not math.is_less_nb(a, -b) - assert not math.is_less_nb(1e10 + a, 1e10 + b) + assert not math_.is_less_nb(a, a) + assert not math_.is_less_nb(a, b) + assert not math_.is_less_nb(-a, -b) + assert math_.is_less_nb(-a, b) + assert not math_.is_less_nb(a, -b) + assert not math_.is_less_nb(1e10 + a, 1e10 + b) # test np.nan - assert not math.is_less_nb(np.nan, b) - assert not math.is_less_nb(a, np.nan) + assert not math_.is_less_nb(np.nan, b) + assert not math_.is_less_nb(a, np.nan) # test np.inf - assert not math.is_less_nb(np.inf, b) - assert math.is_less_nb(a, np.inf) - assert math.is_less_nb(-np.inf, b) - assert not math.is_less_nb(a, -np.inf) - assert not math.is_less_nb(-np.inf, -np.inf) - assert not math.is_less_nb(np.inf, np.inf) - assert math.is_less_nb(-np.inf, np.inf) + assert not math_.is_less_nb(np.inf, b) + assert math_.is_less_nb(a, np.inf) + assert math_.is_less_nb(-np.inf, b) + assert not math_.is_less_nb(a, -np.inf) + assert not math_.is_less_nb(-np.inf, -np.inf) + assert not math_.is_less_nb(np.inf, np.inf) + assert math_.is_less_nb(-np.inf, np.inf) def test_is_addition_zero(self): a = 0.3 b = 0.1 + 0.2 - assert not math.is_addition_zero_nb(a, b) - assert math.is_addition_zero_nb(-a, b) - assert math.is_addition_zero_nb(a, -b) - assert not math.is_addition_zero_nb(-a, -b) + assert not math_.is_addition_zero_nb(a, b) + assert math_.is_addition_zero_nb(-a, b) + assert math_.is_addition_zero_nb(a, -b) + assert not math_.is_addition_zero_nb(-a, -b) def test_add_nb(self): a = 0.3 b = 0.1 + 0.2 - assert math.add_nb(a, b) == a + b - assert math.add_nb(-a, b) == 0 - assert math.add_nb(a, -b) == 0 - assert math.add_nb(-a, -b) == -(a + b) + assert math_.add_nb(a, b) == a + b + assert math_.add_nb(-a, b) == 0 + assert math_.add_nb(a, -b) == 0 + assert math_.add_nb(-a, -b) == -(a + b) -# ############# array.py ############# # +# ############# array_.py ############# # class TestArray: def test_is_sorted(self): - assert array.is_sorted(np.array([0, 1, 2, 3, 4])) - assert array.is_sorted(np.array([0, 1])) - assert array.is_sorted(np.array([0])) - assert not array.is_sorted(np.array([1, 0])) - assert not array.is_sorted(np.array([0, 1, 2, 4, 3])) + assert array_.is_sorted(np.array([0, 1, 2, 3, 4])) + assert array_.is_sorted(np.array([0, 1])) + assert array_.is_sorted(np.array([0])) + assert not array_.is_sorted(np.array([1, 0])) + assert not array_.is_sorted(np.array([0, 1, 2, 4, 3])) # nb - assert array.is_sorted_nb(np.array([0, 1, 2, 3, 4])) - assert array.is_sorted_nb(np.array([0, 1])) - assert array.is_sorted_nb(np.array([0])) - assert not array.is_sorted_nb(np.array([1, 0])) - assert not array.is_sorted_nb(np.array([0, 1, 2, 4, 3])) + assert array_.is_sorted_nb(np.array([0, 1, 2, 3, 4])) + assert array_.is_sorted_nb(np.array([0, 1])) + assert array_.is_sorted_nb(np.array([0])) + assert not array_.is_sorted_nb(np.array([1, 0])) + assert not array_.is_sorted_nb(np.array([0, 1, 2, 4, 3])) def test_insert_argsort_nb(self): a = np.random.uniform(size=1000) A = a.copy() I = np.arange(len(A)) - array.insert_argsort_nb(A, I) + array_.insert_argsort_nb(A, I) np.testing.assert_array_equal(np.sort(a), A) np.testing.assert_array_equal(a[I], A) def test_get_ranges_arr(self): np.testing.assert_array_equal( - array.get_ranges_arr(0, 3), + array_.get_ranges_arr(0, 3), np.array([0, 1, 2]) ) np.testing.assert_array_equal( - array.get_ranges_arr(0, [1, 2, 3]), + array_.get_ranges_arr(0, [1, 2, 3]), np.array([0, 0, 1, 0, 1, 2]) ) np.testing.assert_array_equal( - array.get_ranges_arr([0, 3], [3, 6]), + array_.get_ranges_arr([0, 3], [3, 6]), np.array([0, 1, 2, 3, 4, 5]) ) @@ -2104,52 +2104,52 @@ def set_seed(): set_seed() np.testing.assert_array_almost_equal( - array.uniform_summing_to_one_nb(10), + array_.uniform_summing_to_one_nb(10), np.array([ 5.808361e-02, 9.791091e-02, 2.412011e-05, 2.185215e-01, 2.241184e-01, 2.456528e-03, 1.308789e-01, 1.341822e-01, 8.453816e-02, 4.928569e-02 ]) ) - assert np.sum(array.uniform_summing_to_one_nb(10)) == 1 + assert np.sum(array_.uniform_summing_to_one_nb(10)) == 1 def test_renormalize(self): - assert array.renormalize(0, (0, 10), (0, 1)) == 0 - assert array.renormalize(10, (0, 10), (0, 1)) == 1 + assert array_.renormalize(0, (0, 10), (0, 1)) == 0 + assert array_.renormalize(10, (0, 10), (0, 1)) == 1 np.testing.assert_array_equal( - array.renormalize(np.array([0, 2, 4, 6, 8, 10]), (0, 10), (0, 1)), + array_.renormalize(np.array([0, 2, 4, 6, 8, 10]), (0, 10), (0, 1)), np.array([0., 0.2, 0.4, 0.6, 0.8, 1.]) ) np.testing.assert_array_equal( - array.renormalize_nb(np.array([0, 2, 4, 6, 8, 10]), (0, 10), (0, 1)), + array_.renormalize_nb(np.array([0, 2, 4, 6, 8, 10]), (0, 10), (0, 1)), np.array([0., 0.2, 0.4, 0.6, 0.8, 1.]) ) def test_min_rel_rescale(self): np.testing.assert_array_equal( - array.min_rel_rescale(np.array([2, 4, 6]), (10, 20)), + array_.min_rel_rescale(np.array([2, 4, 6]), (10, 20)), np.array([10., 15., 20.]) ) np.testing.assert_array_equal( - array.min_rel_rescale(np.array([5, 6, 7]), (10, 20)), + array_.min_rel_rescale(np.array([5, 6, 7]), (10, 20)), np.array([10., 12., 14.]) ) np.testing.assert_array_equal( - array.min_rel_rescale(np.array([5, 5, 5]), (10, 20)), + array_.min_rel_rescale(np.array([5, 5, 5]), (10, 20)), np.array([10., 10., 10.]) ) def test_max_rel_rescale(self): np.testing.assert_array_equal( - array.max_rel_rescale(np.array([2, 4, 6]), (10, 20)), + array_.max_rel_rescale(np.array([2, 4, 6]), (10, 20)), np.array([10., 15., 20.]) ) np.testing.assert_array_equal( - array.max_rel_rescale(np.array([5, 6, 7]), (10, 20)), + array_.max_rel_rescale(np.array([5, 6, 7]), (10, 20)), np.array([14.285714285714286, 17.142857142857142, 20.]) ) np.testing.assert_array_equal( - array.max_rel_rescale(np.array([5, 5, 5]), (10, 20)), + array_.max_rel_rescale(np.array([5, 5, 5]), (10, 20)), np.array([20., 20., 20.]) ) @@ -2160,18 +2160,18 @@ def set_seed(): set_seed() np.testing.assert_array_equal( - array.rescale_float_to_int_nb(np.array([0.3, 0.3, 0.3, 0.1]), (10, 20), 70), + array_.rescale_float_to_int_nb(np.array([0.3, 0.3, 0.3, 0.1]), (10, 20), 70), np.array([17, 14, 22, 17]) ) - assert np.sum(array.rescale_float_to_int_nb(np.array([0.3, 0.3, 0.3, 0.1]), (10, 20), 70)) == 70 + assert np.sum(array_.rescale_float_to_int_nb(np.array([0.3, 0.3, 0.3, 0.1]), (10, 20), 70)) == 70 -# ############# random.py ############# # +# ############# random_.py ############# # class TestRandom: def test_set_seed(self): - random.set_seed(seed) + random_.set_seed(seed) def test_seed(): return np.random.uniform(0, 1) @@ -2229,137 +2229,137 @@ def test_apply_mapping(self): assert mapping.apply_mapping(np.array(['world']), mapping_like={'world': 'hello'})[0] == 'hello' -# ############# enum.py ############# # +# ############# enum_.py ############# # class TestEnum: def test_map_enum_fields(self): - assert enum.map_enum_fields(0, Enum) == 0 - assert enum.map_enum_fields(10, Enum) == 10 + assert enum_.map_enum_fields(0, Enum) == 0 + assert enum_.map_enum_fields(10, Enum) == 10 with pytest.raises(Exception): - _ = enum.map_enum_fields(10., Enum) - assert enum.map_enum_fields('Attr1', Enum) == 0 - assert enum.map_enum_fields('attr1', Enum) == 0 + _ = enum_.map_enum_fields(10., Enum) + assert enum_.map_enum_fields('Attr1', Enum) == 0 + assert enum_.map_enum_fields('attr1', Enum) == 0 with pytest.raises(Exception): - _ = enum.map_enum_fields('hello', Enum) - assert enum.map_enum_fields('attr1', Enum) == 0 - assert enum.map_enum_fields(('attr1', 'attr2'), Enum) == (0, 1) - assert enum.map_enum_fields([['attr1', 'attr2']], Enum) == [[0, 1]] + _ = enum_.map_enum_fields('hello', Enum) + assert enum_.map_enum_fields('attr1', Enum) == 0 + assert enum_.map_enum_fields(('attr1', 'attr2'), Enum) == (0, 1) + assert enum_.map_enum_fields([['attr1', 'attr2']], Enum) == [[0, 1]] np.testing.assert_array_equal( - enum.map_enum_fields(np.array([]), Enum), + enum_.map_enum_fields(np.array([]), Enum), np.array([]) ) with pytest.raises(Exception): - _ = enum.map_enum_fields(np.array([[0., 1.]]), Enum) + _ = enum_.map_enum_fields(np.array([[0., 1.]]), Enum) with pytest.raises(Exception): - _ = enum.map_enum_fields(np.array([[False, True]]), Enum) + _ = enum_.map_enum_fields(np.array([[False, True]]), Enum) np.testing.assert_array_equal( - enum.map_enum_fields(np.array([[0, 1]]), Enum), + enum_.map_enum_fields(np.array([[0, 1]]), Enum), np.array([[0, 1]]) ) np.testing.assert_array_equal( - enum.map_enum_fields(np.array([['attr1', 'attr2']]), Enum), + enum_.map_enum_fields(np.array([['attr1', 'attr2']]), Enum), np.array([[0, 1]]) ) with pytest.raises(Exception): - _ = enum.map_enum_fields(np.array([['attr1', 1]]), Enum) + _ = enum_.map_enum_fields(np.array([['attr1', 1]]), Enum) pd.testing.assert_series_equal( - enum.map_enum_fields(pd.Series([]), Enum), + enum_.map_enum_fields(pd.Series([]), Enum), pd.Series([]) ) with pytest.raises(Exception): - _ = enum.map_enum_fields(pd.Series([0., 1.]), Enum) + _ = enum_.map_enum_fields(pd.Series([0., 1.]), Enum) with pytest.raises(Exception): - _ = enum.map_enum_fields(pd.Series([False, True]), Enum) + _ = enum_.map_enum_fields(pd.Series([False, True]), Enum) pd.testing.assert_series_equal( - enum.map_enum_fields(pd.Series([0, 1]), Enum), + enum_.map_enum_fields(pd.Series([0, 1]), Enum), pd.Series([0, 1]) ) pd.testing.assert_series_equal( - enum.map_enum_fields(pd.Series(['attr1', 'attr2']), Enum), + enum_.map_enum_fields(pd.Series(['attr1', 'attr2']), Enum), pd.Series([0, 1]) ) with pytest.raises(Exception): - _ = enum.map_enum_fields(pd.Series(['attr1', 0]), Enum) + _ = enum_.map_enum_fields(pd.Series(['attr1', 0]), Enum) pd.testing.assert_frame_equal( - enum.map_enum_fields(pd.DataFrame([]), Enum), + enum_.map_enum_fields(pd.DataFrame([]), Enum), pd.DataFrame([]) ) with pytest.raises(Exception): - _ = enum.map_enum_fields(pd.DataFrame([[0., 1.]]), Enum) + _ = enum_.map_enum_fields(pd.DataFrame([[0., 1.]]), Enum) pd.testing.assert_frame_equal( - enum.map_enum_fields(pd.DataFrame([[0, 1]]), Enum), + enum_.map_enum_fields(pd.DataFrame([[0, 1]]), Enum), pd.DataFrame([[0, 1]]) ) pd.testing.assert_frame_equal( - enum.map_enum_fields(pd.DataFrame([['attr1', 'attr2']]), Enum), + enum_.map_enum_fields(pd.DataFrame([['attr1', 'attr2']]), Enum), pd.DataFrame([[0, 1]]) ) pd.testing.assert_frame_equal( - enum.map_enum_fields(pd.DataFrame([[0, 'attr2']]), Enum), + enum_.map_enum_fields(pd.DataFrame([[0, 'attr2']]), Enum), pd.DataFrame([[0, 1]]) ) def test_map_enum_values(self): - assert enum.map_enum_values(0, Enum) == 'Attr1' - assert enum.map_enum_values(-1, Enum) is None + assert enum_.map_enum_values(0, Enum) == 'Attr1' + assert enum_.map_enum_values(-1, Enum) is None with pytest.raises(Exception): - _ = enum.map_enum_values(-2, Enum) - assert enum.map_enum_values((0, 1, 'Attr3'), Enum) == ('Attr1', 'Attr2', 'Attr3') - assert enum.map_enum_values([[0, 1, 'Attr3']], Enum) == [['Attr1', 'Attr2', 'Attr3']] - assert enum.map_enum_values('hello', Enum) == 'hello' + _ = enum_.map_enum_values(-2, Enum) + assert enum_.map_enum_values((0, 1, 'Attr3'), Enum) == ('Attr1', 'Attr2', 'Attr3') + assert enum_.map_enum_values([[0, 1, 'Attr3']], Enum) == [['Attr1', 'Attr2', 'Attr3']] + assert enum_.map_enum_values('hello', Enum) == 'hello' np.testing.assert_array_equal( - enum.map_enum_values(np.array([]), Enum), + enum_.map_enum_values(np.array([]), Enum), np.array([]) ) np.testing.assert_array_equal( - enum.map_enum_values(np.array([[0., 1.]]), Enum), + enum_.map_enum_values(np.array([[0., 1.]]), Enum), np.array([['Attr1', 'Attr2']]) ) np.testing.assert_array_equal( - enum.map_enum_values(np.array([['Attr1', 'Attr2']]), Enum), + enum_.map_enum_values(np.array([['Attr1', 'Attr2']]), Enum), np.array([['Attr1', 'Attr2']]) ) np.testing.assert_array_equal( - enum.map_enum_values(np.array([[0, 'Attr2']]), Enum), + enum_.map_enum_values(np.array([[0, 'Attr2']]), Enum), np.array([['0', 'Attr2']]) ) pd.testing.assert_series_equal( - enum.map_enum_values(pd.Series([]), Enum), + enum_.map_enum_values(pd.Series([]), Enum), pd.Series([]) ) pd.testing.assert_series_equal( - enum.map_enum_values(pd.Series([0., 1.]), Enum), + enum_.map_enum_values(pd.Series([0., 1.]), Enum), pd.Series(['Attr1', 'Attr2']) ) pd.testing.assert_series_equal( - enum.map_enum_values(pd.Series([0, 1]), Enum), + enum_.map_enum_values(pd.Series([0, 1]), Enum), pd.Series(['Attr1', 'Attr2']) ) pd.testing.assert_series_equal( - enum.map_enum_values(pd.Series(['Attr1', 'Attr2']), Enum), + enum_.map_enum_values(pd.Series(['Attr1', 'Attr2']), Enum), pd.Series(['Attr1', 'Attr2']) ) with pytest.raises(Exception): - _ = enum.map_enum_values(pd.Series([0, 'Attr2']), Enum) + _ = enum_.map_enum_values(pd.Series([0, 'Attr2']), Enum) pd.testing.assert_frame_equal( - enum.map_enum_values(pd.DataFrame([]), Enum), + enum_.map_enum_values(pd.DataFrame([]), Enum), pd.DataFrame([]) ) pd.testing.assert_frame_equal( - enum.map_enum_values(pd.DataFrame([[0., 1.]]), Enum), + enum_.map_enum_values(pd.DataFrame([[0., 1.]]), Enum), pd.DataFrame([['Attr1', 'Attr2']]) ) pd.testing.assert_frame_equal( - enum.map_enum_values(pd.DataFrame([[0, 1]]), Enum), + enum_.map_enum_values(pd.DataFrame([[0, 1]]), Enum), pd.DataFrame([['Attr1', 'Attr2']]) ) pd.testing.assert_frame_equal( - enum.map_enum_values(pd.DataFrame([['Attr1', 'Attr2']]), Enum), + enum_.map_enum_values(pd.DataFrame([['Attr1', 'Attr2']]), Enum), pd.DataFrame([['Attr1', 'Attr2']]) ) pd.testing.assert_frame_equal( - enum.map_enum_values(pd.DataFrame([[0, 'Attr2']]), Enum), + enum_.map_enum_values(pd.DataFrame([[0, 'Attr2']]), Enum), pd.DataFrame([['Attr1', 'Attr2']]) ) @@ -2388,90 +2388,90 @@ def test_create_param_combs(self): ] -# ############# datetime.py ############# # +# ############# datetime_.py ############# # class TestDatetime: def test_to_timedelta(self): - assert datetime.freq_to_timedelta('d') == pd.to_timedelta('1d') + assert datetime_.freq_to_timedelta('d') == pd.to_timedelta('1d') def test_get_utc_tz(self): - assert datetime.get_utc_tz().utcoffset(_datetime.now()) == _timedelta(0) + assert datetime_.get_utc_tz().utcoffset(_datetime.now()) == _timedelta(0) def test_get_local_tz(self): - assert datetime.get_local_tz().utcoffset(_datetime.now()) == _datetime.now().astimezone(None).utcoffset() + assert datetime_.get_local_tz().utcoffset(_datetime.now()) == _datetime.now().astimezone(None).utcoffset() def test_convert_tzaware_time(self): - assert datetime.convert_tzaware_time( - _time(12, 0, 0, tzinfo=datetime.get_utc_tz()), _timezone(_timedelta(hours=2))) == \ + assert datetime_.convert_tzaware_time( + _time(12, 0, 0, tzinfo=datetime_.get_utc_tz()), _timezone(_timedelta(hours=2))) == \ _time(14, 0, 0, tzinfo=_timezone(_timedelta(hours=2))) def test_tzaware_to_naive_time(self): - assert datetime.tzaware_to_naive_time( - _time(12, 0, 0, tzinfo=datetime.get_utc_tz()), _timezone(_timedelta(hours=2))) == _time(14, 0, 0) + assert datetime_.tzaware_to_naive_time( + _time(12, 0, 0, tzinfo=datetime_.get_utc_tz()), _timezone(_timedelta(hours=2))) == _time(14, 0, 0) def test_naive_to_tzaware_time(self): - assert datetime.naive_to_tzaware_time( + assert datetime_.naive_to_tzaware_time( _time(12, 0, 0), _timezone(_timedelta(hours=2))) == \ - datetime.convert_tzaware_time( - _time(12, 0, 0, tzinfo=datetime.get_local_tz()), _timezone(_timedelta(hours=2))) + datetime_.convert_tzaware_time( + _time(12, 0, 0, tzinfo=datetime_.get_local_tz()), _timezone(_timedelta(hours=2))) def test_convert_naive_time(self): - assert datetime.convert_naive_time( + assert datetime_.convert_naive_time( _time(12, 0, 0), _timezone(_timedelta(hours=2))) == \ - datetime.tzaware_to_naive_time( - _time(12, 0, 0, tzinfo=datetime.get_local_tz()), _timezone(_timedelta(hours=2))) + datetime_.tzaware_to_naive_time( + _time(12, 0, 0, tzinfo=datetime_.get_local_tz()), _timezone(_timedelta(hours=2))) def test_is_tz_aware(self): - assert not datetime.is_tz_aware(pd.Timestamp('2020-01-01')) - assert datetime.is_tz_aware(pd.Timestamp('2020-01-01', tz=datetime.get_utc_tz())) + assert not datetime_.is_tz_aware(pd.Timestamp('2020-01-01')) + assert datetime_.is_tz_aware(pd.Timestamp('2020-01-01', tz=datetime_.get_utc_tz())) def test_to_timezone(self): - assert datetime.to_timezone('UTC') == _timezone.utc - assert datetime.to_timezone('Europe/Berlin') == _timezone(_timedelta(hours=2)) - assert datetime.to_timezone('Europe/Berlin', to_py_timezone=False) == pytz.timezone('Europe/Berlin') - assert datetime.to_timezone('+0500') == _timezone(_timedelta(hours=5)) - assert datetime.to_timezone(_timezone(_timedelta(hours=1))) == _timezone(_timedelta(hours=1)) - assert datetime.to_timezone(pytz.timezone('Europe/Berlin')) == _timezone(_timedelta(hours=2)) - assert datetime.to_timezone(1) == _timezone(_timedelta(hours=1)) - assert datetime.to_timezone(0.5) == _timezone(_timedelta(hours=0.5)) + assert datetime_.to_timezone('UTC') == _timezone.utc + assert datetime_.to_timezone('Europe/Berlin') == _timezone(_timedelta(hours=2)) + assert datetime_.to_timezone('Europe/Berlin', to_py_timezone=False) == pytz.timezone('Europe/Berlin') + assert datetime_.to_timezone('+0500') == _timezone(_timedelta(hours=5)) + assert datetime_.to_timezone(_timezone(_timedelta(hours=1))) == _timezone(_timedelta(hours=1)) + assert datetime_.to_timezone(pytz.timezone('Europe/Berlin')) == _timezone(_timedelta(hours=2)) + assert datetime_.to_timezone(1) == _timezone(_timedelta(hours=1)) + assert datetime_.to_timezone(0.5) == _timezone(_timedelta(hours=0.5)) with pytest.raises(Exception): - _ = datetime.to_timezone('+05') + _ = datetime_.to_timezone('+05') def test_to_tzaware_datetime(self): - assert datetime.to_tzaware_datetime(0.5) == \ - _datetime(1970, 1, 1, 0, 0, 0, 500000, tzinfo=datetime.get_utc_tz()) - assert datetime.to_tzaware_datetime(0) == \ - _datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=datetime.get_utc_tz()) - assert datetime.to_tzaware_datetime(pd.Timestamp('2020-01-01').value) == \ - _datetime(2020, 1, 1).replace(tzinfo=datetime.get_utc_tz()) - assert datetime.to_tzaware_datetime('2020-01-01') == \ - _datetime(2020, 1, 1).replace(tzinfo=datetime.get_local_tz()) - assert datetime.to_tzaware_datetime(pd.Timestamp('2020-01-01')) == \ - _datetime(2020, 1, 1).replace(tzinfo=datetime.get_local_tz()) - assert datetime.to_tzaware_datetime(pd.Timestamp('2020-01-01', tz=datetime.get_utc_tz())) == \ - _datetime(2020, 1, 1).replace(tzinfo=datetime.get_utc_tz()) - assert datetime.to_tzaware_datetime(_datetime(2020, 1, 1)) == \ - _datetime(2020, 1, 1).replace(tzinfo=datetime.get_local_tz()) - assert datetime.to_tzaware_datetime(_datetime(2020, 1, 1, tzinfo=datetime.get_utc_tz())) == \ - _datetime(2020, 1, 1).replace(tzinfo=datetime.get_utc_tz()) - assert datetime.to_tzaware_datetime( - _datetime(2020, 1, 1, 12, 0, 0, tzinfo=datetime.get_utc_tz()), tz=datetime.get_local_tz()) == \ - _datetime(2020, 1, 1, 12, 0, 0, tzinfo=datetime.get_utc_tz()).astimezone(datetime.get_local_tz()) - with pytest.raises(Exception): - _ = datetime.to_tzaware_datetime('2020-01-001') + assert datetime_.to_tzaware_datetime(0.5) == \ + _datetime(1970, 1, 1, 0, 0, 0, 500000, tzinfo=datetime_.get_utc_tz()) + assert datetime_.to_tzaware_datetime(0) == \ + _datetime(1970, 1, 1, 0, 0, 0, 0, tzinfo=datetime_.get_utc_tz()) + assert datetime_.to_tzaware_datetime(pd.Timestamp('2020-01-01').value) == \ + _datetime(2020, 1, 1).replace(tzinfo=datetime_.get_utc_tz()) + assert datetime_.to_tzaware_datetime('2020-01-01') == \ + _datetime(2020, 1, 1).replace(tzinfo=datetime_.get_local_tz()) + assert datetime_.to_tzaware_datetime(pd.Timestamp('2020-01-01')) == \ + _datetime(2020, 1, 1).replace(tzinfo=datetime_.get_local_tz()) + assert datetime_.to_tzaware_datetime(pd.Timestamp('2020-01-01', tz=datetime_.get_utc_tz())) == \ + _datetime(2020, 1, 1).replace(tzinfo=datetime_.get_utc_tz()) + assert datetime_.to_tzaware_datetime(_datetime(2020, 1, 1)) == \ + _datetime(2020, 1, 1).replace(tzinfo=datetime_.get_local_tz()) + assert datetime_.to_tzaware_datetime(_datetime(2020, 1, 1, tzinfo=datetime_.get_utc_tz())) == \ + _datetime(2020, 1, 1).replace(tzinfo=datetime_.get_utc_tz()) + assert datetime_.to_tzaware_datetime( + _datetime(2020, 1, 1, 12, 0, 0, tzinfo=datetime_.get_utc_tz()), tz=datetime_.get_local_tz()) == \ + _datetime(2020, 1, 1, 12, 0, 0, tzinfo=datetime_.get_utc_tz()).astimezone(datetime_.get_local_tz()) + with pytest.raises(Exception): + _ = datetime_.to_tzaware_datetime('2020-01-001') def test_datetime_to_ms(self): - assert datetime.datetime_to_ms(_datetime(2020, 1, 1)) == \ + assert datetime_.datetime_to_ms(_datetime(2020, 1, 1)) == \ 1577836800000 - _datetime(2020, 1, 1).astimezone(None).utcoffset().total_seconds() * 1000 - assert datetime.datetime_to_ms(_datetime(2020, 1, 1, tzinfo=datetime.get_utc_tz())) == 1577836800000 + assert datetime_.datetime_to_ms(_datetime(2020, 1, 1, tzinfo=datetime_.get_utc_tz())) == 1577836800000 -# ############# schedule.py ############# # +# ############# schedule_.py ############# # class TestScheduleManager: def test_every(self): - manager = schedule.ScheduleManager() + manager = schedule_.ScheduleManager() job = manager.every() assert job.interval == 1 assert job.unit == 'seconds' @@ -2502,11 +2502,11 @@ def test_every(self): assert job.at_time == _time(10, 30) assert job.start_day is None - job = manager.every('day', _time(9, 30, tzinfo=datetime.get_utc_tz())) + job = manager.every('day', _time(9, 30, tzinfo=datetime_.get_utc_tz())) assert job.interval == 1 assert job.unit == 'days' - assert job.at_time == datetime.tzaware_to_naive_time( - _time(9, 30, tzinfo=datetime.get_utc_tz()), datetime.get_local_tz()) + assert job.at_time == datetime_.tzaware_to_naive_time( + _time(9, 30, tzinfo=datetime_.get_utc_tz()), datetime_.get_local_tz()) assert job.start_day is None job = manager.every('monday') @@ -2535,7 +2535,7 @@ def job_func(kwargs): if kwargs['call_count'] == 5: raise KeyboardInterrupt - manager = schedule.ScheduleManager() + manager = schedule_.ScheduleManager() manager.every().do(job_func, kwargs) manager.start() assert kwargs['call_count'] == 5 @@ -2546,9 +2546,9 @@ def test_async_start(self): def job_func(kwargs): kwargs['call_count'] += 1 if kwargs['call_count'] == 5: - raise schedule.CancelledError + raise schedule_.CancelledError - manager = schedule.ScheduleManager() + manager = schedule_.ScheduleManager() manager.every().do(job_func, kwargs) loop = asyncio.get_event_loop() loop.run_until_complete(manager.async_start()) diff --git a/vectorbt/__init__.py b/vectorbt/__init__.py index 62b1ad95..b5f43024 100644 --- a/vectorbt/__init__.py +++ b/vectorbt/__init__.py @@ -640,7 +640,7 @@ class method in order to be able to compute performance metrics such as the Shar from vectorbt.messaging import * # Import all submodules -from vectorbt.utils.module import import_submodules +from vectorbt.utils.module_ import import_submodules # silence NumbaExperimentalFeatureWarning import warnings diff --git a/vectorbt/_settings.py b/vectorbt/_settings.py index 40536073..6ad5699a 100644 --- a/vectorbt/_settings.py +++ b/vectorbt/_settings.py @@ -80,7 +80,7 @@ import plotly.graph_objects as go from vectorbt.utils.config import Config -from vectorbt.utils.datetime import get_local_tz, get_utc_tz +from vectorbt.utils.datetime_ import get_local_tz, get_utc_tz from vectorbt.utils.decorators import CacheCondition from vectorbt.utils.template import Sub, RepEval from vectorbt.base.array_wrapper import ArrayWrapper diff --git a/vectorbt/base/array_wrapper.py b/vectorbt/base/array_wrapper.py index a67d0886..afaa4dbc 100644 --- a/vectorbt/base/array_wrapper.py +++ b/vectorbt/base/array_wrapper.py @@ -92,10 +92,10 @@ from vectorbt import _typing as tp from vectorbt.utils import checks from vectorbt.utils.config import Configured, merge_dicts -from vectorbt.utils.datetime import freq_to_timedelta, DatetimeIndexes -from vectorbt.utils.array import get_ranges_arr +from vectorbt.utils.datetime_ import freq_to_timedelta, DatetimeIndexes +from vectorbt.utils.array_ import get_ranges_arr from vectorbt.utils.decorators import cached_method -from vectorbt.utils.attr import AttrResolver, AttrResolverT +from vectorbt.utils.attr_ import AttrResolver, AttrResolverT from vectorbt.base import index_fns, reshape_fns from vectorbt.base.indexing import IndexingError, PandasIndexer from vectorbt.base.column_grouper import ColumnGrouper diff --git a/vectorbt/base/column_grouper.py b/vectorbt/base/column_grouper.py index 5642a5b1..651f13e9 100644 --- a/vectorbt/base/column_grouper.py +++ b/vectorbt/base/column_grouper.py @@ -14,7 +14,7 @@ from vectorbt import _typing as tp from vectorbt.utils import checks -from vectorbt.utils.array import is_sorted +from vectorbt.utils.array_ import is_sorted from vectorbt.utils.decorators import cached_method from vectorbt.utils.config import Configured from vectorbt.base import index_fns diff --git a/vectorbt/data/base.py b/vectorbt/data/base.py index ea81482d..cd088651 100644 --- a/vectorbt/data/base.py +++ b/vectorbt/data/base.py @@ -265,7 +265,7 @@ from vectorbt import _typing as tp from vectorbt.utils import checks from vectorbt.utils.decorators import cached_method -from vectorbt.utils.datetime import is_tz_aware, to_timezone +from vectorbt.utils.datetime_ import is_tz_aware, to_timezone from vectorbt.utils.config import merge_dicts, Config from vectorbt.base.array_wrapper import ArrayWrapper, Wrapping from vectorbt.generic.stats_builder import StatsBuilderMixin diff --git a/vectorbt/data/custom.py b/vectorbt/data/custom.py index c3207a7a..b3647b85 100644 --- a/vectorbt/data/custom.py +++ b/vectorbt/data/custom.py @@ -11,7 +11,7 @@ from functools import wraps from vectorbt import _typing as tp -from vectorbt.utils.datetime import ( +from vectorbt.utils.datetime_ import ( get_utc_tz, get_local_tz, to_tzaware_datetime, diff --git a/vectorbt/data/updater.py b/vectorbt/data/updater.py index b0f7f180..f425fcba 100644 --- a/vectorbt/data/updater.py +++ b/vectorbt/data/updater.py @@ -6,7 +6,7 @@ import logging from vectorbt import _typing as tp -from vectorbt.utils.schedule import ScheduleManager +from vectorbt.utils.schedule_ import ScheduleManager from vectorbt.utils.config import Configured from vectorbt.data.base import Data diff --git a/vectorbt/generic/plots_builder.py b/vectorbt/generic/plots_builder.py index feba0e8b..0aec50db 100644 --- a/vectorbt/generic/plots_builder.py +++ b/vectorbt/generic/plots_builder.py @@ -13,7 +13,7 @@ from vectorbt.utils.config import Config, merge_dicts, get_func_arg_names from vectorbt.utils.template import deep_substitute from vectorbt.utils.tags import match_tags -from vectorbt.utils.attr import get_dict_attr +from vectorbt.utils.attr_ import get_dict_attr from vectorbt.utils.figure import make_subplots, get_domain from vectorbt.base.array_wrapper import Wrapping diff --git a/vectorbt/generic/plotting.py b/vectorbt/generic/plotting.py index f219c14f..ae743d0f 100644 --- a/vectorbt/generic/plotting.py +++ b/vectorbt/generic/plotting.py @@ -22,7 +22,7 @@ from vectorbt import _typing as tp from vectorbt.utils import checks from vectorbt.utils.figure import make_figure -from vectorbt.utils.array import renormalize +from vectorbt.utils.array_ import renormalize from vectorbt.utils.colors import rgb_from_cmap from vectorbt.utils.config import Configured, resolve_dict from vectorbt.base import reshape_fns diff --git a/vectorbt/generic/stats_builder.py b/vectorbt/generic/stats_builder.py index eb610160..edfafb1e 100644 --- a/vectorbt/generic/stats_builder.py +++ b/vectorbt/generic/stats_builder.py @@ -15,7 +15,7 @@ from vectorbt.utils.config import Config, merge_dicts, get_func_arg_names from vectorbt.utils.template import deep_substitute from vectorbt.utils.tags import match_tags -from vectorbt.utils.attr import get_dict_attr +from vectorbt.utils.attr_ import get_dict_attr from vectorbt.base.array_wrapper import Wrapping diff --git a/vectorbt/indicators/factory.py b/vectorbt/indicators/factory.py index 087ed561..15e754de 100644 --- a/vectorbt/indicators/factory.py +++ b/vectorbt/indicators/factory.py @@ -1176,9 +1176,9 @@ from vectorbt.utils import checks from vectorbt.utils.decorators import classproperty, cached_property from vectorbt.utils.config import merge_dicts, resolve_dict, Config, Default -from vectorbt.utils.random import set_seed +from vectorbt.utils.random_ import set_seed from vectorbt.utils.params import to_typed_list, broadcast_params, create_param_product -from vectorbt.utils.enum import map_enum_fields +from vectorbt.utils.enum_ import map_enum_fields from vectorbt.utils.mapping import to_mapping, apply_mapping from vectorbt.utils.docs import to_doc from vectorbt.base import index_fns, reshape_fns, combine_fns diff --git a/vectorbt/messaging/telegram.py b/vectorbt/messaging/telegram.py index 2b2e3557..efa7ee49 100644 --- a/vectorbt/messaging/telegram.py +++ b/vectorbt/messaging/telegram.py @@ -22,7 +22,7 @@ from vectorbt import _typing as tp from vectorbt.utils.config import merge_dicts, get_func_kwargs, Configured -from vectorbt.utils.requests import text_to_giphy_url +from vectorbt.utils.requests_ import text_to_giphy_url logger = logging.getLogger(__name__) diff --git a/vectorbt/portfolio/base.py b/vectorbt/portfolio/base.py index e4facc03..8144f433 100644 --- a/vectorbt/portfolio/base.py +++ b/vectorbt/portfolio/base.py @@ -1418,10 +1418,10 @@ from vectorbt import _typing as tp from vectorbt.utils import checks from vectorbt.utils.decorators import cached_property, cached_method -from vectorbt.utils.enum import map_enum_fields +from vectorbt.utils.enum_ import map_enum_fields from vectorbt.utils.config import merge_dicts, Config from vectorbt.utils.template import RepEval, deep_substitute -from vectorbt.utils.random import set_seed +from vectorbt.utils.random_ import set_seed from vectorbt.utils.colors import adjust_opacity from vectorbt.utils.figure import get_domain from vectorbt.base.reshape_fns import to_1d_array, to_2d_array, broadcast, broadcast_to, to_pd_array diff --git a/vectorbt/portfolio/nb.py b/vectorbt/portfolio/nb.py index a0aaa474..33a1c5c1 100644 --- a/vectorbt/portfolio/nb.py +++ b/vectorbt/portfolio/nb.py @@ -51,13 +51,13 @@ from numba import njit from vectorbt import _typing as tp -from vectorbt.utils.math import ( +from vectorbt.utils.math_ import ( is_close_nb, is_close_or_less_nb, is_less_nb, add_nb ) -from vectorbt.utils.array import insert_argsort_nb +from vectorbt.utils.array_ import insert_argsort_nb from vectorbt.base.reshape_fns import flex_select_auto_nb from vectorbt.generic import nb as generic_nb from vectorbt.returns import nb as returns_nb diff --git a/vectorbt/portfolio/trades.py b/vectorbt/portfolio/trades.py index fb9ae20c..80b7c739 100644 --- a/vectorbt/portfolio/trades.py +++ b/vectorbt/portfolio/trades.py @@ -488,7 +488,7 @@ from vectorbt.utils.colors import adjust_lightness from vectorbt.utils.config import merge_dicts, Config from vectorbt.utils.figure import make_figure, get_domain -from vectorbt.utils.array import min_rel_rescale, max_rel_rescale +from vectorbt.utils.array_ import min_rel_rescale, max_rel_rescale from vectorbt.utils.template import RepEval from vectorbt.utils.decorators import cached_method, cached_property from vectorbt.base.reshape_fns import to_1d_array, to_2d_array diff --git a/vectorbt/records/base.py b/vectorbt/records/base.py index d61a48a3..c85c4c83 100644 --- a/vectorbt/records/base.py +++ b/vectorbt/records/base.py @@ -398,7 +398,7 @@ from vectorbt.utils import checks from vectorbt.utils.decorators import cached_method from vectorbt.utils.config import merge_dicts, Config, Configured -from vectorbt.utils.attr import get_dict_attr +from vectorbt.utils.attr_ import get_dict_attr from vectorbt.base.reshape_fns import to_1d_array from vectorbt.base.array_wrapper import ArrayWrapper, Wrapping from vectorbt.generic.stats_builder import StatsBuilderMixin diff --git a/vectorbt/returns/accessors.py b/vectorbt/returns/accessors.py index 958c959a..85073309 100644 --- a/vectorbt/returns/accessors.py +++ b/vectorbt/returns/accessors.py @@ -144,7 +144,7 @@ from vectorbt.utils import checks from vectorbt.utils.config import merge_dicts, Config from vectorbt.utils.figure import make_figure, get_domain -from vectorbt.utils.datetime import freq_to_timedelta, DatetimeIndexes +from vectorbt.utils.datetime_ import freq_to_timedelta, DatetimeIndexes from vectorbt.base.reshape_fns import to_1d_array, to_2d_array, broadcast, broadcast_to from vectorbt.base.array_wrapper import ArrayWrapper, Wrapping from vectorbt.generic.drawdowns import Drawdowns diff --git a/vectorbt/signals/factory.py b/vectorbt/signals/factory.py index f64f2e15..3888721d 100644 --- a/vectorbt/signals/factory.py +++ b/vectorbt/signals/factory.py @@ -17,7 +17,7 @@ from vectorbt.utils import checks from vectorbt.utils.config import merge_dicts from vectorbt.utils.params import to_typed_list -from vectorbt.utils.enum import map_enum_fields +from vectorbt.utils.enum_ import map_enum_fields from vectorbt.base import combine_fns from vectorbt.indicators.factory import IndicatorFactory, IndicatorBase, CacheOutputT from vectorbt.signals.nb import ( diff --git a/vectorbt/signals/nb.py b/vectorbt/signals/nb.py index 95cc3d4e..5cd4ca3b 100644 --- a/vectorbt/signals/nb.py +++ b/vectorbt/signals/nb.py @@ -29,7 +29,7 @@ import numpy as np from vectorbt import _typing as tp -from vectorbt.utils.array import uniform_summing_to_one_nb, rescale_float_to_int_nb, renormalize_nb +from vectorbt.utils.array_ import uniform_summing_to_one_nb, rescale_float_to_int_nb, renormalize_nb from vectorbt.base.reshape_fns import flex_select_auto_nb from vectorbt.generic.enums import range_dt, RangeStatus from vectorbt.signals.enums import StopType diff --git a/vectorbt/utils/__init__.py b/vectorbt/utils/__init__.py index 56333bc5..d4d93c76 100644 --- a/vectorbt/utils/__init__.py +++ b/vectorbt/utils/__init__.py @@ -7,9 +7,9 @@ from vectorbt.utils.template import Sub, Rep, RepEval, RepFunc, deep_substitute from vectorbt.utils.decorators import CacheCondition, cached_property, cached_method from vectorbt.utils.figure import Figure, FigureWidget, make_figure, make_subplots -from vectorbt.utils.random import set_seed -from vectorbt.utils.image import save_animation -from vectorbt.utils.schedule import AsyncJob, AsyncScheduler, CancelledError, ScheduleManager +from vectorbt.utils.random_ import set_seed +from vectorbt.utils.image_ import save_animation +from vectorbt.utils.schedule_ import AsyncJob, AsyncScheduler, CancelledError, ScheduleManager __all__ = [ 'atomic_dict', diff --git a/vectorbt/utils/array.py b/vectorbt/utils/array_.py similarity index 100% rename from vectorbt/utils/array.py rename to vectorbt/utils/array_.py diff --git a/vectorbt/utils/attr.py b/vectorbt/utils/attr_.py similarity index 100% rename from vectorbt/utils/attr.py rename to vectorbt/utils/attr_.py diff --git a/vectorbt/utils/datetime.py b/vectorbt/utils/datetime_.py similarity index 100% rename from vectorbt/utils/datetime.py rename to vectorbt/utils/datetime_.py diff --git a/vectorbt/utils/enum.py b/vectorbt/utils/enum_.py similarity index 100% rename from vectorbt/utils/enum.py rename to vectorbt/utils/enum_.py diff --git a/vectorbt/utils/image.py b/vectorbt/utils/image_.py similarity index 100% rename from vectorbt/utils/image.py rename to vectorbt/utils/image_.py diff --git a/vectorbt/utils/math.py b/vectorbt/utils/math_.py similarity index 100% rename from vectorbt/utils/math.py rename to vectorbt/utils/math_.py diff --git a/vectorbt/utils/module.py b/vectorbt/utils/module_.py similarity index 100% rename from vectorbt/utils/module.py rename to vectorbt/utils/module_.py diff --git a/vectorbt/utils/random.py b/vectorbt/utils/random_.py similarity index 100% rename from vectorbt/utils/random.py rename to vectorbt/utils/random_.py diff --git a/vectorbt/utils/requests.py b/vectorbt/utils/requests_.py similarity index 100% rename from vectorbt/utils/requests.py rename to vectorbt/utils/requests_.py diff --git a/vectorbt/utils/schedule.py b/vectorbt/utils/schedule_.py similarity index 99% rename from vectorbt/utils/schedule.py rename to vectorbt/utils/schedule_.py index bbc840d4..d6e5a483 100644 --- a/vectorbt/utils/schedule.py +++ b/vectorbt/utils/schedule_.py @@ -11,7 +11,7 @@ import inspect from vectorbt import _typing as tp -from vectorbt.utils.datetime import tzaware_to_naive_time +from vectorbt.utils.datetime_ import tzaware_to_naive_time from vectorbt.utils import checks logger = logging.getLogger(__name__)