danielhrisca / asammdf

Fast Python reader and editor for ASAM MDF / MF4 (Measurement Data Format) files
GNU Lesser General Public License v3.0
612 stars 216 forks source link

Possible to append object type signal? #979

Open morbult opened 5 months ago

morbult commented 5 months ago

Python version

('python=3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:26:23) ' '[MSC v.1916 64 bit (AMD64)]') 'os=Windows-10-10.0.19041-SP0' 'numpy=1.25.2' 'asammdf=7.4.1'

Code

MDF version

4.10

Code snippet

import numpy as np
from asammdf import Signal, MDF

n = 3
t = np.arange(n)
mdf = MDF()
sig = Signal(np.array([b''] * n, dtype=object), t, name='b')
mdf.append(sig)

Traceback

asammdf - ERROR - Unknown type: dtype=object, shape=(3,)
NoneType: None
Traceback (most recent call last):

  Cell In[22], line 8
    mdf.append(sig)

  File ~\AppData\Local\anaconda3\Lib\site-packages\asammdf\blocks\mdf_v4.py:2767 in append
    s_type, s_size = fmt_to_datatype_v4(sig_dtype, sig_shape)

  File ~\AppData\Local\anaconda3\Lib\site-packages\asammdf\blocks\utils.py:788 in fmt_to_datatype_v4
    raise MdfException(message)

MdfException: Unknown type: dtype=object, shape=(3,)

Description

Hi Daniel,

I have some 4.10 files where some channels are strings of type dtype('S256'). After mdf.to_dataframe they are converted to type object. I then process the data and create a new mdf object to be saved. It fails at mdf.append due to the object type signals.

Should it be possible to append a signal of type object? Or do I need to discard or convert those signals to strings?

danielhrisca commented 5 months ago

@morbult please try the development branch code

morbult commented 5 months ago

Still the same error trace as above for me. Both from the snippet above and my actual use case.