Python module for the normalization of ternary generalized
pseudostandard words. Examples can be found in the Jupyter notebook
Examples.ipynb
Bases: object
Object for normalizing a ternary directive bi-sequences using the new normalization algorithm.
normalize(delta, theta)
Ternary normalization algorithm.
Normalization function that returns the normalized directive bi-sequence giving the same generalized pseudostandard word as (delta, theta).
Parameters: |
|
Returns: | Returns the tuple (new_delta, new_theta, notchanged) where (new_delta, new_theta) is the normalized bi-sequence of (delta, theta). The boolean notchanged is True if the bi-sequence (delta, theta) was already normalized, otherwise it is False. |
Examples
>>> n = Normalizer012()
>>> n.normalize("0011", "00RR")
('0011', '00RR', True)
>>> n.normalize("0102110", "02R0121")
print_all_factor_rules()
Prints in a readable form all the factor normalization rules
Bases: object
Object for normalizing ternary directive bi-sequences using a naive algorithm.
normalize(delta, theta)
Ternary naive normalization algorithm.
Naive normalization function that returns the normalized directive bi-sequence giving the same generalized pseudostandard word as (delta, theta). It creates the prefixes w_i by generalized pseudopalindromic closures a then checks if those are the only pseudopalindromic prefixes in the word created by the directive bi-sequence.
Parameters: |
|
Returns: | Returns the tuple (new_delta, new_theta, notchanged) where (new_delta, new_theta) is the normalized bi-sequence of (delta, theta). The boolean notchanged is True if the bi-sequence (delta, theta) was already normalized, otherwise it is False. |
Examples
>>> nn = NaiveNormalizer012()
>>> nn.normalize("0011", "00RR")
('0011', '00RR', True)
>>> nn.normalize("0102110", "02R0121")
('01021102', '02R01201', False)
tgpc.Ei(i)
The involutory antimorphism Ei.
Parameters: | i – Either 0, 1, 2 or “0”, “1”, “2” |
Returns: | A tuple corresponding to the involutory antimorphism Ei. |
Examples
>>> Ei(0)
('0', '2', '1')
>>> Ei(1)
('2', '1', '0')
>>> Ei(2)
('1', '0', '2')
tgpc.is_eipal(seq, i)
Checks if a word is an Ei-palindrome.
Parameters: |
|
Returns: | True if the word is an Ei-palindrome, otherwise False. |
Examples
>>> is_eipal("012", 1)
True
>>> is_eipal("002", 1)
False
tgpc.is_pal(seq)
Checks if a word is an R-palindrome.
Parameters: | seq (string) – The word checked. |
Returns: | True if the word is an Ei-palindrome, otherwise False. |
Examples
>>> is_pal("012")
False
>>> is_pal("010")
True
tgpc.make_eipal_closure(seq, i)
Makes an Ei-palindromic closure of a string.
Parameters: |
|
Returns: | The palindromic closure of the word. |
Examples
>>> make_eipal_closure("102", 0)
'102'
>>> make_eipal_closure("101", 1)
'10121'
tgpc.make_pal_closure(seq)
Makes a palindromic closure of a string.
Parameters: | seq (string) – A word. |
Returns: | The palindromic closure of the word. |
Examples
>>> make_pal_closure("101")
'101'
>>> make_pal_closure("102")
'10201'
tgpc.make_word012(delta, theta,*seed='')
Makes a ternary GPS word from (delta, theta).
Parameters: |
|
Returns: | A string made by pseudopalindromic closure from (delta, theta). |
Examples
>>> make_word012("0011", "012R")
'00221112200'
tgpc.set_logging(logging level='ERROR')
Sets the logging level of the module.
If the level is set to “ERROR”, the functions log only errors. If it is set to “INFO” or “DEBUG”, the fuction prints more information about how ternary words are being processed.
Parameters: | level (str) – “ERROR” (default), “INFO” or “DEBUG” |