Sha256: e8eb53c43a042255492f87ca01d5038ed1022ee3928d0005b4f868ba71b0b02a

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 KB

Contents

describe "Monkeys" do
  context Matrix do
    it "performs elementwise division" do
      left  = Matrix[[3,6,9],[4,8,12],[2,4,6]]
      right = Matrix[[3,6,9],[4,8,12],[2,4,6]]

      expect(left.elementwise_division(right)).to eq(Matrix[[1,1,1],[1,1,1],[1,1,1]])
    end
  end

  describe '#daru_vector' do
    it 'converts Array' do
      expect([1,2,3].daru_vector).to eq Daru::Vector.new [1,2,3]
      expect([1,2,3].daru_vector('test', [:a, :b, :c])).to eq \
        Daru::Vector.new [1,2,3], name: 'test', index: [:a, :b, :c]
    end

    it 'converts Range' do
      expect((1..3).daru_vector).to eq Daru::Vector.new [1,2,3]
      expect((1..3).daru_vector('test', [:a, :b, :c])).to eq \
        Daru::Vector.new [1,2,3], name: 'test', index: [:a, :b, :c]
    end

    it 'converts Hash' do
      # FIXME: is it most useful way of converting hashes?..
      # I'd prefer something like
      #   expect({a: 1, b: 2, c: 3}.daru_vector('test')).to eq Daru::Vector.new [1,2,3], name: 'test', index: [:a, :b, :c]
      #
      expect({test: [1, 2, 3]}.daru_vector).to eq Daru::Vector.new [1,2,3], name: :test
    end
  end

  describe '#to_index' do
    it 'converts Array' do
      expect([1,2,3].to_index).to eq Daru::Index.new [1,2,3]
    end

    it 'converts Range' do
      expect((1..3).to_index).to eq Daru::Index.new [1,2,3]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
daru-0.3 spec/monkeys_spec.rb
daru-0.2.2 spec/monkeys_spec.rb
daru-0.2.1 spec/monkeys_spec.rb
daru-0.2.0 spec/monkeys_spec.rb
daru-0.1.6 spec/monkeys_spec.rb
daru-0.1.5 spec/monkeys_spec.rb
daru-0.1.4.1 spec/monkeys_spec.rb
daru-0.1.4 spec/monkeys_spec.rb