plumial.core.P._P.encode
- _P.encode(basis=None, g=None, h=None)[source]
Create a new P object encoded in a different basis.
This method enables the transitive encoding property where P objects can be transformed between different coordinate systems while preserving the underlying p-value identity.
- Parameters:
basis (
Optional[Basis]) – Target basis for encodingg (
Union[int,float,None]) – g parameter for custom basis (alternative to basis parameter)h (
Union[int,float,None]) – h parameter for custom basis (alternative to basis parameter)
- Return type:
- Returns:
New P object with same p-value but different basis
Examples
>>> p = P(281) # Symbolic basis >>> collatz_p = p.encode(B.Collatz) # Collatz basis >>> custom_p = p.encode(g=5, h=2) # Custom basis >>> back_p = collatz_p.encode() # Back to symbolic basis >>> assert back_p == p # Round-trip equality