mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-09-30 03:18:11 +08:00
X float16 support (#2406)
* float16 support * fix type checks * PR review comments * add tests for custom json encoder; rename and comment for posterity * lint * typos
This commit is contained in:
committed by
Colin Megill
parent
eaae6df5e3
commit
154d099fef
@@ -17,7 +17,7 @@ from flask_restful import Api, Resource
|
||||
import backend.server.common.rest as common_rest
|
||||
from backend.common.errors import DatasetAccessError, RequestException
|
||||
from backend.server.common.health import health_check
|
||||
from backend.common.utils.utils import Float32JSONEncoder
|
||||
from backend.common.utils.utils import StrictJSONEncoder
|
||||
|
||||
webbp = Blueprint("webapp", "backend.server.common.web", template_folder="templates")
|
||||
|
||||
@@ -257,7 +257,7 @@ class Server:
|
||||
def __init__(self, app_config):
|
||||
self.app = Flask(__name__, static_folder=None)
|
||||
self._before_adding_routes(self.app, app_config)
|
||||
self.app.json_encoder = Float32JSONEncoder
|
||||
self.app.json_encoder = StrictJSONEncoder
|
||||
server_config = app_config.server_config
|
||||
|
||||
# enable session data
|
||||
|
||||
@@ -232,7 +232,7 @@ class AnndataAdaptor(DataAdaptor):
|
||||
"Anndata data matrix is sparse, but not a CSC (columnar) matrix. "
|
||||
"Performance may be improved by using CSC."
|
||||
)
|
||||
if self.data.X.dtype != "float32":
|
||||
if self.data.X.dtype > np.dtype(np.float32):
|
||||
warnings.warn(
|
||||
f"Anndata data matrix is in {self.data.X.dtype} format not float32. " f"Precision may be truncated."
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ from server_timing import Timing as ServerTiming
|
||||
from backend.server.common.config.app_config import AppConfig
|
||||
from backend.common.constants import Axis, XApproximateDistribution
|
||||
from backend.common.errors import FilterError, JSONEncodingValueError, ExceedsLimitError, UnsupportedSummaryMethod
|
||||
from backend.common.utils.utils import jsonify_numpy
|
||||
from backend.common.utils.utils import jsonify_strict
|
||||
from backend.common.fbs.matrix import encode_matrix_fbs
|
||||
from backend.common.genesets import validate_gene_sets
|
||||
|
||||
@@ -331,7 +331,7 @@ class DataAdaptor(metaclass=ABCMeta):
|
||||
)
|
||||
|
||||
try:
|
||||
return jsonify_numpy(result)
|
||||
return jsonify_strict(result)
|
||||
except ValueError:
|
||||
raise JSONEncodingValueError("Error encoding differential expression to JSON")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user