# tf_agents.utils.numpy_storage.NumpyStorage

<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/utils/numpy_storage.py#L176-L242) |

A class to store nested objects in a collection of numpy arrays.

    tf_agents.utils.numpy_storage.NumpyStorage(
        data_spec, capacity
    )

If a data_spec of `{'foo': ArraySpec(shape=(4,), dtype=np.uint8), 'bar':
ArraySpec(shape=(3, 7), dtype=np.float32)}` were used, then this would create
two arrays, one for the 'foo' key and one for the 'bar' key. The .get and
.set methods would return/take Python dictionaries, but break down the
component arrays before storing them.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `data_spec` | An ArraySpec or a list/tuple/nest of ArraySpecs describing a single item that can be stored in this table. |
| `capacity` | The maximum number of items that can be stored in the buffer. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If data_spec is not an instance or nest of ArraySpecs. |

<br />

## Methods

### `get`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/utils/numpy_storage.py#L232-L237)

    get(
        idx
    )

Get value stored at idx.

### `set`

[View source](https://github.com/tensorflow/agents/blob/v0.19.0/tf_agents/utils/numpy_storage.py#L239-L242)

    set(
        table_idx, value
    )

Set table_idx to value.