Repository navigation
fix(activations): fail early when no stimuli are passed - #2636
Merged
Merged
Conversation
With an empty list of paths or an empty StimulusSet, the batch loop never ran, layer_activations stayed None, and packaging failed with "AttributeError: 'NoneType' object has no attribute 'values'". Raise a ValueError at the start of from_paths instead. It has to come before stored activations are looked up: their key ignores the paths, so an empty request under a stimuli identifier that is already stored got the stored activations back. Closes brain-score#376
KartikP
approved these changes
Nov 5, 2026
KartikP
left a comment
Collaborator
There was a problem hiding this comment.
Simple and long standing issue! Thanks
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.
Closes #376.
With an empty list of paths or an empty
StimulusSet, nothing complains until packaging._get_activations_batchednever enters its batch loop, solayer_activationsstaysNone, and_packagefails with an error that says nothing about the input:With stored activations it can be worse. Their key ignores the paths, so an empty request under a stimuli identifier that is already stored gets the stored activations back. With a list of paths that is a full assembly for zero stimuli. With a
StimulusSetit fails later, inattach_stimulus_set_meta.This adds a check at the start of
from_paths, before the stored activations are looked up:__call__andfrom_stimulus_setboth go throughfrom_paths, so all entry points are covered, with or withoutrequire_variance. The message matches the existing "No layers passed to retrieve activations from" check in_from_paths.Test:
test_no_stimulipasses an empty list and an emptyStimulusSet(filtered down to zero rows) through__call__, withrequire_varianceoff and on. It also replaces_from_paths_storedand_from_pathswith stubs that fail if called, so the check is shown to come before both computing and loading activations. It fails onmasterand passes here.This doesn't overlap with #2628 or #2629. They touch other parts of the same file and merge cleanly with this in either order.