From b8568c6af4a61070f9011c175b1702ceb88d16f4 Mon Sep 17 00:00:00 2001 From: haoshengzou Date: Thu, 25 Jan 2018 10:15:38 +0800 Subject: [PATCH] added data/utils.py. was ignored by .gitignore before... --- tianshou/data/.gitignore | 2 +- tianshou/data/utils.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tianshou/data/utils.py diff --git a/tianshou/data/.gitignore b/tianshou/data/.gitignore index 15584ca..0d20b64 100644 --- a/tianshou/data/.gitignore +++ b/tianshou/data/.gitignore @@ -1 +1 @@ -.pyc +*.pyc diff --git a/tianshou/data/utils.py b/tianshou/data/utils.py new file mode 100644 index 0000000..d073aeb --- /dev/null +++ b/tianshou/data/utils.py @@ -0,0 +1,21 @@ +# internal key match + +def internal_key_match(key, keys): + """ + internal rule for key matching between placeholders and data + :param key: + :param keys: + :return: a bool and a data key + """ + if key == 'advantage': + if key in keys: + return True, key + elif 'return' in keys: + return True, 'return' + else: + return False, None + else: + if key in keys: + return True, key + else: + return False, None \ No newline at end of file