multiscale / muscle3

The third major version of the MUltiScale Coupling Library and Environment
Apache License 2.0
25 stars 13 forks source link

Ensure correct timestamp type in Message #119

Closed maarten-ic closed 2 years ago

maarten-ic commented 2 years ago

Fixes #118

When an incorrect type is provided by the user for Message.timestamp or Message.next_timestamp, MsgPack will serialize an invalid MMPMessage on the wire. This leads to errors in statically typed peer actors.

Issue is fixed by explicitly converting to float in Message.init and checking again in MMPMessage.init (as the user may have assigned another value between creation of the Message and Instance.send).

LourensVeen commented 2 years ago

Looks good. Ideally people would use mypy or an IDE that does so for them, but if they don't and pass something that cleanly converts to a float, why not?