-
classmethod galois.Array.display(mode: 'int' | 'poly' | 'power' =
'int'
) Generator[None, None, None] Sets the display mode for all arrays from this
FieldArray
subclass.The display mode can be set to either the integer representation, polynomial representation, or power representation. See Element Representation for a further discussion.
This function updates
display_mode
.Warning
For the power representation,
numpy.log()
is computed on each element. So for large fields without lookup tables, displaying arrays in the power representation may take longer than expected.- Parameters¶
- mode: 'int' | 'poly' | 'power' =
'int'
¶ The field element representation.
"int"
: Sets the display mode to the integer representation."poly"
: Sets the display mode to the polynomial representation."power"
: Sets the display mode to the power representation.
- mode: 'int' | 'poly' | 'power' =
- Returns¶
A context manager for use in a
with
statement. If permanently setting the display mode, disregard the return value.
Examples¶
The default display mode is the integer representation.
In [1]: GF = galois.GF(3**2) In [2]: x = GF.elements; x Out[2]: GF([0, 1, 2, 3, 4, 5, 6, 7, 8], order=3^2)
Permanently set the display mode by calling
display()
.In [3]: GF.display("poly"); In [4]: x Out[4]: GF([ 0, 1, 2, α, α + 1, α + 2, 2α, 2α + 1, 2α + 2], order=3^2)
In [5]: GF.display("power"); In [6]: x Out[6]: GF([ 0, 1, α^4, α, α^2, α^7, α^5, α^3, α^6], order=3^2)
Temporarily modify the display mode by using
display()
as a context manager.In [7]: print(x) [0 1 2 3 4 5 6 7 8] In [8]: with GF.display("poly"): ...: print(x) ...: [ 0 1 2 α α + 1 α + 2 2α 2α + 1 2α + 2] # Outside the context manager, the display mode reverts to its previous value In [9]: print(x) [0 1 2 3 4 5 6 7 8]
In [10]: print(x) [0 1 2 3 4 5 6 7 8] In [11]: with GF.display("power"): ....: print(x) ....: [ 0 1 α^4 α α^2 α^7 α^5 α^3 α^6] # Outside the context manager, the display mode reverts to its previous value In [12]: print(x) [0 1 2 3 4 5 6 7 8]