Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Casting the frame id from scientific number format fails #778

Closed
djdesant opened this issue Mar 21, 2024 · 6 comments
Closed

Casting the frame id from scientific number format fails #778

djdesant opened this issue Mar 21, 2024 · 6 comments
Assignees

Comments

@djdesant
Copy link

djdesant commented Mar 21, 2024

db.enum_attribs_to_values()
File "C:\…\MdfMetaData.venv\Lib\site-packages\canmatrix\canmatrix.py", line 2317, in e
num_attribs_to_values
frame.attributes[define] = self.frame_defines[define].values[int(frame.attributes[define])]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '8.52715012702708E-317'

Please consider the casting to float before int. Example:
frame.attributes[define] = self.frame_defines[define].values[int(float(frame.attributes[define]))]

@ebroecker ebroecker self-assigned this Mar 22, 2024
@pempem98
Copy link
Contributor

pempem98 commented Mar 23, 2024

I guest this is the precision issue of the library decimal
I used to get this issue before when I tried to read string '1' and convert it into decimal.Decimal type.
The result comes as decimal.Decimal('1.00000000000000000000003216...')

@djdesant
Copy link
Author

djdesant commented Apr 10, 2024

I guest this is the precision issue of the library decimal I used to get this issue before when I tried to read string '1' and convert it into decimal.Decimal type. The result comes as decimal.Decimal('1.00000000000000000000003216...')

Are there more possible workarounds ?
@pempem98 Could you please describe your alternative proposal for solving this problem ?

@ebroecker
Copy link
Owner

I don't know a better workaround.
Also - I was not able to reproduce the error.

pip install git+https://github.com/ebroecker/canmatrix.git@issue_778

@djdesant
Copy link
Author

I don't know a better workaround. Also - I was not able to reproduce the error.

pip install git+https://github.com/ebroecker/canmatrix.git@issue_778

Thanks for fixing.

Probably you have a clean database example without scientific numbers. I'll give you short exctract from the dbc in my case:

BA_ "GenMsgCycleTime" BO_ 2360127010 100;
BA_ "GenMsgSendType" BO_ 2360127010 8.48332452797837E-317;
BA_ "VFrameFormat" BO_ 2360127010 3;
BA_ "VFrameFormat" BO_ 2566875426 3;
BA_ "GenMsgCycleTime" BO_ 2360156846 100;
BA_ "GenMsgSendType" BO_ 2360156846 8.48390950170305E-317;
BA_ "VFrameFormat" BO_ 2360156846 3;

As you can see the attribute "GenMsgSendType" is marginally small number and could surely be replaced by zero, but this would require manual post-editing in an ASCII text editor after each change of the database in Vector DB Editor.

@djdesant
Copy link
Author

djdesant commented Apr 21, 2024

@ebroecker, when are you planning to merge the current branch into master ?

ebroecker added a commit that referenced this issue May 2, 2024
@ebroecker
Copy link
Owner

should be merged, if not please blame me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants