Skip to content

shape_reducer_rectangle error fix#844

Merged
CKrawczyk merged 27 commits intomasterfrom
rectangle-reducer-error-fix
Mar 4, 2026
Merged

shape_reducer_rectangle error fix#844
CKrawczyk merged 27 commits intomasterfrom
rectangle-reducer-error-fix

Conversation

@MollyBurkmar1
Copy link
Copy Markdown
Collaborator

This PR fixes an error encountered when reducing rectangle-classification extractions using the shape reducer where some rows contain empty subtask lists. During reduction, the presence of both empty and non-empty subtask lists caused the following error:

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (43,) + inhomogeneous part.

The issue is in the subtask_reducer_wrapper which attempts to construct a homogeneous array from the subtask lists but errors when they are different shapes (in this case a mix of empty and non-empty lists). This PR adds try/except blocks to the subtask_reducer_wrapper which removes any empty subtask lists.

Two tests have also been added to test_shape_reducer_rectangle to ensure the empty subtask lists are being removed correctly. One test contains data from the project which originally encountered this error and removes empty subtasks from clusters of one. The other tests a mixed cluster case containing rectangles with both empty and non-empty subtasks.

Copy link
Copy Markdown

@hound hound Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some files could not be reviewed due to errors:

./panoptes_aggregation/reducers/subtask_reducer_wrapper.py:93: [B007] Loop co...
./panoptes_aggregation/reducers/subtask_reducer_wrapper.py:93: [B007] Loop control variable 'frame_key' not used within the loop body. If this is intended, start the name with an underscore.
./panoptes_aggregation/reducers/subtask_reducer_wrapper.py:94: [B007] Loop control variable 'key' not used within the loop body. If this is intended, start the name with an underscore.

Copy link
Copy Markdown
Collaborator

@CKrawczyk CKrawczyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good. The last thing to do is to bump the "bug fix" version number to prepare for a release (found here https://github.com/zooniverse/aggregation-for-caesar/blob/rectangle-reducer-error-fix/panoptes_aggregation/version/__init__.py#L1 update to 5.3.1).

@CKrawczyk CKrawczyk merged commit 0d866c4 into master Mar 4, 2026
7 checks passed
@CKrawczyk CKrawczyk deleted the rectangle-reducer-error-fix branch March 4, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants