Skip to content

Conversation

@klimaj
Copy link
Member

@klimaj klimaj commented Dec 31, 2025

This PR aims to make a minor change to the Pose.cache infrastructure.

Currently, accessing SimpleMetrics data in the Pose.cache dictionary via the get_sm_data method lazily initializes a SimpleMetricData entry in the Pose.data cache. If a Pose does not already contain SimpleMetrics data, then merely accessing this getter method bitwise mutates the Pose (albeit harmlessly, since it only instantiates an empty container). However, in principle, a getter ought not to modify the underlying state or binary representation of the Pose.

Herein, we instead conditionally check for Pose.data().has(CacheableDataType.SIMPLE_METRIC_DATA), performing the same test at the PyRosetta layer that the get_sm_data method performs at the C++ interface. If False, then we return an empty dictionary without lazily initializing a SimpleMetricData entry in the Pose.data cache. This minor update enables deterministic behavior when instantiating PackedPose objects, during which the Pose.cache dictionary is accessed to define the PackedPose.scores attribute. By preventing lazy initialization of the SimpleMetrics data cache, the new behavior is consistent regardless of whether input Pose objects contain SimpleMetrics data. Unit tests are also added herein to ensure consistency of the underlying bitwise representations of Pose objects with and without SimpleMetrics data.

@klimaj klimaj requested review from ajasja and lyskov December 31, 2025 03:37
@klimaj klimaj added bug Something isn't working 03 PyRosetta industry ready_for_review This PR is ready to be reviewed and merged. labels Dec 31, 2025
Copy link
Member

@ajasja ajasja left a comment

Choose a reason for hiding this comment

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

Looks good to me, love the test sequence:) (pyrosetta.io.pose_from_sequence("TEST/SIMPLE/METRIC/DATA"))

Copy link
Member

@lyskov lyskov left a comment

Choose a reason for hiding this comment

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

LGTM!

@klimaj
Copy link
Member Author

klimaj commented Jan 7, 2026

Thanks @ajasja and @lyskov !

@lyskov lyskov merged commit ebb233b into RosettaCommons:main Jan 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

03 PyRosetta bug Something isn't working industry ready_for_review This PR is ready to be reviewed and merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants