Skip to content

Commit

Permalink
fix numeric-only strings for legend - fix #100
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Apr 13, 2024
1 parent 3adb944 commit 02c4b27
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
packaging. Fixes #98.
- fixes for Windows (#89)
- use terminal "dumb" if probing shows "unknown" (#66)
- fix numeric-only strings for legend (#100) - thanks @d-lamb for report

2.024 2023-03-30
- Add Alien::Gnuplot as a configure-time dependency. Fixes #92 - thanks @zmughal
Expand Down
2 changes: 1 addition & 1 deletion lib/PDL/Graphics/Gnuplot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5466,7 +5466,7 @@ $_pOHInputs = {
## one-line list (can also be boolean)
'l' => sub { return undef unless(defined $_[1]);
return "" unless(length($_[1])); # false value yields false
return $_[1] if( (!ref($_[1])) && "$_[1]" =~ m/^\s*\-?\d+\s*$/); # nonzero integers yield true
return [$_[1]] if( (!ref($_[1])) && "$_[1]" =~ m/^\s*\-?\d+\s*$/); # nonzero integers yield true
# Not setting a boolean value - it's a list (or a trivial list).
return $_[1] if ref $_[1] eq 'ARRAY';
# anything that's not an array ref (and not a number) gets put in the array
Expand Down
6 changes: 5 additions & 1 deletion t/plot.t
Original file line number Diff line number Diff line change
Expand Up @@ -825,11 +825,15 @@ $b = pdl(1,4,9,16,25)->sqrt; # 1,2,3,4,5

$w->plot(with=>'lines',$a,{binary=>1});
$w->close;

@lines = do { open my $fh, "<", $testoutput or die "$testoutput: $!"; <$fh> };
isnt $lines[12], '';
like substr($lines[12],20,40), qr/^\s+$/, "NaN makes a blank in a plot";

$w->restart;
eval {$w->plot(with=>'lines',legend=>'456',$b)};
is $@, '', "can use numeric-only strings for legend"; # GH#100
$w->close;

$w->restart;
$w->plot(with=>'lines',$b,{binary=>1});
$w->close;
Expand Down

0 comments on commit 02c4b27

Please sign in to comment.