How to use the yarl.spaces.OBSOLETE.continuous.Continuous function in yarl

To help you get started, we’ve selected a few yarl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rlgraph / rlgraph / yarl / spaces / OBSOLETE / continuous.py View on Github external
def __eq__(self, other):
        return isinstance(other, Continuous) and np.allclose(self.low, other.low) and np.allclose(self.high, other.high)
github rlgraph / rlgraph / yarl / spaces / OBSOLETE / intbox.py View on Github external
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from .continuous import Continuous
import numpy as np


# OBSOLETE: This should be replaced by the new generic Box class.
class IntBox(Continuous):
    """
    A box in Z^n (only integers; each coordinate is bounded)
    e.g. an image (w x h x RGB) where each color channel pixel can be between 0 and 255.
    """
    def __init__(self, low=None, high=None, shape=None, add_batch_rank=False, dtype="int32"):
        """
        Three kinds of valid input:
            IntBox(0, 1) # low and high are given as scalars and shape is assumed to be ()
            IntBox(-1, 1, (3,4)) # low and high are scalars, and shape is provided
            IntBox(np.array([-1,-2]), np.array([2,4])) # low and high are arrays of the same shape (no shape given!)

        Args:
            dtype (str): The underlying data-type of this Space.
        """
        if not isinstance(low, int) or not isinstance(high, int):
            assert low is None or low.shape == high.shape
github rlgraph / rlgraph / yarl / spaces / OBSOLETE / continuous.py View on Github external
"""
        Args:
            low (any): The lower bound (see Valid Inputs for more information).
            high (any): The upper bound (see Valid Inputs for more information).
            shape (tuple): The shape of this space.

        Valid inputs:
            Continuous(0.0, 1.0) # low and high are given as scalars and shape is assumed to be ()
                -> single scalar between low and high.
            Continuous(-1.0, 1.0, (3,4)) # low and high are scalars, and shape is provided -> nD array
                where all(!) elements are between low and high.
            Continuous(np.array([-1.0,-2.0]), np.array([2.0,4.0])) # low and high are arrays of the same shape
                (no shape given!) -> nD array where each dimension has different bounds.
            Continuous(None, None, (2,3,4)) # low and high are not given (unknown).
        """
        super(Continuous, self).__init__(add_batch_rank=add_batch_rank)
        self.is_scalar = False  # whether we are a single scalar (shape=())
        self.has_unknown_bounds = False
        self.has_flex_bounds = False

        # Single value (may be bounded)
        if shape is None or shape == ():
            if isinstance(low, (int, float)) and isinstance(high, (int, float)):
                assert low < high
                self.low = float(low)
                self.high = float(high)
                self.is_scalar = True
            elif low is None:
                assert high is None
                self.has_unknown_bounds = True
                self.has_flex_bounds = True
                self.is_scalar = True