When trying to convert a nan to an int you will get a warning:
RuntimeWarning: invalid value encountered in cast
As explained in MIT-LCP/wfdb-python#481 this is expected and has been circumvented in the latest WFDB code. This update isn't in the current release of WFDB though (v4.1.2). Therefore, I'm adding an issue here so it is clear that this is expected and isn't a problem.