Change first example for sparse arrays #33189
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the first example in the SparseArrays docs is the following:
This example is shown before the COO format is explained (and it needs to use COO as it deals with explicitly setting zero values). If a user scans this page superficially - e.g. when looking for a quick example that shows how to initialize a sparse matrix -, they might be inclined to think that the function
creates a 3x3 matrix of the values listed in the arrays and that way confuse it with
(The latter syntax is also there on the page, coming from the docstring of
findnz
).I have been confused by this multiple times when I forgot the syntax and visited the Sparse Arrays documentation page to refresh my memory. To mitigate this, this PR proposes a simple change and adds an additional non-zero entry, which hopefully makes the docs a bit more instructive.