Skip to content

Commit

Permalink
Add an extra note about np.nan etc
Browse files Browse the repository at this point in the history
  • Loading branch information
hyanwong authored and mergify-bot committed Jul 9, 2021
1 parent 6ed8957 commit 6ce2364
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 6ce2364

Please sign in to comment.