From 0e872a813d223b66cb89549de48e6232d4394d1c Mon Sep 17 00:00:00 2001 From: TomNicholas Date: Sat, 11 Nov 2023 22:39:32 -0500 Subject: [PATCH] simply generation of sparse arrays in example --- doc/user-guide/testing.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/user-guide/testing.rst b/doc/user-guide/testing.rst index 032b733674b..fc8ef5ee0d2 100644 --- a/doc/user-guide/testing.rst +++ b/doc/user-guide/testing.rst @@ -178,15 +178,14 @@ different type: .. ipython:: python def convert_to_sparse(var): - if var.ndim == 0: - return var - else: - var.data = sparse.COO.from_numpy(var.to_numpy()) - return var + var.data = sparse.COO.from_numpy(var.to_numpy()) + return var .. ipython:: python - sparse_variables = xrst.variables().map(convert_to_sparse) + sparse_variables = xrst.variables(dims=dimension_names(min_dims=1)).map( + convert_to_sparse + ) sparse_variables.example() sparse_variables.example()