11import os
22from os import PathLike
3- from .setup import setup
43from anndata import AnnData # type: ignore
54import pandas as pd
6- from scipy .sparse import csr_matrix , csc_matrix
5+ from scipy .sparse import csc_matrix
76import h5py # type: ignore
8- from typing import Any , Union , List
7+ from typing import List
98from array import array
109import logging
1110from numpy import ndarray
12- from .utils import _validate_anndata , _validate_obs , _get_loupe_path , _validate_obsm , get_obs , get_obsm , get_count_matrix
11+ from .utils import _validate_anndata , _get_loupe_path , get_obs , get_obsm , get_count_matrix
1312
1413
1514def _create_string_dataset (obj : h5py .Group , key : str , strings : List [str ]| pd .Series | str | pd .Index ) -> None :
@@ -31,9 +30,9 @@ def _create_string_dataset(obj: h5py.Group, key: str, strings: List[str]|pd.Seri
3130 if strings == "" :
3231 #for the special case of an empty string
3332 #matches r behavior
34- d = obj .create_dataset (name = key , dtype = dtype , shape = (0 ,))
33+ obj .create_dataset (name = key , dtype = dtype , shape = (0 ,))
3534 else :
36- d = obj .create_dataset (name = key , data = strings , dtype = dtype )
35+ obj .create_dataset (name = key , data = strings , dtype = dtype )
3736
3837def _write_matrix (f : h5py .File , matrix : csc_matrix ,
3938 features : pd .Series | pd .Index , barcodes : pd .Index | pd .Series ,
@@ -202,7 +201,7 @@ def _write_hdf5(mat: csc_matrix,
202201 for n in obsm .keys ():
203202 _write_projection (projections , obsm [n ], n )
204203 f .close ()
205- except :
204+ except ValueError :
206205 logging .error ("Something went wrong while writing the h5 file. Please check the input data." )
207206 os .remove (file_path )
208207
0 commit comments