Skip to content

Commit

Permalink
TreeNode::group_nodes_below args: override target_value if num_cluste…
Browse files Browse the repository at this point in the history
…rs non-zero

No need to override if caller does not want any clusters...

Updates #803
  • Loading branch information
shawnlaffan committed Nov 16, 2021
1 parent 20668b7 commit 73e03eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/Biodiverse/SpatialConditions/SpCalc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,13 @@ sp_points_in_same_cluster_group (
group_by_depth => 1,
)
# target_distance is ignored if num_clusters is set
sp_points_in_same_cluster_group (
output => "some_cluster_output",
num_clusters => 4,
target_distance => 0.25,
)
END_EXAMPLES

my %metadata = (
Expand Down
2 changes: 1 addition & 1 deletion lib/Biodiverse/TreeNode.pm
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ sub group_nodes_below {

# override target value if $args{num_clusters} passed
my $target_value
= defined $args{num_clusters}
= $args{num_clusters}
? undef
: ($args{target_value} // $args{target_distance});

Expand Down

0 comments on commit 73e03eb

Please sign in to comment.