-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
vector.length() should be number of nonzero entries #29218
Comments
New commits:
|
Author: Markus Wageringel |
Branch: u/gh-mwageringel/29218 |
Commit: |
Reviewer: Travis Scrimshaw |
comment:2
Hmmm...my initial thought was this is a good change to match the behavior as documented. However, there is an issue that does arise. The iterator for a vector is different than for a more generic element of a for i in range(v.length()):
v[i] += 1 So this could break code and it is somewhat unnatural given the name of the method. I would propose instead overriding the documentation to reflect the more natural behavior because of the implementation and how people are expecting to use this class. I further believe this will be a very special case to allow the break in inherited behavior. |
comment:3
The method is also broken for matrices:
This would be useful for sparse matrices in particular. What would you suggest to do with matrices then? Should it return the number of rows? Given that the method does not currently work for matrices, it would not break anything if we make it return the length of the support, except that it is inconsistent with vectors. |
comment:4
There is much less of a case for matrices as it is only because of the internal representation as rows that length has a distinct meaning. There is nothing really special about the number of rows versus columns, and it makes equal sense to have it be the size of the support. So I would instead fix matrices to be the size of the support and keep vectors as something special (and inconsistent). |
comment:5
Moving tickets to milestone sage-9.2 based on a review of last modification date, branch status, and severity. |
comment:7
Setting new milestone based on a cursory review of ticket status, priority, and last modification date. |
comment:8
Setting a new milestone for this ticket based on a cursory review. |
comment:9
Stalled in |
comment:12
Replying to Markus Wageringel:
Still broken in 9.7.rc1. This must be some strange Cython-related effect:
|
Dependencies: #34509 |
Changed branch from u/gh-mwageringel/29218 to u/mkoeppe/29218 |
According to the documentation of
length
frommodules_with_basis.py
:This is solved by overwriting
length
inFreeModuleElement
.Depends on #34509
Component: linear algebra
Author: Markus Wageringel
Branch/Commit: u/mkoeppe/29218 @
324478d
Reviewer: Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/29218
The text was updated successfully, but these errors were encountered: