Skip to content

Conversation

@sarapelka-blyk
Copy link

@sarapelka-blyk sarapelka-blyk commented Sep 10, 2025

Closes #533

Make sure you have read over the developer guide to ease
the review process. These include:

Include 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)

  • Add support for optional flx = ... normalization factor
  • Allow skipping N0 = zeros(...), ZAI = zeros(...), N1 = zeros(...) initializers
  • Pad CSC indptr when depmtx has trailing all-zero columns
  • Store flux in DepmtxReader.flx

@sarapelka-blyk sarapelka-blyk changed the title [BUG] Handle optional preamble lines in DepmtxReader and pad csc indptr [BUG] Handle optional preamble lines in DepmtxReader and pad csc indptr Sep 10, 2025
@sarapelka-blyk sarapelka-blyk marked this pull request as ready for review September 10, 2025 08:25
@drewejohnson drewejohnson self-requested a review September 30, 2025 14:16
@drewejohnson
Copy link
Collaborator

Thanks @sarapelka-blyk! And sorry for the delay. I'll get on this this week

@drewejohnson drewejohnson linked an issue Oct 4, 2025 that may be closed by this pull request
Copy link
Collaborator

@drewejohnson drewejohnson left a 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

Comment on lines +163 to +174
# 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)
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar comments from #512

  1. Please add this to the Attributes section of the docstring, when it may exist or not, what purpose it serves, etc.
  2. Please consider using the full name self.flux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG in depmtx reader

2 participants