1# Script to test the subsections of: 2# "Accessing SciDAVis's functions from Python" 3# available at: https://highperformancecoder.github.io/scidavis-handbook/sec-python.html 4# Basically a Ctrl+C -> Ctrl+V most of times 5 6## Working with Tables 7 8# 1st, create some empty tables - use defaults 9t1=newTable() 10t2=newTable() 11t1.confirmClose(False) 12t2.confirmClose(False) 13 14assert t1.cell(1,1) == 0.0 15t1.setCell(1,1,pi) 16assert t1.cell(1,1) == pi 17 18assert t2.text(1,1) == "" 19# need to set the desired column as text first 20c1t2=t2.column("1") 21c1t2.setColumnMode("Text") 22t2.setText(1,1,"pi") 23assert t2.text(1,1) == "pi" 24 25assert t2.colName(2) == "2" 26t2.setColName(2,"two") 27assert t2.colName(2) == "two" 28 29assert t1.numRows() == 30 30assert t1.numCols() == 2 31t1.setNumRows(10) 32t1.setNumCols(5) 33assert t1.numRows() == 10 34assert t1.numCols() == 5 35 36# fill columns with x^2, x = row number, to perform the normalization test 37for i in range(1,t1.numRows()+1): 38 t1.setCell(1,i,i**2) 39 t1.setCell(2,i,i**2) 40 41t1.normalize(1) #normalize only column 1 42assert t1.cell(1,t1.numRows()) == 1.0 # verify only column 1 43t1.normalize() #normalize all columns 44assert t1.cell(2,t1.numRows()) == 1.0 # verify only column 2 45 46# t.importASCII will not be included in this test file - add it to TODO list 47# t.notifyChanges() will not be included because I guess it is deprecated - add it to a TOCHECK list 48app.exit() 49