Fix reward of SimpleMultiObsEnv to always be float (#1676)

* Fix reward of SimpleMultiObsEnv to always be float

Previously the reward was sometimes returned as an int.

* changelog

* Update changelog.rst

* Update version.txt

* Fix type annotation

* Fix import

---------

Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
Co-authored-by: Antonin Raffin <antonin.raffin@ensta.org>
This commit is contained in:
Nicholas Goldowsky-Dill 2023-09-15 23:56:04 -07:00 committed by GitHub
parent 99712760c8
commit 1cd6ae42d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 5 deletions

View file

@ -3,7 +3,7 @@
Changelog
==========
Release 2.2.0a2 (WIP)
Release 2.2.0a3 (WIP)
--------------------------
Breaking Changes:
@ -32,6 +32,7 @@ Bug Fixes:
- Calls ``callback.update_locals()`` before ``callback.on_rollout_end()`` in OnPolicyAlgorithm (@PatrickHelm)
- Fixed replay buffer device after loading in OffPolicyAlgorithm (@PatrickHelm)
- Fixed ``render_mode`` which was not properly loaded when using ``VecNormalize.load()``
- Fixed success reward dtype in ``SimpleMultiObsEnv`` (@NixGD)
Deprecations:

View file

@ -150,7 +150,7 @@ class SimpleMultiObsEnv(gym.Env):
self.state -= self.num_col
got_to_end = self.state == self.max_state
reward = 1 if got_to_end else reward
reward = 1.0 if got_to_end else reward
truncated = self.count > self.max_count
terminated = got_to_end

View file

@ -8,10 +8,10 @@ from collections import defaultdict
from io import TextIOBase
from typing import Any, Dict, List, Mapping, Optional, Sequence, TextIO, Tuple, Union
import matplotlib.figure
import numpy as np
import pandas
import torch as th
from matplotlib import pyplot as plt
try:
from torch.utils.tensorboard import SummaryWriter
@ -52,7 +52,7 @@ class Figure:
:param close: if true, close the figure after logging it
"""
def __init__(self, figure: plt.figure, close: bool):
def __init__(self, figure: matplotlib.figure.Figure, close: bool):
self.figure = figure
self.close = close

View file

@ -1 +1 @@
2.2.0a2
2.2.0a3