ratal / mdfreader

Read Measurement Data Format (MDF) versions 3.x and 4.x file formats in python
Other
169 stars 74 forks source link

AttributeError: 'builtin_function_or_method' object has no attribute 'dtype' #62

Closed ginseil closed 7 years ago

ginseil commented 7 years ago

Hi ratal,

I am no longer able to laod a mdf 4 file, which worked with pervious versions. The current version always terminates with the following AttributeError:

[...] File "C:/Users/stoev/PycharmProjects/Measured_Data_Conditioning\format\mdf\converter.py", line 149, in _load_mdf_data mdf = mdfreader.mdf(self.source, convertAfterRead=False) File "C:\Users\stoev\AppData\Local\Continuum\Anaconda3\lib\site-packages\mdfreader\mdf.py", line 114, in init self.read(fileName, channelList=channelList, convertAfterRead=convertAfterRead, filterChannelNames=filterChannelNames) File "C:\Users\stoev\AppData\Local\Continuum\Anaconda3\lib\site-packages\mdfreader\mdfreader.py", line 362, in read self.read4(self.fileName, info, multiProc, channelList, convertAfterRead, filterChannelNames=False) File "C:\Users\stoev\AppData\Local\Continuum\Anaconda3\lib\site-packages\mdfreader\mdf4reader.py", line 1426, in read4 if temp.dtype.kind != 'U': AttributeError: 'builtin_function_or_method' object has no attribute 'dtype'

temp seems to be: <built-in method put of recarray object at 0x000000000E749BA8>

ratal commented 7 years ago

What version of mdfreader are you using ? Looking at the code, temp can only be None, arange or inherited from buf[recordID]['data'] (line 1404) --> it comes from another class/method. Probably readBitarray or DATABlock with unsorted reading. I miss information to undesrtand what goes wrong. There has been lately regressions channel names handling that slipped out my tests, can you try again with latest commit ?

ginseil commented 7 years ago

Hi ratal,

I made some tests and found the oldest commit which produced the error described above for the first time, please see the attached file: mdfreader.txt

However the latest working commit is from 10. may: 384aad995c84b22c32487978da399c57fe3e10ba. I also tried your latest changes and the result is still the same.

ratal commented 7 years ago

Hi Ginseil, Thanks for trying but I could not track back the change that could trigger this issue. I recently had to use limited naming of recarrays channels (_convertName) because it is limited to python identifiers characters. Big change that caused several regressions that were not identified by my tests. I guess your issue is one of those regressions. Could you try with a print(temp) just before the error line to understand what is temp ? Maybe also a print(type(temp)). Also some print() in readBitarray or in DATABlock for unsorted reading to confirm what is reading path ?

ginseil commented 7 years ago

Hi ratal,

I think the problem is the name of one channel ('put' in my case) rather than reading its data. Furthermore content of temp at the time this error occured states that: temp is a built-in method 'put' of recarray object. It seems to be a general issue with channel names exactly matching the method names of recarray?!

However here are the results of the added prints right before the error occurs: temp: <built-in method put of recarray object at 0x000000000DE6E5F8> type: <class 'builtin_function_or_method'>

I also added prints to readBitarray, but this method has not been entered. I also took a look into DATABlock but have no idea where to add some usefull prints?!

ratal commented 7 years ago

Clearly, having 'put' as channel name is the reason of your issue. I will try to make something clean but I think you could try to implement a small cleaning condition in mdf.py, convertName function, something like this: if name in ['put','sum'] name+=name+'' It is a bit sad that recarray does not check the record name are not conflicting with its attributes.

ginseil commented 7 years ago

Hi ratal,

your suggested cleaning condition works like a charm. Tanks! Would you close this ticket once this bugs is fixed?

ratal commented 7 years ago

I implemented generic name cleaning in mdf.py and removed also getattribute method call in last commit, this issue should not happen anymore.