Skip to content

Commit

Permalink
fixing param overwrite bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rallen10 committed Nov 29, 2023
1 parent 101f528 commit 4403f0d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/kspdg/lbg1/lbg1_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion src/kspdg/pe1/pe1_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/kspdg/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 7 additions & 2 deletions tests/ksp_ingame_tests/test_pe1_e1_i3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)

0 comments on commit 4403f0d

Please sign in to comment.