mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/matrix.rb: Fix error message, patch by pypypy [Bug #7777]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d22ce4a522
commit
9a912c66d4
2 changed files with 10 additions and 6 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Tue Feb 5 14:43:15 2013 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
|
|
||||||
|
* lib/matrix.rb: Fix error message, patch by pypypy [Bug #7777]
|
||||||
|
|
||||||
Tue Feb 5 14:36:04 2013 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
Tue Feb 5 14:36:04 2013 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
|
|
||||||
* numeric.c (fix_pow): Handle special cases when base is 0, -1 or +1
|
* numeric.c (fix_pow): Handle special cases when base is 0, -1 or +1
|
||||||
|
|
|
@ -156,7 +156,7 @@ class Matrix
|
||||||
end
|
end
|
||||||
size = (rows[0] || []).size
|
size = (rows[0] || []).size
|
||||||
rows.each do |row|
|
rows.each do |row|
|
||||||
Matrix.Raise ErrDimensionMismatch, "row size differs (#{row.size} should be #{size})" unless row.size == size
|
raise ErrDimensionMismatch, "row size differs (#{row.size} should be #{size})" unless row.size == size
|
||||||
end
|
end
|
||||||
new rows, size
|
new rows, size
|
||||||
end
|
end
|
||||||
|
@ -286,8 +286,8 @@ class Matrix
|
||||||
# => Matrix[[0, 0, 0], [0, 0, 0]]
|
# => Matrix[[0, 0, 0], [0, 0, 0]]
|
||||||
#
|
#
|
||||||
def Matrix.empty(row_count = 0, column_count = 0)
|
def Matrix.empty(row_count = 0, column_count = 0)
|
||||||
Matrix.Raise ArgumentError, "One size must be 0" if column_count != 0 && row_count != 0
|
raise ArgumentError, "One size must be 0" if column_count != 0 && row_count != 0
|
||||||
Matrix.Raise ArgumentError, "Negative size" if column_count < 0 || row_count < 0
|
raise ArgumentError, "Negative size" if column_count < 0 || row_count < 0
|
||||||
|
|
||||||
new([[]]*row_count, column_count)
|
new([[]]*row_count, column_count)
|
||||||
end
|
end
|
||||||
|
@ -446,7 +446,7 @@ class Matrix
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Matrix.Raise ArgumentError, "expected #{which.inspect} to be one of :all, :diagonal, :off_diagonal, :lower, :strict_lower, :strict_upper or :upper"
|
raise ArgumentError, "expected #{which.inspect} to be one of :all, :diagonal, :off_diagonal, :lower, :strict_lower, :strict_upper or :upper"
|
||||||
end
|
end
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
@ -508,7 +508,7 @@ class Matrix
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Matrix.Raise ArgumentError, "expected #{which.inspect} to be one of :all, :diagonal, :off_diagonal, :lower, :strict_lower, :strict_upper or :upper"
|
raise ArgumentError, "expected #{which.inspect} to be one of :all, :diagonal, :off_diagonal, :lower, :strict_lower, :strict_upper or :upper"
|
||||||
end
|
end
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
@ -579,7 +579,7 @@ class Matrix
|
||||||
from_row += row_count if from_row < 0
|
from_row += row_count if from_row < 0
|
||||||
from_col += column_count if from_col < 0
|
from_col += column_count if from_col < 0
|
||||||
else
|
else
|
||||||
Matrix.Raise ArgumentError, param.inspect
|
raise ArgumentError, param.inspect
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil if from_row > row_count || from_col > column_count || from_row < 0 || from_col < 0
|
return nil if from_row > row_count || from_col > column_count || from_row < 0 || from_col < 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue