Skip to content

Commit f019cd7

Browse files
committed
some cleanup form PR openwebwork#1217 and update test suite
1 parent 2b3a3df commit f019cd7

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

lib/Value/Matrix.pm

+2-4
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,7 @@ Usage:
856856
=cut
857857

858858
sub slice {
859-
my $self = shift;
860-
my ($index, $value) = @_;
859+
my ($self, $index, $value) = @_;
861860
my @d = $self->dimensions;
862861
my $d = scalar(@d);
863862
my $w = $d[0];
@@ -867,7 +866,6 @@ sub slice {
867866
Value::Error("value must be an integer from 1 to $w")
868867
unless ($value == int($value) && $value >= 1 && $value <= $w);
869868
return $M->[ $value - 1 ];
870-
return $self->make($M->[ $value - 1 ]);
871869
} else {
872870
my @rows;
873871
for (1 .. $w) {
@@ -922,7 +920,7 @@ sub transpose {
922920
for my $i (0 .. $#{$cycle} - 1) {
923921
$p[ $cycle->[$i] - 1 ] = $p[ $cycle->[ $i + 1 ] - 1 ];
924922
}
925-
$p[ $cycle->[ $#{$cycle} ] - 1 ] = $tmp;
923+
$p[ $cycle->[-1] - 1 ] = $tmp;
926924
}
927925
%p = map { $_ => $p[ $_ - 1 ] } (1 .. $N);
928926
}

t/math_objects/matrix.t

+2-3
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,8 @@ subtest 'Transpose a Matrix' => sub {
193193
is $row->transpose->TeX, $row_trans->TeX, 'Transpose of a degree 1 Matrix.';
194194

195195
my $C = Matrix([ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 5, 6 ], [ 7, 8 ] ] ]);
196-
like dies {
197-
$C->transpose;
198-
}, qr/Can't transpose \d+-dimensional matrices/, "Can't tranpose a three-d matrix.";
196+
my $D = Matrix([ [ [ 1, 3 ], [ 2, 4 ] ], [ [ 5, 7 ], [ 6, 8 ] ] ]);
197+
is $C->transpose->TeX, $D->TeX, 'Test the tranpose of a degree 3 tensor.';
199198
};
200199

201200
subtest 'Extract an element' => sub {

0 commit comments

Comments
 (0)