diff --git a/inferelator_velocity/denoise.py b/inferelator_velocity/denoise.py index 9e2cdd0..cc02491 100644 --- a/inferelator_velocity/denoise.py +++ b/inferelator_velocity/denoise.py @@ -1,3 +1,5 @@ +import numpy as np + from inferelator_velocity.utils.noise2self import ( _dist_to_row_stochastic, dot @@ -24,10 +26,13 @@ def denoise( f"run global_graph() first" ) - data.layers[output_layer] = dot( + data.layers[output_layer] = np.zeros(lref.shape, dtype=np.float32) + + dot( _dist_to_row_stochastic(data.obsp[graph_key]), lref, - dense=dense + dense=dense, + out=data.layers[output_layer] ) return data diff --git a/inferelator_velocity/utils/math.py b/inferelator_velocity/utils/math.py index 016bb6e..929deaf 100644 --- a/inferelator_velocity/utils/math.py +++ b/inferelator_velocity/utils/math.py @@ -19,14 +19,18 @@ f"{str(err)}" ) - def dot(x, y, dense=False, cast=False): + def dot(x, y, dense=False, cast=False, out=None): z = x @ y if dense and sps.issparse(z): z = z.A - return z + if out is not None: + out[:] = z + return out + else: + return z def scalar_projection(