@@ -37,14 +37,14 @@ def typ(request):
3737
3838
3939@pytest .mark .parametrize ('dtype' , ['float32' , 'int64' ])
40- def test_normalize_total (typ , dtype ):
41- adata = AnnData (typ (X_total ), dtype = dtype )
40+ def test_normalize_total (array_type , dtype ):
41+ adata = AnnData (array_type (X_total ). astype ( dtype ) )
4242 sc .pp .normalize_total (adata , key_added = 'n_counts' )
4343 assert np .allclose (np .ravel (adata .X .sum (axis = 1 )), [3.0 , 3.0 , 3.0 ])
4444 sc .pp .normalize_total (adata , target_sum = 1 , key_added = 'n_counts2' )
4545 assert np .allclose (np .ravel (adata .X .sum (axis = 1 )), [1.0 , 1.0 , 1.0 ])
4646
47- adata = AnnData (typ (X_frac ), dtype = dtype )
47+ adata = AnnData (array_type (X_frac ). astype ( dtype ) )
4848 sc .pp .normalize_total (adata , exclude_highly_expressed = True , max_fraction = 0.7 )
4949 assert np .allclose (np .ravel (adata .X [:, 1 :3 ].sum (axis = 1 )), [1.0 , 1.0 , 1.0 ])
5050
@@ -59,17 +59,17 @@ def test_normalize_total_rep(typ, dtype):
5959
6060
6161@pytest .mark .parametrize ('dtype' , ['float32' , 'int64' ])
62- def test_normalize_total_layers (typ , dtype ):
63- adata = AnnData (typ (X_total ), dtype = dtype )
62+ def test_normalize_total_layers (array_type , dtype ):
63+ adata = AnnData (array_type (X_total ). astype ( dtype ) )
6464 adata .layers ["layer" ] = adata .X .copy ()
6565 with pytest .warns (FutureWarning , match = r".*layers.*deprecated" ):
6666 sc .pp .normalize_total (adata , layers = ["layer" ])
6767 assert np .allclose (adata .layers ["layer" ].sum (axis = 1 ), [3.0 , 3.0 , 3.0 ])
6868
6969
7070@pytest .mark .parametrize ('dtype' , ['float32' , 'int64' ])
71- def test_normalize_total_view (typ , dtype ):
72- adata = AnnData (typ (X_total ), dtype = dtype )
71+ def test_normalize_total_view (array_type , dtype ):
72+ adata = AnnData (array_type (X_total ). astype ( dtype ) )
7373 v = adata [:, :]
7474
7575 sc .pp .normalize_total (v )
@@ -127,7 +127,7 @@ def test_normalize_pearson_residuals_values(sparsity_func, dtype, theta, clip):
127127 residuals_reference = (X - mu ) / np .sqrt (mu + mu ** 2 / theta )
128128
129129 # compute output to test
130- adata = AnnData (sparsity_func (X ), dtype = dtype )
130+ adata = AnnData (sparsity_func (X ). astype ( dtype ) )
131131 output = sc .experimental .pp .normalize_pearson_residuals (
132132 adata , theta = theta , clip = clip , inplace = False
133133 )
0 commit comments