mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/matrix.rb: Deprecate Vector#elements_to{i/f/r}
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3f64c83eb1
commit
521f4a4beb
3 changed files with 6 additions and 27 deletions
|
@ -1465,15 +1465,18 @@ class Vector
|
|||
end
|
||||
|
||||
def elements_to_f
|
||||
collect{|e| e.to_f}
|
||||
warn "#{caller(1)[0]}: warning: Vector#elements_to_f is deprecated"
|
||||
map(&:to_f)
|
||||
end
|
||||
|
||||
def elements_to_i
|
||||
collect{|e| e.to_i}
|
||||
warn "#{caller(1)[0]}: warning: Vector#elements_to_i is deprecated"
|
||||
map(&:to_i)
|
||||
end
|
||||
|
||||
def elements_to_r
|
||||
collect{|e| e.to_r}
|
||||
warn "#{caller(1)[0]}: warning: Vector#elements_to_r is deprecated"
|
||||
map(&:to_r)
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -366,18 +366,6 @@ class TestMatrix < Test::Unit::TestCase
|
|||
assert_equal([Vector[1,4], Vector[2,5], Vector[3,6]], @m1.column_vectors)
|
||||
end
|
||||
|
||||
def test_elements_to_f
|
||||
assert_equal(Matrix[[0.5,1.0,1.5],[2.0,2.5,3.0]], @m1.elements_to_f / 2)
|
||||
end
|
||||
|
||||
def test_elements_to_i
|
||||
assert_equal(Matrix[[0,1,1],[2,2,3]], (@m1.elements_to_f / 2).elements_to_i)
|
||||
end
|
||||
|
||||
def test_elements_to_r
|
||||
assert_equal(@m1.collect {|x| Rational(x, 2) }, @m1.elements_to_r / 2)
|
||||
end
|
||||
|
||||
def test_to_s
|
||||
assert_equal("Matrix[[1, 2, 3], [4, 5, 6]]", @m1.to_s)
|
||||
assert_equal("Matrix.empty(0, 0)", Matrix[].to_s)
|
||||
|
|
|
@ -123,18 +123,6 @@ class TestVector < Test::Unit::TestCase
|
|||
assert_equal(Matrix[[1,2,3]], @v1.covector)
|
||||
end
|
||||
|
||||
def test_elements_to_f
|
||||
assert_equal(Vector[0.5,1.0,1.5], @v1.elements_to_f * Rational(1, 2))
|
||||
end
|
||||
|
||||
def test_elements_to_i
|
||||
assert_equal(Vector[0,1,1], (@v1.elements_to_f * Rational(1, 2)).elements_to_i)
|
||||
end
|
||||
|
||||
def test_elements_to_r
|
||||
assert_equal(@v1.collect {|x| Rational(x, 2) }, @v1.elements_to_r * Rational(1, 2))
|
||||
end
|
||||
|
||||
def test_to_s
|
||||
assert_equal("Vector[1, 2, 3]", @v1.to_s)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue