Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NEWS and docs to encourage accessor usage for sparse arrays #33050

Closed
wants to merge 2 commits into from

Conversation

tkf
Copy link
Member

@tkf tkf commented Aug 23, 2019

This is a followup of #32953.

@@ -50,6 +54,12 @@ function nonzeros(x::SparseColumnView)
return y
end

"""
SparseArrays.nonzeroinds(x)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added SparseArrays. prefix to indicate that it is not exported. But maybe we should export it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename it to storedindices. See: #33054 (comment)

@tkf tkf mentioned this pull request Aug 24, 2019
4 tasks
@ViralBShah ViralBShah added the sparse Sparse arrays label Aug 25, 2019
* `SparseMatrixCSC` and `SparseVector` are refactored to use accessor functions. It is now
highly recommended to use accessor methods like `size`, `nzrange`, `rowvals`, `nonzeros`,
and `nonzeroinds` instead of directly using field (e.g., `A.m`) whose names are
implementation details ([#32953]).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can say that the fields and their types of SparseMatrixCSC are implementation details. Many algorithms require explicit modifications to e.g. the colptr and the usage of this is spread far and wide throughout the ecosystem and the fields are in fact documented. If people want to support AbstractSparseMatrixCSC then they would need generic code, but I really think we should try to keep existing code that currently works with SparseMatrixCSC to keep working. The current structure of SparseMatrixCSC is very standard and what I blieve the vast majority of users need.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many algorithms require explicit modifications to e.g. the colptr and the usage of this is spread far and wide throughout the ecosystem and the fields are in fact documented.

Isn't dosomething!(getcolptr(A)) just as efficient as dosomething!(A.colptr)?

I really think we should try to keep existing code that currently works with SparseMatrixCSC to keep working

All SparseMatrixCSC fields are accessible through equivalent AbstractSparseMatrixCSC interface I proposed in #33054. So I think you can write an efficient algorithm on AbstractSparseMatrixCSC which is as efficient as SparseMatrixCSC? Can you comment on them in #33054?

(Sorry, I probably should have merged this to #33054. I thought #33039 may take sometime to be merged so it might make sense to write a NEWS/docs for its predecessor #32953 which is what this NEWS is all about.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether necessary or not, direct access to sparse matrix fields is both common and documented. Changing their names in a breaking fashion does not seem viable for 1.x — more attention should have been paid to these names/APIs before 1.0, but it’s too late for that now.

One way forward is to change the field names to better ones and use property overloading to keep code using the legacy names working.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(For people finding this issue now, the discussion of the assessor API is happening in #33054 and the discussion of the future deprecation strategy is in #33056)

@tkf
Copy link
Member Author

tkf commented Aug 25, 2019

It's probably better to accumulate discussion in #33054. I'm closing this PR since the exact phrasing may be different depending on what we do in #33054.

@tkf tkf closed this Aug 25, 2019
@ViralBShah
Copy link
Member

Nobody is proposing changing the field names in this PR or any other PR. There is no change to the internal structure, and all the code will keep working as is. The only thing we are doing is encouraging the use of accessor functions.

The only thing being figured out is the accessor API. @tkf I am reopening this and we'll figure out the right wording.

@ViralBShah ViralBShah reopened this Aug 25, 2019
@ViralBShah
Copy link
Member

@tkf I see you want to include everything in #33054. Closing this accordingly.

@ViralBShah ViralBShah closed this Aug 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sparse Sparse arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants