Skip to content

Commit

Permalink
Add use strict, use warnings to modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
pstaabp committed Aug 13, 2024
1 parent 0dfc328 commit 5c47cce
Show file tree
Hide file tree
Showing 28 changed files with 183 additions and 162 deletions.
4 changes: 2 additions & 2 deletions lib/Fun.pm
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ my $FUNCTION_REFERENCE = "Fun";

my %fields = (
tstart => -1, # (tstart,$tstop) constitutes the domain
tstop => 1,
steps => 50,
tstop => 1,
steps => 50,
color => 'blue',
x_rule => \&identity,
y_rule => \&identity,
Expand Down
2 changes: 1 addition & 1 deletion lib/Hermite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ sub internal_critical_points {
}

sub internal_inflection_points {
my ($x0, $l, $lp,, $x1, $r, $rp, $rh_roots, $rf_function) = @_;
my ($x0, $l, $lp, $x1, $r, $rp, $rh_roots, $rf_function) = @_;
#data for one segment of the hermite spline

# coefficients for the approximating polynomial
Expand Down
3 changes: 3 additions & 0 deletions lib/Label.pm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ This module defines labels for the graph objects (WWPlot).
package Label;

use strict;
use warnings;

use GD;

#use Exporter;
#use DynaLoader;
Expand Down
9 changes: 6 additions & 3 deletions lib/Plots/Axes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ be visible after the fill, otherwise the fill will cover the axis. Default: 0

package Plots::Axes;

use strict;
use warnings;

sub new {
my $class = shift;
my $self = {
Expand All @@ -214,9 +217,9 @@ sub new {
sub axis_defaults {
my ($self, $axis) = @_;
return (
visible => 1,
visible => 1,
min => -5,
max => 5,
max => 5,
label => $axis eq 'y' ? '\(y\)' : '\(x\)',
location => $axis eq 'y' ? 'center' : 'middle',
position => 0,
Expand Down Expand Up @@ -329,4 +332,4 @@ sub bounds {
return $self->{xaxis}{min}, $self->{yaxis}{min}, $self->{xaxis}{max}, $self->{yaxis}{max};
}

1;
1;
5 changes: 4 additions & 1 deletion lib/Plots/Data.pm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ to add / change the styles.

package Plots::Data;

use strict;
use warnings;

sub new {
my $class = shift;
my $self = {
Expand Down Expand Up @@ -168,7 +171,7 @@ sub set_function {
sub_x => sub { return $_[0]; },
sub_y => sub { return $_[0]; },
min => -5,
max => 5,
max => 5,
@_
};
$self->style(steps => $self->{function}{steps}) if $self->{funciton}{steps};
Expand Down
7 changes: 6 additions & 1 deletion lib/Plots/GD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ See L<plots.pl> for more details.

package Plots::GD;

use GD;

use strict;
use warnings;

sub new {
my ($class, $pgplot) = @_;
my $self = {
Expand Down Expand Up @@ -382,4 +387,4 @@ sub draw {
return $pgplot->ext eq 'gif' ? $self->im->gif : $self->im->png;
}

1;
1;
13 changes: 8 additions & 5 deletions lib/Plots/Plot.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,20 @@ See L<plots.pl> for more details.

package Plots::Plot;

use strict;
use warnings;

use Plots::Axes;
use Plots::Data;
use Plots::GD;
use Plots::Tikz;
use Plots::GD;

sub new {
my ($class, $pg, @opts) = @_;
my $size = $main::envir{onTheFlyImageSize} || 500;
my $size = $pg->{envir}{onTheFlyImageSize} || 500;

my $self = {
pg => $pg,
pg => $pg,
imageName => {},
type => 'Tikz',
ext => 'svg',
Expand Down Expand Up @@ -158,15 +161,15 @@ sub image_type {
# Tikz needs to use pdf for hardcopy generation.
sub ext {
my $self = shift;
return 'pdf' if ($self->{type} eq 'Tikz' && $main::displayMode eq 'TeX');
return 'pdf' if ($self->{type} eq 'Tikz' && $self->{pg}{displayMode} eq 'TeX');
return $self->{ext};
}

# Return a copy of the tikz code (available after the image has been drawn).
# Set $plot->{tikzDebug} to 1 to just generate the tikzCode, and not create a graph.
sub tikz_code {
my $self = shift;
return ($self->{tikzCode} && $main::displayMode =~ /HTML/) ? '<pre>' . $self->{tikzCode} . '</pre>' : '';
return ($self->{tikzCode} && $self->{pg}{displayMode} =~ /HTML/) ? '<pre>' . $self->{tikzCode} . '</pre>' : '';
}

# Add functions to the graph.
Expand Down
4 changes: 3 additions & 1 deletion lib/Plots/Tikz.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ See L<plots.pl> for more details.
=cut


package Plots::Tikz;

use strict;
use warnings;

sub new {
my ($class, $pgplot) = @_;
my $image = new LaTeXImage;
Expand Down
6 changes: 3 additions & 3 deletions lib/Regression.pm
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ if (DEBUGGING) {

my $reg = Statistics::Regression->new(3, "sample regression", [ "const", "someX", "someY" ]);
$reg->include(2.0, [ 1.0, 3.0, -1.0 ]);
$reg->include(1.0, [ 1.0, 5.0, 2.0 ]);
$reg->include(20.0, [ 1.0, 31.0, 0.0 ]);
$reg->include(15.0, [ 1.0, 11.0, 2.0 ]);
$reg->include(1.0, [ 1.0, 5.0, 2.0 ]);
$reg->include(20.0, [ 1.0, 31.0, 0.0 ]);
$reg->include(15.0, [ 1.0, 11.0, 2.0 ]);

# $reg->print(); or: my $coefs= $reg->theta(); print @coefs; print $reg->rsq;
# my $coefs= $reg->theta(); print $coeff[0];
Expand Down
Loading

0 comments on commit 5c47cce

Please sign in to comment.