Welcome to our community.
In order to ignore the
inf values, you can just check whether the value you are checking is
inf or not.
In this link you will find an example on how to achieve that:
Please let us know in case you need further assistance.