On 21 November 2015 at 15:08,  <tlin...@nmr-relax.com> wrote:
> Author: tlinnet
> Date: Sat Nov 21 15:08:17 2015
> New Revision: 28076
>
> URL: http://svn.gna.org/viewcvs/relax?rev=28076&view=rev
> Log:
> Made additional check in sequence reading, that "nan" values are skipped.
>
> Modified:
>     trunk/lib/sequence.py
>
> Modified: trunk/lib/sequence.py
> URL: 
> http://svn.gna.org/viewcvs/relax/trunk/lib/sequence.py?rev=28076&r1=28075&r2=28076&view=diff
> ==============================================================================
> --- trunk/lib/sequence.py       (original)
> +++ trunk/lib/sequence.py       Sat Nov 21 15:08:17 2015
> @@ -24,6 +24,7 @@
>  """Module for handling the molecule, residue, and spin sequence data."""
>
>  # Python module imports.
> +from math import isnan
>  from warnings import warn
>
>  # relax module imports.
> @@ -310,6 +311,11 @@
>                  else:
>                      value = float(line[data_col-1])
>
> +                    # If it a float, test if is nan.
> +                    if isnan(value):
> +                        warn(RelaxWarning("The value is 'nan', skipping the 
> line %s" % line))
> +                        continue
> +
>              # Bad data.
>              except ValueError:
>                  warn(RelaxWarning("Invalid data, skipping the line %s" % 
> line))
> @@ -326,6 +332,11 @@
>                  # A float.
>                  else:
>                      error = float(line[error_col-1])
> +
> +                    # If it a float, test if is nan.
> +                    if isnan(error):
> +                        warn(RelaxWarning("The error is 'nan', skipping the 
> line %s" % line))
> +                        continue
>
>              # Bad data.
>              except ValueError:

Hi Troels,

For these changes, I would recommend using Gary's lib.float.isNaN()
function.  The math.isnan() function is relatively recent and it
breaks our Python 2.5 compatibility.  I believe that Gary's lib.float
code is also more advanced.  For example even better would be to use
the isFinite() function, as that will simultaneously check for NaN and
+/- Inf.  Or you could isNaN() followed by isInf() if you'd like
different warning messages for each number type.

Cheers,

Edward

_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-devel mailing list
relax-devel@gna.org

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-devel

Reply via email to