galois.typing.ShapeLike

A Union representing objects that can be coerced into a NumPy shape tuple.

Union

  • int: The size of a 1-D array.

    In [1]: GF = galois.GF(3**5)
    
    In [2]: x = GF.Random(4); x
    Out[2]: GF([ 10, 124, 192, 136], order=3^5)
    
    In [3]: x.shape
    Out[3]: (4,)
    
  • Sequence [ int ]: An iterable of integer dimensions. Tuples or lists are allowed. An empty iterable, () or [], represents a 0-D array (scalar).

    In [4]: x = GF.Random((2, 3)); x
    Out[4]: 
    GF([[ 40, 106, 196],
        [ 32, 192, 107]], order=3^5)
    
    In [5]: x.shape
    Out[5]: (2, 3)
    
    In [6]: x = GF.Random([2, 3, 4]); x
    Out[6]: 
    GF([[[ 42, 230, 218,   5],
         [104, 203, 160, 183],
         [216,  52, 165,  41]],
    
        [[208,   8, 225, 149],
         [206, 221,  14, 111],
         [ 62, 176, 200, 187]]], order=3^5)
    
    In [7]: x.shape
    Out[7]: (2, 3, 4)
    
    In [8]: x = GF.Random(()); x
    Out[8]: GF(29, order=3^5)
    
    In [9]: x.shape
    Out[9]: ()
    

Alias

alias of Union[int, Sequence[int]]