Skip to content

Commit

Permalink
if PDL_SIMPLE_ENGINE in ENV, use ONLY that if engine unspecified
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Mar 29, 2024
1 parent e7d87a1 commit 75f1a1b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
8 changes: 6 additions & 2 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- P{GPLOT,Lplot} to read devices using proper API not subprocesses
- if PDL_SIMPLE_ENGINE in ENV, use ONLY that if engine unspecified

1.010 2024-03-24
- fix PGPLOT to read devices correctly
Expand Down Expand Up @@ -27,8 +28,11 @@
1.003 2013-03-20
- Fix tests for smoker compatibility

1.002
1.002 2013-03-20
- window name, default to inches

1.001 2013-03-20
- Include Prima support

1.001 2013-03-19
1.000 2013-03-14
- initial CPAN release
44 changes: 29 additions & 15 deletions lib/PDL/Graphics/Simple.pm
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,25 @@ object.
The non-object interface will keep using the last plot engine you used
successfully. On first start, you can specify an engine with the
environment variable PDL_SIMPLE_ENGINE. If that one isn't working, or
environment variable C<PDL_SIMPLE_ENGINE>. As of 1.011, only that will be tried, but
if you didn't specify one, all known engines are tried in alphabetical
order until one works.
The value of C<PDL_SIMPLE_ENGINE> should be the "shortname" of the
engine, currently:
=over
=item C<gnuplot>
=item C<plplot>
=item C<pgplot>
=item C<prima>
=back
=over 3
=item * Load module and create line plots
Expand Down Expand Up @@ -364,9 +379,9 @@ If specified, this must be one of the supported plotting engines. You
can use a module name or the shortened name. If you don't give one,
the constructor will try the last one you used, or else scan through
existing modules and pick one that seems to work. It will first check
the environment variable PDL_SIMPLE_ENGINE, then search through all
the known engines in alphabetical order until it finds one that seems
to work on your system.
the environment variable C<PDL_SIMPLE_ENGINE>, and as of 1.011, only that will be tried, but
if you didn't specify one, all known engines are tried in alphabetical
order until one works.
=item size
Expand Down Expand Up @@ -430,37 +445,36 @@ sub new {
##############################
# Pick out a working plot engine...

unless($opt->{engine}) {
unless ($opt->{engine}) {
# find the first working subclass...
unless($last_successful_type) {
unless ($last_successful_type) {

my @try = ();

if($ENV{'PDL_SIMPLE_ENGINE'}) {
if ($ENV{'PDL_SIMPLE_ENGINE'}) {
push(@try, $ENV{'PDL_SIMPLE_ENGINE'});
} else {
push(@try, sort keys %$mods);
}

push(@try, sort keys %$mods);

attempt: for my $engine( @try ) {
print "Trying $engine ($mods->{$engine}->{engine})...";
my $s;
my $a = eval { $mods->{$engine}{module}->can('check')->() };
if($@) {
if ($@) {
chomp $@;
$s = "$@";
} else {
$s = ($a ? "ok" : "nope");
}
print $s."\n";
if($a) {
if ($a) {
$last_successful_type = $engine;
last attempt;
}
}
unless( $last_successful_type ) {
barf "Sorry, all known plotting engines failed. Install one and try again.\n";
}
unless ( $last_successful_type ) {
barf "Sorry, all known plotting engines failed. Install one and try again.\n";
}
}
$opt->{engine} = $last_successful_type;
}
Expand Down
2 changes: 1 addition & 1 deletion t/simple.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use File::Temp q/tempfile/;
use PDL;

my $tests_per_engine = 17;
my @engines = qw/plplot gnuplot pgplot prima/;
my @engines = $ENV{PDL_SIMPLE_ENGINE} || qw/plplot gnuplot pgplot prima/;
my $smoker = ($ENV{'PERL_MM_USE_DEFAULT'} or $ENV{'AUTOMATED_TESTING'});
$ENV{PGPLOT_DEV} ||= '/NULL' if $smoker;

Expand Down

0 comments on commit 75f1a1b

Please sign in to comment.