Standardize epochtable() return value handling to always unpack tuple#49
Merged
Merged
Conversation
epochtable() returns (list, hash) but getchanneldevinfo() and _readtimeseries_via_syncgraph() assigned the tuple directly to et, causing et[epoch-1] to return the list instead of a dict entry, leading to AttributeError: 'list' object has no attribute 'get'. https://claude.ai/code/session_017Sfgtomgo9AEEGfKP57eJZ
- epoch/functions.py:epochrange() - was not unpacking tuple - element/functions.py:_get_epoch_table() - could return tuple to callers expecting a list; now handles both return types - fun/probe/export_binary.py - replace ad-hoc isinstance check with proper tuple unpacking https://claude.ai/code/session_017Sfgtomgo9AEEGfKP57eJZ
epochrange() accepts any object with an epochtable() method, which may return either a tuple (epochset subclasses) or a plain list (daq/navigator). Use isinstance check to handle both cases. https://claude.ai/code/session_017Sfgtomgo9AEEGfKP57eJZ
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.
Summary
This PR standardizes how the
epochtable()method return values are handled across the codebase. The method can return either a tuple or a single value, and this change ensures consistent unpacking behavior.Key Changes
_get_epoch_table()to handle both tuple and non-tuple return values fromepochtable(), extracting the first element when a tuple is returnedet, _ = probe.epochtable())epochrange()to unpack tuple return value fromepochtable()_readtimeseries_via_syncgraph()to unpack tuple return valuegetchanneldevinfo()to unpack tuple return valueImplementation Details
The changes assume that
epochtable()consistently returns a tuple where the first element is the epoch table data and the second element (discarded with_) is additional metadata. The centralized handling in_get_epoch_table()provides a fallback for cases where the return value might not be a tuple, improving robustness while other call sites are updated to expect the tuple format directly.https://claude.ai/code/session_017Sfgtomgo9AEEGfKP57eJZ