GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||
GeezerVison is showing github.com — Add `A.setdiag(x, k)` by eriknw · Pull Request #493 · python-graphblas/python-graphblas Conversation
|
|
coverage: 98.838% (-0.9%) from 99.743% when pulling 9e51b87 on eriknw:wip_setdiag into bf28a79 on python-graphblas:main. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This is ready for review. I updated it to implement option 2 from #487 (comment) by adding The main remaining question I have is regarding I think the pros and cons from #487 (comment) are still accurate and I think are worth rereading when reviewing this PR. I am +1 for adding |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Do you plan to allow A(mask, accum=accum).setdiag(v)? Which would just delegate to the keywords in the setdiag method.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Unsure. I removed this. It would be very easy to add back. What do you think? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Use `second` as the accumulator for `clear_missing=False` behavior.
Add it as an issue to discuss, but don't hold up this PR for that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This (allowing to set 0-length when k == 0) is actually what setdiag in scipy.sparse does. I think this is a good idea and let's us better handle length 0 dimensions. For example, should it be possible to set any diagonal in a 0x2 Matrix? My latest commit allows this. For the record, scipy.sparse setdiag also allows the size of the vector of new values to be too large or too small. Should we follow suite, or require that the vector exactly match the size of the diagonal, which is what we currently do? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| Diag = v.diag(k) | ||
| if Diag.shape != self.shape: | ||
| Diag.resize(self._nrows, self._ncols) | ||
| if mask is None: | ||
| mask = Diag.S | ||
| self(accum=accum, mask=mask, **opts) << Diag |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
For posterity and those who browse this PR, these lines are the main recipe for setting the diagonal of a Matrix with a Vector. The rest of the function mostly deals with handing different input types and giving good error messages when necessary.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.