johnbachman / py-fcm

Automatically exported from code.google.com/p/py-fcm
0 stars 1 forks source link

trying to access 'SPILL' in fcm results in crash #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1: import fcm
2: f1 = fcm.loadFCS('../../hg/fcm/sample_data/3FITC_4PE_004.fcs')
3: f1['SPILL']

What is the expected output? What do you see instead?

In [3]: f1['SPILL']
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (5, 0))

--------------------------------------------------------------------------
-
ValueError                                Traceback (most recent call last)

/Users/cliburn/hg/fcm/<ipython console> in <module>()

/Users/cliburn/MyPython/fcm/core/fcmdata.pyc in __getitem__(self, item)
     69 
     70         if type(item) == type(''):
---> 71             return self.get_channel_by_name(item)
     72         elif type(item) == tuple:
     73             if type(item[0]) == type(''):

/Users/cliburn/MyPython/fcm/core/fcmdata.pyc in get_channel_by_name(self, 
channels)
     58         """Return the data associated with specific channel names"""
     59 
---> 60         return self.tree.view()[:, self.name_to_index(channels)]
     61 
     62     def get_markers(self):

/Users/cliburn/MyPython/fcm/core/fcmdata.pyc in name_to_index(self, channels)
     52         if type(channels) == type(''):
     53             channels = [channels]
---> 54         to_return = [ self.channels.index(i) for i in channels]
     55         return to_return
     56 

ValueError: list.index(x): x not in list

Please use labels and text to provide additional information.

Original issue reported on code.google.com by cliburn....@gmail.com on 16 Aug 2009 at 9:45

GoogleCodeExporter commented 9 years ago
first, 'spill' isn't a channel, it's a part of the annotation, so it should be
referenced as f1.notes['spill'].  but it's still a bug, as it should raise a
meaningful exception and not bail like it does.  Would adding either a class 
method
or attribute of spill be useful? it so I'll add it.

Original comment by Jacob.Frelinger@gmail.com on 16 Aug 2009 at 10:30

GoogleCodeExporter commented 9 years ago
I think we can just get it to fail nicely by catching the exception or setting 
a default for the return to be None - 
for example, make Annotation use defaultdict rather than dict or use 
notes.get('spill',None) instead of 
notes.get['spill']

Original comment by cliburn....@gmail.com on 16 Aug 2009 at 10:34

GoogleCodeExporter commented 9 years ago
I've added a get spill function that's just a convince for notes.text['spill'], 
or
failing that, None.  Also added code to raise a ValueError exception when you 
pass in
a bad channel (same as numpy does).

Original comment by Jacob.Frelinger@gmail.com on 17 Aug 2009 at 2:22

GoogleCodeExporter commented 9 years ago

Original comment by Jacob.Frelinger@gmail.com on 17 Aug 2009 at 2:23

GoogleCodeExporter commented 9 years ago

Original comment by Jacob.Frelinger@gmail.com on 30 Jun 2011 at 3:03