IPython-Notebook

Example on how to use pyhasse.acm

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 [10]:
import pathlib
from pyhasse.core.csv_io import CSVReader
In [11]:
TESTFILENAME = '/csvdata/example_r6_k4_fresh.csv'
HERE = pathlib.Path('__file__').parent
csv = CSVReader(fn=str(HERE) + TESTFILENAME, ndec=3)
red = csv.calc_reduced_system()

Check if all data are correct imported

All data

In [12]:
for row in csv.data:
    print(row)
[0.1, 9.3, 0.7, 0.0]
[0.11, 0.7, 0.69, 1.0]
[0.5, 1.2, 2.3, 1.5]
[0.3, 0.0, 1.2, 0.6]
[2.5, 1.6, 2.7, 1.3]
[0.1, 0.3, 0.7, 0.0]

Basic calculations

Antichain

In [13]:
from pyhasse.acm.calc import ACM
acm = ACM(csv.data, csv.rows, csv.cols)

define a user list

In [14]:
user_list = ["a", "b", "d", "e"]
In [15]:
px, pq = acm.generate_setofpairs(csv.objred, user_list)
4
In [16]:
 ac = acm.calc_acm(px, pq)
In [18]:
for row in ac:
    print(row)
[1, 1, 0, 0, 1, 1]
[1, 0, 0, 1, 1, 0]
[1, 0, 0, 1, 1, 0]
[1, 0, 1, 1, 0, 1]
[0, 0, 0, 0, 0, 0]
[0, 0, 0, 0, 0, 0]

usw. usw.....