# tf_agents.specs.BoundedArraySpec

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L270-L458) |

An `ArraySpec` that specifies minimum and maximum values.

Inherits From: [`ArraySpec`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/specs/ArraySpec)

#### View aliases


**Main aliases**

[`tf_agents.specs.array_spec.BoundedArraySpec`](https://www.tensorflow.org/agents/api_docs/python/tf_agents/specs/BoundedArraySpec)

<br />

    tf_agents.specs.BoundedArraySpec(
        shape, dtype, minimum=None, maximum=None, name=None
    )

### Used in the notebooks

| Used in the tutorials |
|---|
| - [Tutorial on Multi Armed Bandits in TF-Agents](https://www.tensorflow.org/agents/tutorials/bandits_tutorial) - [Networks](https://www.tensorflow.org/agents/tutorials/8_networks_tutorial) - [Environments](https://www.tensorflow.org/agents/tutorials/2_environments_tutorial) - [Policies](https://www.tensorflow.org/agents/tutorials/3_policies_tutorial) |

#### Example usage:

    # Specifying the same minimum and maximum for every element.
    spec = BoundedArraySpec((3, 4), np.float64, minimum=0.0, maximum=1.0)

    # Specifying a different minimum and maximum for each element.
    spec = BoundedArraySpec(
        (2,), np.float64, minimum=[0.1, 0.2], maximum=[0.9, 0.9])

    # Specifying the same minimum and a different maximum for each element.
    spec = BoundedArraySpec(
        (3,), np.float64, minimum=-10.0, maximum=[4.0, 5.0, 3.0])

Bounds are meant to be inclusive. This is especially important for
integer types. The following spec will be satisfied by arrays
with values in the set {0, 1, 2}:

    spec = BoundedArraySpec((3, 4), np.int, minimum=0, maximum=2)

<br />

<br />

<br />

| ## Args ||
|---|---|
| `shape` | An iterable specifying the array shape. |
| `dtype` | numpy dtype or string specifying the array dtype. |
| `minimum` | Number or sequence specifying the maximum element bounds (inclusive). Must be broadcastable to `shape`. |
| `maximum` | Number or sequence specifying the maximum element bounds (inclusive). Must be broadcastable to `shape`. |
| `name` | Optional string containing a semantic name for the corresponding array. Defaults to `None`. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `minimum` or `maximum` are not broadcastable to `shape` or if the limits are outside of the range of the specified dtype. |
| `TypeError` | If the shape is not an iterable or if the `dtype` is an invalid numpy dtype. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `dtype` | Returns a numpy dtype specifying the array dtype. |
| `maximum` | Returns a NumPy array specifying the maximum bounds (inclusive). |
| `minimum` | Returns a NumPy array specifying the minimum bounds (inclusive). |
| `name` | Returns the name of the ArraySpec. |
| `num_values` | Returns the number of values for discrete BoundedArraySpec. |
| `shape` | Returns a `tuple` specifying the array shape. |

<br />

## Methods

### `check_array`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L436-L442)

    check_array(
        array
    )

Return true if the given array conforms to the spec.

### `from_array`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L248-L256)

    @staticmethod
    from_array(
        array, name=None
    )

Construct a spec from the given array or number.

### `from_spec`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L383-L393)

    @classmethod
    from_spec(
        spec, name=None
    )

Construct a spec from the given spec.

### `replace`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L444-L452)

    replace(
        shape=None, dtype=None, minimum=None, maximum=None, name=None
    )

### `__eq__`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L427-L434)

    __eq__(
        other
    )

Checks if the shape and dtype of two specs are equal.

### `__ne__`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/specs/array_spec.py#L224-L225)

    __ne__(
        other
    )

Return self!=value.