I have created a table containing header rows, header columns, column ids and row ids (the above picture is a very simple example of the table structure), and have used some methods of a specific class to convert the table to weighted flat cross-tab and pivot cross tab, etc. Now what I'm looking for is to test if the values in the table are float , so I've developed a unittest test suite. I have used Table.values(), or Table.iteritems(), but these two methods iterate over all the Table including the headers and ids which are all strings , therefor the test is failed. Does anyone have a better solution to iterate only the values of the table regardless of the labels in the table?
row_ids=['g','p']
col_ids=['r','c']
values = { ('g','r'): 0.75, ('g','c'): 0.25, ('p','r'): 0.5, ('p','c'): 0.5, }
header_row = { 'id':'forme', 'type':'string' }
header_col = { 'id':'taille', 'type': 'string', }
What I'm looking for is to only read the values in the values dictionary, but with values() and items() the output is a tuple of key and value. That's why the test is failed.
I think you mean you want to do this:
for k, v in values.iteritems():
if k: # if k has a value indicating this is a header:
continue # skip it
if not isinstance(v, float):
print 'bad value: ', k, v
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments