IPython-Notebook
pyhasse.core¶
Objectives¶
The module pyhasse.core is a tool to import data from a CSV file.
It is the basic module for other calcualtions and modules to calculate partial order sets.
After successful importing the data, some basic calculations are performed.
In [1]:
import os
from pyhasse.core.csv_io import CSVReader
In [2]:
TESTFILENAME = '/csvdata/zeta_test.csv'
basepath = os.path.realpath('.')
csv = CSVReader(fn=basepath + TESTFILENAME, ndec=3)
red = csv.calc_reduced_system()
Check if all data are correct imported¶
Objects¶
In [3]:
print(csv.obj)
Attributes¶
In [4]:
print(csv.prop)
All data¶
In [5]:
for row in csv.data:
print(row)
Basic calculations¶
Equivalence classes¶
In [6]:
# prepare dataset
csv.calc_reduced_system()
In [7]:
csv.eqm == [[0, 3, 4], [1], [2], [5], [6]]
eqm_obj = []
eqm_representants = []
for i in range(0, len(csv.eqm)):
eqm_obj.append(0)
eqm_obj[i] = []
for i2 in range(0, len(csv.eqm[i])):
eqm_obj[i].append(csv.obj[csv.eqm[i][i2]])
eqm_representants.append(eqm_obj[i][0])
In [8]:
print(eqm_representants)
K = sum Ni*(Ni-1)
K = 0: There is no nontrivial equivalence class
K > 0: Check the list below to detect the nontirivial equivalence classes
In [9]:
k = -1
for i in eqm_obj:
k += len(i)
print(k, " <-- sum Ni*(Ni-1)")
In [10]:
for row in eqm_obj:
if len(row) > 1:
print(row[0], row[1:])
else:
print(row[0])
In [11]:
from pyhasse.core.order import Order
precision = 4
order = Order(csv.dmred,
csv.redrows,
csv.cols)
zeta = order.calc_relatmatrix(
datamatrix=csv.dmred,
rows=csv.redrows,
cols=csv.cols,
prec=precision)
#covd_act, cov_act = order.calc_cov(zeta, csv.redrows)
#labellength = int(s.get('labelLen', 3))
Zeta-Matrix¶
In [12]:
for row in zeta:
print(row)