From 4403f0dc12dea3c509d8a66924769e9717d5fc0b Mon Sep 17 00:00:00 2001 From: Ross Allen Date: Wed, 29 Nov 2023 09:02:17 -0800 Subject: [PATCH] fixing param overwrite bug --- CHANGELOG.md | 12 ++++++++++++ src/kspdg/lbg1/lbg1_base.py | 3 ++- src/kspdg/pe1/pe1_base.py | 3 ++- src/kspdg/version.py | 2 +- tests/ksp_ingame_tests/test_pe1_e1_i3.py | 9 +++++++-- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1ee0bf..84f478a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v0.4.3] - 2023-11-29 + +### Added + +### Fixed + +- bug where PARAMS from LBG1 classes overwrite PARAMS in PE1 classes due to top-level imports at kspdg/__init__.py. + +### Changed + +### Removed + ## [v0.4.2] - 2023-11-28 ### Added diff --git a/src/kspdg/lbg1/lbg1_base.py b/src/kspdg/lbg1/lbg1_base.py index 01f55ba..c404914 100644 --- a/src/kspdg/lbg1/lbg1_base.py +++ b/src/kspdg/lbg1/lbg1_base.py @@ -11,6 +11,7 @@ from types import SimpleNamespace from typing import List, Dict from numpy.typing import ArrayLike +from copy import deepcopy import kspdg.utils.constants as C import kspdg.utils.utils as U @@ -44,7 +45,7 @@ class LadyBanditGuardGroup1Env(Group1BaseEnv): # in observation which should really only be variable values) # Need for hard-coding rsc properties comes from the errors in # krpc's handling of thruster objects. - PARAMS = Group1BaseEnv.PARAMS + PARAMS = deepcopy(Group1BaseEnv.PARAMS) PARAMS.LADY= SimpleNamespace() PARAMS.BANDIT = SimpleNamespace() PARAMS.GUARD = SimpleNamespace() diff --git a/src/kspdg/pe1/pe1_base.py b/src/kspdg/pe1/pe1_base.py index 053b8fb..648a855 100644 --- a/src/kspdg/pe1/pe1_base.py +++ b/src/kspdg/pe1/pe1_base.py @@ -8,6 +8,7 @@ from types import SimpleNamespace from typing import List, Dict +from copy import deepcopy import kspdg.utils.constants as C import kspdg.utils.utils as U @@ -38,7 +39,7 @@ class PursuitEvadeGroup1Env(Group1BaseEnv): # in observation which should really only be variable values) # Need for hard-coding rsc properties comes from the errors in # krpc's handling of thruster objects. - PARAMS = Group1BaseEnv.PARAMS + PARAMS = deepcopy(Group1BaseEnv.PARAMS) PARAMS.PURSUER = SimpleNamespace() PARAMS.EVADER = SimpleNamespace() PARAMS.PURSUER.RCS = SimpleNamespace() diff --git a/src/kspdg/version.py b/src/kspdg/version.py index f704537..b2ef0fd 100644 --- a/src/kspdg/version.py +++ b/src/kspdg/version.py @@ -5,4 +5,4 @@ # Single-sourcing package version # https://packaging.python.org/guides/single-sourcing-package-version/ -VERSION = "0.4.2" +VERSION = "0.4.3" diff --git a/tests/ksp_ingame_tests/test_pe1_e1_i3.py b/tests/ksp_ingame_tests/test_pe1_e1_i3.py index d23c0d5..79a9647 100644 --- a/tests/ksp_ingame_tests/test_pe1_e1_i3.py +++ b/tests/ksp_ingame_tests/test_pe1_e1_i3.py @@ -26,7 +26,11 @@ def pe1_e1_i3_env(): def test_observation_dict_list_convert_0(pe1_e1_i3_env): '''check that converting between lists and dict to not alter observation''' # ~~ ARRANGE ~~ - env = pe1_e1_i3_env + if pe1_e1_i3_env is None: + env = PE1_E1_I3_Env() + env.reset() + else: + env = pe1_e1_i3_env # collect current observation as list obs_list = env.get_observation() @@ -379,4 +383,5 @@ def test_step_action_ref_frame_2(pe1_e1_i3_env): assert np.isclose(v0, v1) if __name__ == "__main__": - test_get_info_0(None) + # test_get_info_0(None) + test_observation_dict_list_convert_0(None)