Skip to content

Commit

Permalink
rand_structured is now the default randomisation function
Browse files Browse the repository at this point in the history
updates #76
  • Loading branch information
shawnlaffan committed May 21, 2016
1 parent 6dcc448 commit 5272780
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lib/Biodiverse/GUI/Tabs/Randomise.pm
Original file line number Diff line number Diff line change
Expand Up @@ -268,23 +268,29 @@ sub make_function_model {

# Add each randomisation function
my $functions = Biodiverse::Randomise->get_randomisation_functions;
my %functions = %$functions;
my @funcs;
# SWL: put the selected one first
# - should really manipulate GTK iters to just select it
if (defined $args{selected_function}) {
#delete $functions{$args{selected_function}};
#@funcs = ($args{selected_function}, sort keys %functions);
@funcs = ($args{selected_function}); # only allow the previously used function
my %functions = %$functions;
my @funcs;
# SWL: put the selected one first
# - should really manipulate GTK iters to just select it
if (defined $args{selected_function}) {
#delete $functions{$args{selected_function}};
#@funcs = ($args{selected_function}, sort keys %functions);
@funcs = ($args{selected_function}); # only allow the previously used function
}
else {
my $default = Biodiverse::Randomise->get_default_rand_function;
if (exists $functions->{$default}) {
push @funcs, $default;
push @funcs, grep {$_ ne $default} sort keys %{$functions};
}
else {
@funcs = sort keys %{$functions};
push @funcs, sort keys %{$functions};
}
}
foreach my $name (@funcs) {
# Add to model
my $iter = $model->append;
$model->set($iter, 0, $name);

}

$self->{selected_function_iter} = $model->get_iter_first;
Expand Down
4 changes: 4 additions & 0 deletions lib/Biodiverse/Randomise.pm
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ sub export_prng_current_state {
return;
}

sub get_default_rand_function {
return 'rand_structured';
}

# get a list of the all the publicly available randomisations.
sub get_randomisation_functions {
my $self = shift || __PACKAGE__;
Expand Down

0 comments on commit 5272780

Please sign in to comment.