single-cell-data / SOMA

A flexible and extensible API for annotated 2D matrix data stored in multiple underlying formats.
MIT License
70 stars 9 forks source link

Empty query results typing #101

Closed bkmartinjr closed 1 year ago

bkmartinjr commented 1 year ago

Several small changes to ensure that empty query results have types that are compatible with AnnData, avoiding warnings/errors from AnnData.

  1. The empty matrix result in the fast CSR builder was creating an empty float64 matrix. AnnData has a strong preference for float32, and will issue a warning on anything else. As the actual type is relatively immaterial (it is an empty matrix), this PR changes to float32 to minimize complaints from AnnData.
  2. The axis dataframes need to have an index type of str. Previous code did not work correctly when the dataframe was empty.
  3. When the resulting X is empty (nnz==0), need to ensure it has the same shape as the axis.

Fixes: single-cell-data/TileDB-SOMA#805

bkmartinjr commented 1 year ago

@thetorpedodog - I forgot one small change which I pushed after your review. Mentioning in case you want to take another look.

thetorpedodog commented 1 year ago

@thetorpedodog - I forgot one small change which I pushed after your review. Mentioning in case you want to take another look.

I saw that change roll in as I was looking at it; it’s good.