Fix float16 support [#2379] (#2483)

* Fix float16 support [#2379]

Convert to float32 on startup unless backed, in which case error. scipy does not support complex slicing from float16 data so this is the easiest fix for now.

* minor msg change
This commit is contained in:
Ben MR
2022-02-10 15:20:47 -08:00
committed by GitHub
parent ceb0cc6f27
commit 8bac98f25c
4 changed files with 32 additions and 1 deletions
+8
View File
@@ -236,6 +236,14 @@ class AnndataAdaptor(DataAdaptor):
warnings.warn(
f"Anndata data matrix is in {self.data.X.dtype} format not float32. " f"Precision may be truncated."
)
if self.data.X.dtype < np.float32:
if self.data.isbacked:
raise DatasetAccessError(f"Data matrix in {self.data.X.dtype} format is not supported in backed mode."
" Please reload without --backed, or convert matrix to float32")
warnings.warn(
f"Anndata data matrix is in unsupported {self.data.X.dtype} format -- will be cast to float32"
)
self.data.X = self.data.X.astype(np.float32)
for ax in Axis:
curr_axis = getattr(self.data, str(ax))
for ann in curr_axis: