-
-
Notifications
You must be signed in to change notification settings - Fork 134
ENH: n-D SciPy COO interop #919
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
base: main
Are you sure you want to change the base?
Conversation
| coords = np.empty((2, x.nnz), dtype=x.row.dtype) | ||
| coords[0, :] = x.row | ||
| coords[1, :] = x.col | ||
| return COO( | ||
| coords, | ||
| x.coords, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe x.coords doesn't exist for coo_matrix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't, indeed. I think we might need to specialize for coo_matrix vs coo_array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like:
def coords(x):
c = getattr(x, "coords", None)
if c is None:
c = (x.row, x.col)
return c| result = scipy.sparse.coo_matrix((self.data, (self.coords[0], self.coords[1])), shape=self.shape) | ||
| result = scipy.sparse.coo_array((self.data, self.coords), shape=self.shape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obviously this is a breaking change, this diff is just for demonstration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm willing to accept this breakage given that *_array is now recommended over *_matrix.
In fact, I'd change it in all formats, not just this one, for consistency.
What type of PR is this? (check all applicable)
Related issues
Checklist
Please explain your changes below.