IPython-Notebook
Demo of pyhasse.lpom¶
Aim of the programm
LPOM stands for Local Partial Order Model.
LPOM0 and LPOMext are approximations to calculate the average height, hav, of partially ordered sets (posets).
If not allredy done¶
Comment out or delete the following line if the module is installed.
In [24]:
#!pip install pyhasse.lpom
import all nessesary libraries¶
In [25]:
import pathlib
from pyhasse.core.csv_io import CSVReader
from pyhasse.core.order import Order
from pyhasse.lpom.calc import LPOM
import json
import random
from IPython.core.display import display, HTML
import pandas as pd
from string import Template
In [26]:
TESTFILENAME = '/csvdata/a-equiv.txt'
prefs={
'start': 0,
'stop': 3,
'user_list' : [],
'labelLen': 3,
'actwidth': 550,
'actheight': 200
}
HERE = pathlib.Path('__file__').parent
csv = CSVReader(fn=str(HERE) + TESTFILENAME, ndec=3)
red = csv.calc_reduced_system()
order = Order(csv.dmred,
csv.redrows,
csv.cols)
zeta = order.calc_relatmatrix(csv.dmred,
csv.redrows,
csv.cols)
redrows = csv.redrows
down = order.calc_downset(zeta, redrows)
up = order.calc_upset(zeta, redrows)
Some basic data¶
In [27]:
print(csv.rows)
print(csv.cols)
print(csv.prop)
print(csv.obj)
print(csv.objred)
print(csv.data)
In [28]:
incomp = order.calc_incompset(zeta, redrows)
order.calc_incomp(zeta, redrows)
down = order.calc_downset(zeta, redrows)
up = order.calc_upset(zeta, redrows)
print(up)
print(down)
In [29]:
lpom2 = LPOM()
In [30]:
hav0 = lpom2.calc_hav(down, incomp, redrows)
In [31]:
hav1 = lpom2.calc_hav_ext(down, up, incomp, redrows)
print(hav1)
Outpup "Averaged height" as table¶
In [32]:
from IPython.display import HTML, display
from pyhasse.core.tables import HTMLTable
data = []
for idx, item in enumerate(csv.objred):
data.append([item, hav1[idx]])
tab = HTMLTable(data)
display(HTML(tab.table2html()))
Objects averaged height0¶
In [33]:
eqact = csv.eqm
fext0 = csv.weak(csv.obj, csv.objred, eqact, hav1)
data = []
for idx, item in enumerate(csv.obj):
data.append([item, fext0[idx]])
tab = HTMLTable(data)
display(HTML(tab.table2html()))
Output as graph¶
Comming soon....