-
Notifications
You must be signed in to change notification settings - Fork 37
[BUG] Handle optional preamble lines in DepmtxReader and pad csc indptr #534
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: develop
Are you sure you want to change the base?
[BUG] Handle optional preamble lines in DepmtxReader and pad csc indptr #534
Conversation
[BUG] Handle optional preamble lines in DepmtxReader and pad csc indptr|
Thanks @sarapelka-blyk! And sorry for the delay. I'll get on this this week |
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.
This behavior would really use some testing. I know the depletion files are lacking in functionality.
Could you create a copy of the existing depletion matrix file and add these preamble / zeros init behavior? Then we can show we get what we expect
| # Pad column pointer if file omits trailing all-zero columns | ||
| _, nCols = matrixSize | ||
| indptr = cscProcessor.indptr | ||
| expected = nCols + 1 | ||
| if indptr.shape[0] < expected: | ||
| pad = expected - indptr.shape[0] | ||
| indptr = concatenate([indptr, full(pad, indptr[-1], dtype=indptr.dtype)]) | ||
| elif indptr.shape[0] > expected: | ||
| raise ValueError(f"index pointer size ({indptr.shape[0]}) should be ({expected})") | ||
| self.depmtx = csc_matrix( | ||
| (cscProcessor.data[:, 0], cscProcessor.indices, | ||
| cscProcessor.indptr), dtype=longfloat, shape=matrixSize) | ||
| (cscProcessor.data[:, 0], cscProcessor.indices, indptr), | ||
| dtype=longfloat, shape=matrixSize) |
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.
This logic isn't immediately clear to me. If the shape of the matrix is known ahead of construction, does it matter that there are full zero columns? They shouldn't have any information in the sparse matrix structure.
Can you add some testing for this logic?
| BaseReader.__init__(self, filePath, 'depmtx') | ||
| SparseReaderMixin.__init__(self, sparse) | ||
| self.deltaT = None | ||
| self.flx = None |
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.
Similar comments from #512
- Please add this to the
Attributessection of the docstring, when it may exist or not, what purpose it serves, etc. - Please consider using the full name
self.flux
Closes #533
Make sure you have read over the developer guide to ease
the review process. These include:
docs/contributors.rstInclude a thorough and concise overview of the changes, and why this PR is overall beneficial to the project.
The previous version of the reader errors out when it comes across a preamble/initialization of the N0, N1, A, and Z matrices. Additionally it cannot handle a normalization factor at the top of the file.
Changes made:
Handle optional preamble lines in DepmtxReader (flx, N0/ZAI/N1)
flx = ...normalization factorN0 = zeros(...),ZAI = zeros(...),N1 = zeros(...)initializersindptrwhen depmtx has trailing all-zero columnsDepmtxReader.flx