diff --git a/sysdata/tests/test_config.py b/sysdata/tests/test_config.py index d7ffbf9afa..2035371392 100644 --- a/sysdata/tests/test_config.py +++ b/sysdata/tests/test_config.py @@ -1,7 +1,6 @@ from sysdata.config.configdata import Config from sysdata.config.control_config import get_control_config from sysdata.config.private_directory import PRIVATE_CONFIG_DIR_ENV_VAR -import os class TestConfig: @@ -11,16 +10,16 @@ def test_default(self): assert config.get_element("ib_idoffset") == 100 def test_custom_dir(self, monkeypatch): - envs = {PRIVATE_CONFIG_DIR_ENV_VAR: "sysdata.tests.custom_private_config"} - monkeypatch.setattr(os, "environ", envs) + monkeypatch.setenv( + PRIVATE_CONFIG_DIR_ENV_VAR, "sysdata.tests.custom_private_config" + ) Config.reset() config = Config.default_config() assert config.get_element("ib_idoffset") == 1000 def test_bad_custom_dir(self, monkeypatch): - envs = {PRIVATE_CONFIG_DIR_ENV_VAR: "sysdata.tests"} - monkeypatch.setattr(os, "environ", envs) + monkeypatch.setenv(PRIVATE_CONFIG_DIR_ENV_VAR, "sysdata.tests") Config.reset() config = Config.default_config() @@ -34,8 +33,9 @@ def test_default_control(self): ) def test_control_custom_dir(self, monkeypatch): - envs = {PRIVATE_CONFIG_DIR_ENV_VAR: "sysdata.tests.custom_private_config"} - monkeypatch.setattr(os, "environ", envs) + monkeypatch.setenv( + PRIVATE_CONFIG_DIR_ENV_VAR, "sysdata.tests.custom_private_config" + ) config = get_control_config() assert ( @@ -44,8 +44,7 @@ def test_control_custom_dir(self, monkeypatch): ) def test_control_bad_custom_dir(self, monkeypatch): - envs = {PRIVATE_CONFIG_DIR_ENV_VAR: "sysdata.tests"} - monkeypatch.setattr(os, "environ", envs) + monkeypatch.setenv(PRIVATE_CONFIG_DIR_ENV_VAR, "sysdata.tests") config = get_control_config() assert ( diff --git a/systems/accounts/curves/account_curve.py b/systems/accounts/curves/account_curve.py index 9e238958d4..af746eeb4e 100644 --- a/systems/accounts/curves/account_curve.py +++ b/systems/accounts/curves/account_curve.py @@ -277,7 +277,7 @@ def sortino(self): return sortino def vals(self): - vals = self.values[~np.isnan(self.values)] + vals = pd.to_numeric(self.values[~pd.isnull(self.values)], errors="coerce") return vals diff --git a/systems/tests/test_position_sizing.py b/systems/tests/test_position_sizing.py index b0676dc816..b81025b357 100644 --- a/systems/tests/test_position_sizing.py +++ b/systems/tests/test_position_sizing.py @@ -29,6 +29,9 @@ def setUp(self): self.data = data self.position_sizing = PositionSizing + def tearDown(self) -> None: + self.monkeypatch.undo() + @unittest.SkipTest def test_get_combined_forecast(self): self.assertAlmostEqual( @@ -60,8 +63,9 @@ def test_get_instrument_sizing_data(self): self.assertEqual(ans[1], 2500) def test_get_daily_cash_vol_target(self): - envs = {PRIVATE_CONFIG_DIR_ENV_VAR: "sysdata.tests.custom_private_config"} - self.monkeypatch.setattr(os, "environ", envs) + self.monkeypatch.setenv( + PRIVATE_CONFIG_DIR_ENV_VAR, "sysdata.tests.custom_private_config" + ) ans_dict = self.system.positionSize.get_vol_target_dict() self.assertEqual(ans_dict["base_currency"], "GBP")