Printing a Table of Process Properties¶
It is now simple to print a nice looking table of process properties in CMPy:
In [1]: from cmpy.util import process_table
In [2]: from cmpy.machines import library
In [3]: process_table(library(0,2))
╔════════════════════╤═══╤═══╤══════════╤══════════╤══════════╗
║ │ R │ k │ Cμ │ E │ hμ ║
╟────────────────────┼───┼───┼──────────┼──────────┼──────────╢
║ 2-State Machine #0 │ 1 │ 0 │ 1.00000 │ 1.00000 │ 0.00000 ║
║ 2-State Machine #1 │ ∞ │ 0 │ 1.00000 │ 1.00000 │ 0.50000 ║
║ 2-State Machine #2 │ ∞ │ 0 │ 1.00000 │ 1.00000 │ 0.50000 ║
║ 2-State Machine #3 │ ∞ │ 0 │ 0.91830 │ 0.91830 │ 0.66667 ║
║ 2-State Machine #4 │ 1 │ 1 │ 0.91830 │ 0.25163 │ 0.66667 ║
║ 2-State Machine #5 │ 1 │ 1 │ 0.91830 │ 0.25163 │ 0.66667 ║
║ 2-State Machine #6 │ ∞ │ 0 │ 0.91830 │ 0.91830 │ 0.66667 ║
╚════════════════════╧═══╧═══╧══════════╧══════════╧══════════╝
you can add custom columns, and control which columns are shown also:
In [4]: from cmpy.machines import build_eM
In [5]: from cmpy.util.process_table import bool_normalizer
In [6]: def is_causally_reversible(m):
....: C1 = m.statistical_complexity()
....: C2 = build_eM(m.reverse(), transients=False).statistical_complexity()
....: return C1 == C2
In [7]: custom = {'CR': (is_causally_reversible, bool_normalizer, 'CR')}
In [8]: process_table(library(0,2), ['R', 'bmu', 'CR'], custom)
╔════════════════════╤═══╤══════════╤════╗
║ │ R │ bμ │ CR ║
╟────────────────────┼───┼──────────┼────╢
║ 2-State Machine #0 │ 1 │ 0.00000 │ T ║
║ 2-State Machine #1 │ ∞ │ 0.00000 │ T ║
║ 2-State Machine #2 │ ∞ │ 0.00000 │ T ║
║ 2-State Machine #3 │ ∞ │ 0.66667 │ T ║
║ 2-State Machine #4 │ 1 │ 0.20752 │ T ║
║ 2-State Machine #5 │ 1 │ 0.20752 │ T ║
║ 2-State Machine #6 │ ∞ │ 0.66667 │ T ║
╚════════════════════╧═══╧══════════╧════╝