permit NaN in embedding coordinates (#1631)

* permit NaN in embedding coordinates

* lint
This commit is contained in:
Bruce Martin
2020-07-16 11:43:56 -07:00
committed by GitHub
parent 3c6d90a4db
commit 2f700b377f
3 changed files with 15 additions and 8 deletions
+2 -2
View File
@@ -391,13 +391,13 @@ def create_emb(e_name, emb):
def is_valid_embedding(adata, name, arr):
""" return True if this layout data is a valid array for front-end presentation:
* ndarray, with shape (n_obs, >= 2), dtype float/int/uint
* contains only finite values
* follows ScanPy embedding naming conventions
* with all values finite or NaN (no +Inf or -Inf)
"""
is_valid = type(name) == str and name.startswith("X_") and len(name) > 2
is_valid = is_valid and type(arr) == np.ndarray and arr.dtype.kind in "fiu"
is_valid = is_valid and arr.shape[0] == adata.n_obs and arr.shape[1] >= 2
is_valid = is_valid and np.all(np.isfinite(arr))
is_valid = is_valid and not np.any(np.isinf(arr)) and not np.all(np.isnan(arr))
return is_valid