Skip to content

Commit 9a8a90c

Browse files
committed
some cleanup form PR #1217 and update test suite
1 parent c9a6152 commit 9a8a90c

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

lib/Value/Matrix.pm

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,7 @@ Usage:
855855
=cut
856856

857857
sub slice {
858-
my $self = shift;
859-
my ($index, $value) = @_;
858+
my ($self, $index, $value) = @_;
860859
my @d = $self->dimensions;
861860
my $d = scalar(@d);
862861
my $w = $d[0];
@@ -866,7 +865,6 @@ sub slice {
866865
Value::Error("value must be an integer from 1 to $w")
867866
unless ($value == int($value) && $value >= 1 && $value <= $w);
868867
return $M->[ $value - 1 ];
869-
return $self->make($M->[ $value - 1 ]);
870868
} else {
871869
my @rows;
872870
for (1 .. $w) {
@@ -921,7 +919,7 @@ sub transpose {
921919
for my $i (0 .. $#{$cycle} - 1) {
922920
$p[ $cycle->[$i] - 1 ] = $p[ $cycle->[ $i + 1 ] - 1 ];
923921
}
924-
$p[ $cycle->[ $#{$cycle} ] - 1 ] = $tmp;
922+
$p[ $cycle->[-1] - 1 ] = $tmp;
925923
}
926924
%p = map { $_ => $p[ $_ - 1 ] } (1 .. $N);
927925
}

t/math_objects/matrix.t

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ subtest 'Transpose' => sub {
108108
is $row->transpose->TeX, $row_trans->TeX, 'Transpose of a Matrix with one row.';
109109

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

116115
subtest 'Extract an element' => sub {

0 commit comments

Comments
 (0)