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
BIN
View File
Binary file not shown.
@@ -1,5 +1,4 @@
import json
import sys
import time
import unittest
@@ -37,6 +36,7 @@ Test the anndata adaptor using the pbmc3k data set.
(f"{FIXTURES_ROOT}/pbmc3k-CSC-gz.h5ad", True, "normal"),
(f"{FIXTURES_ROOT}/pbmc3k-CSR-gz.h5ad", True, "normal"),
(f"{FIXTURES_ROOT}/pbmc3k_64.h5ad", False, "auto"), # 64 bit conversion tests
(f"{FIXTURES_ROOT}/pbmc3k_16.h5ad", False, "auto"), # 16 bit conversion tests
],
)
class AdaptorTest(unittest.TestCase):
@@ -0,0 +1,23 @@
import unittest
from parameterized import parameterized_class
from server.common.errors import DatasetAccessError
from test import FIXTURES_ROOT
from test.unit import app_config
@parameterized_class(
("data_locator", "backed", "X_approximate_distribution"),
[
(f"{FIXTURES_ROOT}/pbmc3k_16.h5ad", True, "auto"), # 16 bit conversion tests
],
)
class AdaptorLoadErrorTest(unittest.TestCase):
def test_float16_backed_raises_err(self):
with self.assertRaises(DatasetAccessError):
config = app_config(
self.data_locator,
backed=self.backed,
extra_dataset_config=dict(X_approximate_distribution=self.X_approximate_distribution),
)