Skip to content

Commit

Permalink
Eliminate needless ternary
Browse files Browse the repository at this point in the history
Co-authored-by: adamsilverstein <[email protected]>
  • Loading branch information
westonruter and adamsilverstein committed Oct 14, 2024
1 parent 477cc33 commit dca43e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,7 @@ public function get_all_element_max_intersection_ratios(): array {
foreach ( $denormalized_elements as list( $group, $url_metric, $element ) ) {
$element_intersection_ratios[] = $element['intersectionRatio'];
}
$elements_max_intersection_ratios[ $xpath ] = count( $element_intersection_ratios ) > 1
? (float) max( ...$element_intersection_ratios )
: $element_intersection_ratios[0];
$elements_max_intersection_ratios[ $xpath ] = (float) max( $element_intersection_ratios );
}
return $elements_max_intersection_ratios;
} )();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,15 @@ public function data_provider_element_max_intersection_ratios(): array {
};

return array(
'one-element-sample-size-one' => array(
'one-element-one-group' => array(
'url_metrics' => array(
$get_sample_url_metric( 600, $xpath1, 0.5 ),
),
'expected' => array(
$xpath1 => 0.5,
),
),
'one-element-three-groups-of-one' => array(
'url_metrics' => array(
$get_sample_url_metric( 400, $xpath1, 0.0 ),
$get_sample_url_metric( 600, $xpath1, 0.5 ),
Expand All @@ -671,7 +679,7 @@ public function data_provider_element_max_intersection_ratios(): array {
$xpath1 => 1.0,
),
),
'three-elements-sample-size-two' => array(
'three-elements-sample-size-two' => array(
'url_metrics' => array(
// Group 1.
$get_sample_url_metric( 400, $xpath1, 0.0 ),
Expand All @@ -689,7 +697,7 @@ public function data_provider_element_max_intersection_ratios(): array {
$xpath3 => 0.6,
),
),
'no-url-metrics' => array(
'no-url-metrics' => array(
'url_metrics' => array(),
'expected' => array(),
),
Expand Down

0 comments on commit dca43e9

Please sign in to comment.