bundles / numpy latest / numpy / random / bit_generator / _coerce_to_uint32_array
cython_function_or_method
numpy.random.bit_generator:_coerce_to_uint32_array
Signature
def _coerce_to_uint32_array ( x ) Summary
Coerce an input to a uint32 array.
Extended Summary
If a uint32 array, pass it through directly. If a non-negative integer, then break it up into uint32 words, lowest bits first. If a string starting with "0x", then interpret as a hex integer, as above. If a string of decimal digits, interpret as a decimal integer, as above. If a sequence of ints or strings, interpret each element as above and concatenate.
Note that the handling of int64 or uint64 arrays are not just straightforward views as uint32 arrays. If an element is small enough to fit into a uint32, then it will only take up one uint32 element in the output. This is to make sure that the interpretation of a sequence of integers is the same regardless of numpy's default integer type, which differs on different platforms.
Parameters
x: int, str, sequence of int or str
Returns
seed_array: uint32 array
Examples
import numpy as np from numpy.random.bit_generator import _coerce_to_uint32_array _coerce_to_uint32_array(12345) _coerce_to_uint32_array('12345') _coerce_to_uint32_array('0x12345') _coerce_to_uint32_array([12345, '67890']) _coerce_to_uint32_array(np.array([12345, 67890], dtype=np.uint32)) _coerce_to_uint32_array(np.array([12345, 67890], dtype=np.int64)) _coerce_to_uint32_array([12345, 0x10deadbeef, 67890, 0xdeadbeef]) _coerce_to_uint32_array(1234567890123456789012345678901234567890)✓
Aliases
-
numpy.random.bit_generator._coerce_to_uint32_array