Skip to content

MultipleSeries.pca(): silently returns None instead of raising when series lengths differ #702

Description

@CommonClimate

Part of #697.

Where

MultipleSeries.pca(), pyleoclim/core/multipleseries.py (~line 1058-1061):

flag, lengths = self.equal_lengths()

if flag==False:
    print('All Time Series should be of same length. Apply common_time() first')
else: # if all series have equal length
    ...
    return res

Problem

This is worse than an inconsistency — it's a correctness bug. When series lengths differ, the function print()s a plain string (not warnings.warn, so it can't be filtered, captured by logging, or suppressed/un-suppressed like every other message in the codebase) and then falls off the end of the function with no return, so the caller silently gets None back. Downstream code (res.screeplot(), res.modeplot(), etc., per the method's own docstring example) then fails with a confusing AttributeError: 'NoneType' object has no attribute ... far from the actual cause.

Proposed fix

Raise a ValueError (or equivalent) naming common_time() as the fix, consistent with the unified policy from #697. This one should probably be fixed regardless of how the broader consistency question is resolved, since silently returning None is a bug on its own.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions