Skip to content

Commit

Permalink
Merge pull request #1563 from hyanwong/patch-26
Browse files Browse the repository at this point in the history
Add an extra note about np.nan etc
  • Loading branch information
mergify[bot] authored Jul 9, 2021
2 parents 6ed8957 + 6ce2364 commit f582dcc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions python/tskit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,17 @@ def canonical_json(obj):
def is_unknown_time(time):
"""
As the default unknown mutation time (:const:`UNKNOWN_TIME`) is a specific NAN value,
equality always fails. This method compares the bitfield such that unknown times can
be detected. Either single floats can be passed or lists/arrays.
equality always fails (A NAN value is not equal to itself by definition).
This method compares the bitfield such that unknown times can be detected. Either
single floats can be passed or lists/arrays.
Note that NANs are a set of floating-point values. `tskit.UNKNOWN_TIME` is a specific
value in this set. `np.nan` is a differing value, but both are NAN.
See https://en.wikipedia.org/wiki/NaN
This function only returns true for ``tskit.is_unknown_time(tskit.UNKNOWN_TIME)``
and will return false for ``tskit.is_unknown_time(np.nan)`` or any other NAN or
non-NAN value.
:param time: Value or array to check.
:type time: Union[float, array-like]
Expand Down

0 comments on commit f582dcc

Please sign in to comment.