Determines if two actions are considered to be the same. Two actions being "the same" is defined here as two actions that would result in a similar screen state. Args: action_1_touch_yx: The (y, x) coordinates of the first action's touch. action_1_lift_yx: The (y, x) co
(
action_1_touch_yx,
action_1_lift_yx,
action_1_action_type,
action_2_touch_yx,
action_2_lift_yx,
action_2_action_type,
annotation_positions,
tap_distance_threshold = _TAP_DISTANCE_THRESHOLD,
annotation_width_augment_fraction = ANNOTATION_WIDTH_AUGMENT_FRACTION,
annotation_height_augment_fraction = ANNOTATION_HEIGHT_AUGMENT_FRACTION,
)
| 233 | |
| 234 | |
| 235 | def check_actions_match( |
| 236 | action_1_touch_yx, |
| 237 | action_1_lift_yx, |
| 238 | action_1_action_type, |
| 239 | action_2_touch_yx, |
| 240 | action_2_lift_yx, |
| 241 | action_2_action_type, |
| 242 | annotation_positions, |
| 243 | tap_distance_threshold = _TAP_DISTANCE_THRESHOLD, |
| 244 | annotation_width_augment_fraction = ANNOTATION_WIDTH_AUGMENT_FRACTION, |
| 245 | annotation_height_augment_fraction = ANNOTATION_HEIGHT_AUGMENT_FRACTION, |
| 246 | ): |
| 247 | """Determines if two actions are considered to be the same. |
| 248 | |
| 249 | Two actions being "the same" is defined here as two actions that would result |
| 250 | in a similar screen state. |
| 251 | |
| 252 | Args: |
| 253 | action_1_touch_yx: The (y, x) coordinates of the first action's touch. |
| 254 | action_1_lift_yx: The (y, x) coordinates of the first action's lift. |
| 255 | action_1_action_type: The action type of the first action. |
| 256 | action_2_touch_yx: The (y, x) coordinates of the second action's touch. |
| 257 | action_2_lift_yx: The (y, x) coordinates of the second action's lift. |
| 258 | action_2_action_type: The action type of the second action. |
| 259 | annotation_positions: The positions of the UI annotations for the screen. It |
| 260 | is A 2D int array of shape (num_bboxes, 4), where each row represents a |
| 261 | bounding box: (y_top_left, x_top_left, box_height, box_width). Note that |
| 262 | containment is inclusive of the bounding box edges. |
| 263 | tap_distance_threshold: The threshold that determines if two taps result in |
| 264 | a matching screen state if they don't fall the same bounding boxes. |
| 265 | annotation_width_augment_fraction: The fraction to increase the width of the |
| 266 | bounding box by. |
| 267 | annotation_height_augment_fraction: The fraction to increase the height of |
| 268 | of the bounding box by. |
| 269 | |
| 270 | Returns: |
| 271 | A boolean representing whether the two given actions are the same or not. |
| 272 | """ |
| 273 | action_1_touch_yx = jnp.asarray(action_1_touch_yx) |
| 274 | action_1_lift_yx = jnp.asarray(action_1_lift_yx) |
| 275 | action_2_touch_yx = jnp.asarray(action_2_touch_yx) |
| 276 | action_2_lift_yx = jnp.asarray(action_2_lift_yx) |
| 277 | |
| 278 | # Checks if at least one of the actions is global (i.e. not DUAL_POINT), |
| 279 | # because if that is the case, only the actions' types need to be compared. |
| 280 | has_non_dual_point_action = jnp.logical_or( |
| 281 | _is_non_dual_point_action(action_1_action_type), |
| 282 | _is_non_dual_point_action(action_2_action_type), |
| 283 | ) |
| 284 | |
| 285 | different_dual_point_types = jnp.logical_xor( |
| 286 | is_tap_action(action_1_touch_yx, action_1_lift_yx), |
| 287 | is_tap_action(action_2_touch_yx, action_2_lift_yx), |
| 288 | ) |
| 289 | |
| 290 | is_tap = jnp.logical_and( |
| 291 | is_tap_action(action_1_touch_yx, action_1_lift_yx), |
| 292 | is_tap_action(action_2_touch_yx, action_2_lift_yx), |
nothing calls this directly
no test coverage detected