MultipleSeries.pca(): raise on unequal lengths instead of returning None - #705
Open
vaibhav8a wants to merge 1 commit into
Open
MultipleSeries.pca(): raise on unequal lengths instead of returning None#705vaibhav8a wants to merge 1 commit into
vaibhav8a wants to merge 1 commit into
Conversation
pca() printed a plain string and fell off the end of the function when the series had different lengths, so callers silently got None back and failed later with an AttributeError far from the cause. Raise a ValueError naming common_time() as the fix, and report the offending lengths. Fixes LinkedEarth#702
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.
Fixes #702.
Problem
MultipleSeries.pca()guarded unequal series lengths with a bareprint()and then fell off the end of the function:So the caller got
Noneback. The failure surfaced later asAttributeError: 'NoneType' object has no attribute 'screeplot'— far from the actual cause — and the message itself couldn't be filtered, captured by logging, or suppressed the waywarnings.warncan.Change
Raise a
ValueErrornamingcommon_time()as the fix, and include the lengths that disagreed:The
elsebranch is untouched, so the equal-length path is byte-for-byte the same.Testing
Added
TestMultipleSeriesPca::test_pca_t4, which builds aMultipleSeriesof unequal length and asserts aValueErrormentioningcommon_time. Confirmed it guards the change: with themultipleseries.pyhunk stashed the test fails withFailed: DID NOT RAISE ValueError, and passes with it applied.pytest pyleoclim/tests/test_core_MultipleSeries.py— 100 passed.Scoped to
pca()only. The other sites in the #697 survey depend on the unified-policy decision that's still open, so I left them alone; this one is the case #702 calls out as a bug in its own right regardless of how that lands.