Conversation
np.linspace(min, max, rowbins) was using rowbins as the edge count, but an edge count of N only makes N-1 bins. Requesting 10 bins came back as a 9x9 matrix, silently wrong shape with no error. Changed it to rowbins + 1 / colbins + 1 so N bins actually means N bins. get_load_classes in the same file already does this correctly (k+1), so this brings find_rainflow_matrix in line with the rest of the module. Added a test covering the int-bins path specifically, since the existing TestFindRainflowMatrix only ever exercises the explicit bin-edge-array path and never caught this. Confirmed the new test fails on the old code and passes with the fix. Full suite passes, 55 tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
find_rainflow_matrix(data, rowbins, colbins) treats rowbins/colbins as an edge count when they're given as an int, but np.linspace(min, max, rowbins) needs rowbins + 1 edges to actually produce rowbins bins. Requesting 10 bins on an axis comes back as 9 bins, silently, no error raised.
Reproduced: fatpack.find_rainflow_matrix(data, 10, 10, return_bins=True) returns a 9x9 matrix instead of 10x10.
get_load_classes elsewhere in the same file already does this right (np.linspace(ymin, ymax, k+1)), so this brings find_rainflow_matrix in line with the rest of the module rather than introducing a new convention.
Fix is one line per axis: rowbins + 1 / colbins + 1.
Added TestFindRainflowMatrixIntBins covering the int-bins path, since the existing TestFindRainflowMatrix only exercises explicit bin-edge arrays and never caught this. Verified the new test fails on the old code (git stash) with the wrong shape, passes with the fix.
Full test suite passes, 55 tests.