@@ -98,22 +98,14 @@ def __init__(
9898
9999 with File (self ._path , "r" ) as handle :
100100 self ._indptr = handle [self ._indptr_name ][:]
101- if len (self ._indptr .shape ) != 1 or not issubdtype (
102- self ._indptr .dtype , integer
103- ):
104- raise ValueError (
105- "'indptr' dataset should be 1-dimensional and contain integers"
106- )
101+ if len (self ._indptr .shape ) != 1 or not issubdtype (self ._indptr .dtype , integer ):
102+ raise ValueError ("'indptr' dataset should be 1-dimensional and contain integers" )
107103 if by_column :
108104 if len (self ._indptr ) != shape [1 ] + 1 :
109- raise ValueError (
110- "'indptr' dataset should have length equal to the number of columns + 1"
111- )
105+ raise ValueError ("'indptr' dataset should have length equal to the number of columns + 1" )
112106 else :
113107 if len (self ._indptr ) != shape [0 ] + 1 :
114- raise ValueError (
115- "'indptr' dataset should have length equal to the number of columns + 1"
116- )
108+ raise ValueError ("'indptr' dataset should have length equal to the number of columns + 1" )
117109 if self ._indptr [0 ] != 0 :
118110 raise ValueError ("first entry of 'indptr' dataset should be zero" )
119111 for i in range (1 , len (self ._indptr )):
@@ -122,9 +114,7 @@ def __init__(
122114
123115 ddset = handle [self ._data_name ]
124116 if len (ddset .shape ) != 1 or ddset .shape [0 ] != self ._indptr [- 1 ]:
125- raise ValueError (
126- "'data' dataset should have length equal to the number of non-zero elements"
127- )
117+ raise ValueError ("'data' dataset should have length equal to the number of non-zero elements" )
128118 self ._modify_dtype = dtype is not None and dtype != ddset .dtype
129119 if not self ._modify_dtype :
130120 dtype = ddset .dtype
@@ -133,14 +123,10 @@ def __init__(
133123 # Not going to check for consistency of the indices themselves.
134124 idset = handle [self ._indices_name ]
135125 if len (idset .shape ) != 1 or idset .shape [0 ] != self ._indptr [- 1 ]:
136- raise ValueError (
137- "'indices' dataset should have length equal to the number of non-zero elements"
138- )
126+ raise ValueError ("'indices' dataset should have length equal to the number of non-zero elements" )
139127 if not issubdtype (idset .dtype , integer ):
140128 raise ValueError ("'indices' dataset should contain integers" )
141- self ._modify_index_dtype = (
142- index_dtype is not None and index_dtype != idset .dtype
143- )
129+ self ._modify_index_dtype = index_dtype is not None and index_dtype != idset .dtype
144130 if not self ._modify_index_dtype :
145131 index_dtype = idset .dtype
146132 self ._index_dtype = index_dtype
@@ -269,9 +255,7 @@ def _extract_array(
269255 start_idx = bisect_left (curindices , secondary_start )
270256 end_idx = len (curindices )
271257 if search_end :
272- end_idx = bisect_left (
273- curindices , secondary_end , lo = start_idx , hi = end_idx
274- )
258+ end_idx = bisect_left (curindices , secondary_end , lo = start_idx , hi = end_idx )
275259
276260 if is_consecutive :
277261 mod_indices = curindices [start_idx :end_idx ]
@@ -406,14 +390,7 @@ def _consecutive(r, cols, values):
406390class Hdf5CompressedSparseMatrix (DelayedArray ):
407391 """Compressed sparse matrix in a HDF5 file as a ``DelayedArray``."""
408392
409- def __init__ (
410- self ,
411- path : str ,
412- group_name : Optional [str ],
413- shape : Tuple [int , int ],
414- by_column : bool ,
415- ** kwargs
416- ):
393+ def __init__ (self , path : str , group_name : Optional [str ], shape : Tuple [int , int ], by_column : bool , ** kwargs ):
417394 """To construct a ``Hdf5CompressedSparseMatrix`` from an existing :py:class:`~Hdf5CompressedSparseMatrixSeed`,
418395 use :py:meth:`~delayedarray.wrap.wrap` instead.
419396
@@ -439,9 +416,7 @@ def __init__(
439416 if isinstance (path , Hdf5CompressedSparseMatrixSeed ):
440417 seed = path
441418 else :
442- seed = Hdf5CompressedSparseMatrixSeed (
443- path , group_name , shape , by_column , ** kwargs
444- )
419+ seed = Hdf5CompressedSparseMatrixSeed (path , group_name , shape , by_column , ** kwargs )
445420 super (Hdf5CompressedSparseMatrix , self ).__init__ (seed )
446421
447422 @property
@@ -530,13 +505,9 @@ def to_scipy_sparse_matrix_from_Hdf5CompressedSparseMatrix(
530505 _indptr = handle [x .indptr_name ][:]
531506
532507 if x .by_column :
533- _matrix = scipy .sparse .csc_matrix (
534- (_data , _indices , _indptr ), shape = x .shape , dtype = x .dtype
535- )
508+ _matrix = scipy .sparse .csc_matrix ((_data , _indices , _indptr ), shape = x .shape , dtype = x .dtype )
536509 else :
537- _matrix = scipy .sparse .csr_matrix (
538- (_data , _indices , _indptr ), shape = x .shape , dtype = x .dtype
539- )
510+ _matrix = scipy .sparse .csr_matrix ((_data , _indices , _indptr ), shape = x .shape , dtype = x .dtype )
540511
541512 if format == "csc" :
542513 return _matrix .tocsc ()
0 commit comments