Bug 157472 - KstScript can not load matrices from Data Sources
Summary: KstScript can not load matrices from Data Sources
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: documentation (show other bugs)
Version: 1.x
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Yiwen Mao
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-09 02:41 UTC by Yiwen Mao
Modified: 2008-04-14 23:12 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
This is the source file for loading matrix in the problem desciption above. (29.86 KB, text/plain)
2008-02-09 02:42 UTC, Yiwen Mao
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yiwen Mao 2008-02-09 02:41:13 UTC
Version:           1.6.0 (using KDE 3.5.3)
Installed from:    Compiled From Sources
OS:                Linux

I try to load a matrix form a source file through KstScript, but Kst fails to load the matrix properly. Data Manager shows that the matrix I just loaded only has 1 sample and ranges from 0 to 0, which is certainly not the case.

Here are the command lines:
kst> source = new DataSource("/home/vyiwen/datafiles/asciimatrix.txt");
DataSource
kst> mx = new Matrix(source, "3");
Matrix
Comment 1 Yiwen Mao 2008-02-09 02:42:22 UTC
Created attachment 23487 [details]
This is the source file for loading matrix in the problem desciption above.
Comment 2 Andrew Walker 2008-02-13 22:32:45 UTC
This is because javaScript does not provide functionality for the configuration settings of a datasource.
Comment 3 Andrew Walker 2008-02-13 22:36:12 UTC
This functionality could be added for each datasource - but for every datasource providing a custom configuration dialog the corresponding functionality would need to be added to javaScript. A better, though initially more complex, scheme would be to provide a mechanism whereby javaScript can discover the configurable settings of a datasource.
Comment 4 Andrew Walker 2008-02-14 22:04:43 UTC
SVN commit 775083 by arwalker:

CCBUG:157472 start to add custom configuration for a datasource

 M  +18 -3     kstdatasource.cpp  
 M  +7 -0      kstdatasource.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=775083
Comment 5 Andrew Walker 2008-02-14 22:09:09 UTC
SVN commit 775086 by arwalker:

CCBUG:157472 continue to add custom configuration for a datasource

 M  +125 -32   ascii.cpp  
 M  +2 -0      ascii.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=775086
Comment 6 Andrew Walker 2008-02-14 22:12:32 UTC
SVN commit 775089 by arwalker:

CCBUG:157472 continue to add custom configuration for a datasource

 M  +104 -2    bind_datasource.cpp  
 M  +26 -0     bind_datasource.h  
 M  +6 -1      bind_matrix.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=775089
Comment 7 Andrew Walker 2008-02-14 22:17:53 UTC
javaScript now has sufficient functionality to read matrices from an ascii data source. The script would look something like:

ds=new DataSource("\root\asciimatrix.txt")
ds.setConfiguration("dataStartLine","1")
ds.setConfiguration("readFieldNames","true")
ds.setConfiguration("readFieldNamesLine","0")
ds.reset()
m=new DataMatrix(ds, "[Matrix,50,0,0,0.5,0.5]")

NOTES:

You must use a DataMatrix, as a Matrix is simply a static matrix that is not connected to a data source.

The call to reset() is essential as it tells the data source to reparse the data file after the configuration settings have been changed.

The text identifying the matrix "[Matrix,50,0,0,0.5,0.5]" must match exactly with the text in the data file.
Comment 8 Andrew Walker 2008-02-14 22:20:03 UTC
Need to update documentation
Comment 9 Andrew Walker 2008-02-14 22:33:48 UTC
Loading can be made slightly easier using (for example):

m=new DataMatrix(ds, ds.matrixList()[0])

or even simpler:

m=new DataMatrix(ds, 0)
Comment 10 Andrew Walker 2008-04-14 23:12:36 UTC
fixed in 1.6.0 documentation