summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-11-29 16:35:51 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2019-11-30 08:00:40 +0900
commit9b950310be874753935a6ef4e8f94b3686f70540 (patch)
tree05d8fb997cb584fd03af3b821d2960b64cbb5d19
parentf47f2076fed1546d993a376ce3c35ca81b1f0c6a (diff)
raise method accepts 3 argument with exception class
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2699
-rw-r--r--lib/matrix.rb18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 0f4e1b2cf4..5084de2f1a 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -28,14 +28,14 @@ module ExceptionForMatrix # :nodoc:
end
class ErrOperationNotDefined < StandardError
- def initialize(op, sc, oc)
- super("Operation(#{op}) can\\'t be defined: #{sc} op #{oc}")
+ def initialize(vals)
+ super("Operation(#{vals[0]}) can\\'t be defined: #{vals[1]} op #{vals[2]}")
end
end
class ErrOperationNotImplemented < StandardError
- def initialize(op, sc, oc)
- super("Sorry, Operation(#{op}) not implemented: #{sc} op #{oc}")
+ def initialize(vals)
+ super("Sorry, Operation(#{vals[0]}) not implemented: #{vals[1]} op #{vals[2]}")
end
end
end
@@ -1066,7 +1066,7 @@ class Matrix
def +(m)
case m
when Numeric
- raise ErrOperationNotDefined, "+", self.class, m.class
+ raise ErrOperationNotDefined, ["+", self.class, m.class]
when Vector
m = self.class.column_vector(m)
when Matrix
@@ -1093,7 +1093,7 @@ class Matrix
def -(m)
case m
when Numeric
- raise ErrOperationNotDefined, "-", self.class, m.class
+ raise ErrOperationNotDefined, ["-", self.class, m.class]
when Vector
m = self.class.column_vector(m)
when Matrix
@@ -1226,7 +1226,7 @@ class Matrix
v, d, v_inv = eigensystem
v * self.class.diagonal(*d.each(:diagonal).map{|e| e ** other}) * v_inv
else
- raise ErrOperationNotDefined, "**", self.class, other.class
+ raise ErrOperationNotDefined, ["**", self.class, other.class]
end
end
@@ -2129,7 +2129,7 @@ class Vector
when Matrix
Matrix.column_vector(self) * x
when Vector
- raise ErrOperationNotDefined, "*", self.class, x.class
+ raise ErrOperationNotDefined, ["*", self.class, x.class]
else
apply_through_coercion(x, __method__)
end
@@ -2180,7 +2180,7 @@ class Vector
els = @elements.collect{|e| e / x}
self.class.elements(els, false)
when Matrix, Vector
- raise ErrOperationNotDefined, "/", self.class, x.class
+ raise ErrOperationNotDefined, ["/", self.class, x.class]
else
apply_through_coercion(x, __method__)
end