dutype#
- class brainstate.environ.dutype(*, env=None)[source]#
Get the default unsigned integer data type.
This function returns the appropriate unsigned integer type based on the current precision setting.
- Parameters:
env (
EnvironmentState|None) – The environment state to query. If None, uses the global environment.- Returns:
Default unsigned integer data type.
- Return type:
Examples
>>> import brainstate.environ as env >>> import jax.numpy as jnp >>> >>> # With 32-bit precision >>> env.set(precision=32) >>> counts = jnp.array([10, 20, 30], dtype=env.dutype()) >>> print(counts.dtype) # uint32 >>> >>> # With 16-bit precision >>> with env.context(precision=16): ... small_counts = jnp.array([1, 2, 3], dtype=env.dutype()) ... print(small_counts.dtype) # uint16
Using custom environment:
>>> import brainstate.environ as env >>> >>> custom_env = env.EnvironmentState() >>> env.set(precision=64, env=custom_env) >>> print(env.dutype(env=custom_env)) # uint64
See also
ditypeDefault signed integer type