Skip to content

Commit 3d27912

Browse files
committed
extract re_minmax into AxesBase
1 parent ea68f5b commit 3d27912

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

lib/PDL/Graphics/TriD/Graph.pm

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ sub normalise_scale { # Normalize the smallest differences away.
140140
$max->dice_axis(0, $got_smalldiff) .= $min->dice_axis(0, $got_smalldiff) + 1;
141141
($min, $max);
142142
}
143+
sub re_minmax {
144+
my ($this, $data) = @_;
145+
my $to_minmax = $data->clump(1..$data->ndims-1); # xyz,...
146+
$to_minmax = $to_minmax->glue(1, $this->{Bounds}); # include old min/max
147+
$to_minmax->transpose->minmaxover; # each min, max is xyz
148+
}
143149

144150
package # hide from PAUSE
145151
PDL::Graphics::TriD::EuclidAxes;
@@ -180,11 +186,7 @@ sub init_scale {
180186
sub add_scale {
181187
my ($this,$data,$inds) = @_;
182188
PDL::barf "no \$inds given" if !defined $inds;
183-
$data = $data->dice_axis(0, $inds);
184-
my $to_minmax = $data->clump(1..$data->ndims-1); # xyz,...
185-
$to_minmax = $to_minmax->glue(1, $this->{Bounds}); # include old min/max
186-
my ($mins, $maxes) = $to_minmax->transpose->minmaxover; # each is xyz
187-
$this->{Bounds} = PDL->pdl($mins, $maxes); # xyz,minmax
189+
$this->{Bounds} = PDL->pdl($this->re_minmax($data->dice_axis(0, $inds))); # xyz,minmax
188190
}
189191

190192
sub finish_scale {
@@ -249,10 +251,7 @@ sub init_scale {
249251
sub add_scale {
250252
my ($this,$data,$inds) = @_;
251253
barf "no \$inds given" if !defined $inds;
252-
$data = $data->dice_axis(0, $inds);
253-
my $to_minmax = $data->clump(1..$data->ndims-1); # xyz,...
254-
$to_minmax = $to_minmax->glue(1, $this->{Bounds}); # include old min/max
255-
my ($mins, $maxes) = $to_minmax->transpose->minmaxover; # each is xyz
254+
my ($mins, $maxes) = $this->re_minmax($data->dice_axis(0, $inds)); # each is xyz
256255
if ($maxes->slice(1) >= 90 or $mins->slice(1) <= -90) {
257256
barf "Error in Latitude ", $maxes->slice(1), " ", $mins->slice(1);
258257
}
@@ -336,10 +335,7 @@ sub init_scale {
336335
sub add_scale {
337336
my ($this,$data,$inds) = @_;
338337
barf "no \$inds given" if !defined $inds;
339-
$data = $data->dice_axis(0, $inds);
340-
my $to_minmax = $data->clump(1..$data->ndims-1); # xyz,...
341-
$to_minmax = $to_minmax->glue(1, $this->{Bounds}); # include old min/max
342-
my ($mins, $maxes) = $to_minmax->transpose->minmaxover; # each is xyz
338+
my ($mins, $maxes) = $this->re_minmax($data->dice_axis(0, $inds)); # each is xyz
343339
if ($maxes->slice(1) >= 90 or $mins->slice(1) <= -90) {
344340
barf "Error in Latitude ", $maxes->slice(1), " ", $mins->slice(1);
345341
}

0 commit comments

Comments
 (0)