Ticket #4900 (closed: fixed)
New features to TableWorkspace in python
Reported by: | Peter Peterson | Owned by: | Peter Peterson |
---|---|---|---|
Priority: | major | Milestone: | Release 2.1 |
Component: | Mantid | Keywords: | |
Cc: | martyn.gigg@…, vel@… | Blocked By: | |
Blocking: | Tester: | Wenduo Zhou |
Description (last modified by Peter Peterson) (diff)
As we are starting to use TableWorkspace for more things in python some additional properties/methods would make it easier to use. The additional methods are:
- keys - the name of all of the columns like a dictionary
- column - get a list of the values of a column based on the column heading like a dictionary works.
- row - get a specific row as a dict with the column names as the keys and the cell values as the values.
- __len__ - the number of rows
- __iter__ - iterate through the rows giving results similar to the row method. This will help the canonical usage of "for row in table:"
Change History
comment:2 Changed 9 years ago by Peter Peterson
Refs #4900. Added code for getting rows.
The next round of changes is to get rid of the copy and pasted code.
Changeset: 6a4924c768a70a2b394c134ba1008217fa85a72f
comment:5 Changed 9 years ago by Peter Peterson
- Status changed from accepted to verify
- Resolution set to fixed
comment:6 Changed 9 years ago by Peter Peterson
This can be tested by seeing that the following script works (needs the raw data file of course)
from MantidFramework import mtd mtd.initialize() from mantid.simpleapi import * # Perform some algorithms LoadEventNexus(filename="/SNS/VULCAN/IPTS-2916/0/12458/NeXus/VULCAN_12458_event.nxs", OutputWorkspace="VULCAN_12458", FilterByTimeStop=90) ConvertUnits(InputWorkspace="VULCAN_12458", OutputWorkspace="VULCAN_12458", target="dSpacing") CreateGroupingWorkspace(InputWorkspace="VULCAN_12458", GroupDetectorsBy="All", OutputWorkspace="VULCAN_group") DiffractionFocussing(InputWorkspace="VULCAN_12458", OutputWorkspace="VULCAN_12458", GroupingWorkspace="VULCAN_group") Rebin(InputWorkspace="VULCAN_12458", OutputWorkspace="VULCAN_12458", Params=[-.0004]) peaks = FindPeaks(InputWorkspace="VULCAN_12458") print peaks print "******************************" print dir(peaks) print "******************************" print "Number of Columns: " + str(peaks.columnCount()) + " , Number of rows: "+ str(peaks.rowCount()) print "******************************" colNames = peaks.getColumnNames() print colNames print "******************************" for i in range(4): print "Spectrum %d has peak at pos %f" % (peaks.cell("spectrum",i), peaks.cell("centre",i)) print "******************************" print peaks.column("centre") print "******************************" print peaks.row(0) print "******************************" for row in peaks: print row
comment:7 Changed 9 years ago by Vickie Lynch
Refs #4900 last row was missing
Changeset: 05ea1454fdeca4a84f1803d7275010adab9b586f
comment:8 Changed 9 years ago by Peter Peterson
Refs #4900. Adding first round of ITableWorkspace methods for python.
This round is keys, column, and length.
Changeset: fe46dda8bd0d676c353bc0963a27de4b7a486246
comment:9 Changed 9 years ago by Peter Peterson
Refs #4900. Added code for getting rows.
The next round of changes is to get rid of the copy and pasted code.
Changeset: 6a4924c768a70a2b394c134ba1008217fa85a72f
comment:10 Changed 9 years ago by Peter Peterson
Refs #4900. Added the ITableWorkspace iterator code for python.
This was tons easier in python.
Changeset: 810a82392d4b1ff7beb744415baf1a68709a9f01
comment:11 Changed 9 years ago by Peter Peterson
Refs #4900. Cleaned up ITableWorkspace.
There was a large amount of copy and pasted code that has been factored out.
Changeset: 43e0691987fd5cf47e2cdbaa088606bf14794b75
comment:12 Changed 9 years ago by Vickie Lynch
Refs #4900 last row was missing
Changeset: 05ea1454fdeca4a84f1803d7275010adab9b586f
comment:13 Changed 9 years ago by Peter Peterson
Refs #4900. Adding more documentation to python ITableWorkspace.
Changeset: 0cdad8c26ae4a08f04f8ab40ad39a17c28b8b43a
comment:14 Changed 9 years ago by Martyn Gigg
Backported table workspace ops to old Python API. Refs #4900.
Required for a Python algorithm at the moment and this is the simplest option.
Changeset: 00b57d92128bd349739559ec1fd94b921ef70a6c
comment:15 Changed 9 years ago by Martyn Gigg
Backported table workspace ops to old Python API. Refs #4900.
Required for a Python algorithm at the moment and this is the simplest option.
Changeset: 00b57d92128bd349739559ec1fd94b921ef70a6c
comment:16 Changed 8 years ago by Wenduo Zhou
- Status changed from verify to verifying
- Tester set to Wenduo Zhou
comment:18 Changed 5 years ago by Stuart Campbell
This ticket has been transferred to github issue 5746
Refs #4900. Adding first round of ITableWorkspace methods for python.
This round is keys, column, and length.