get_key_data

Contents

get_key_data#

class brainstate.random.get_key_data#

Get the current global random key as raw uint32[2] data.

This is the legacy-interop counterpart of get_key(). It returns the underlying key data (a 2-element uint32 array) extracted from the current typed key via jax.random.key_data(). This is useful when interfacing with code that still expects the old uint32[2] key representation.

Return type:

Array

Examples

>>> import brainstate
>>> import jax.random as jr
>>> brainstate.random.set_key(jr.key(11))
>>> data = brainstate.random.get_key_data()
>>> print(data.shape, data.dtype)
(2,) uint32

See also

get_key

Get the current typed key

set_key

Set a new random key (accepts raw uint32[2] too)