Flags actions immutable to notify users when trying to change them.

Can also be used with any tree-like structure containing either dictionaries, numpy arrays or already immutable objects per se. Note, however that tree.map_structure() will in general not include the shallow object containing all others and therefore immutability will hold only for all objects contained in it. Use tree.traverse(fun, action, top_down=False) to include also the containing object.


obj – The object to be made immutable.


The immutable object.

import tree
import numpy as np
from ray.rllib.utils.numpy import make_action_immutable
arr = np.arange(1,10)
d = dict(a = 1, b = (arr, arr))
tree.traverse(make_action_immutable, d, top_down=False)