Sha256: 3a71b022b98a5ae7cbf6b1b53f2893f76a0b277d5f248485d92994d416e25f42

Contents?: true

Size: 1.52 KB

Versions: 5

Compression:

Stored size: 1.52 KB

Contents

require 'spec_helper'

describe Danica::Function::Gauss do
  let(:variables) do
    {
      x: :x,
      average: :u,
      variance_root: { latex: '\theta', gnu: :v }
    }
  end

  subject { described_class::Gauss.new(variables) }
  it_behaves_like 'an object that respond to basic_methods'

  describe '#to_tex' do
    context 'when creating the spatial operator for constantly accelerated movement' do
      let(:expected) { '\frac{1}{\theta \cdot \sqrt{2 \cdot \pi}} \cdot e^{-\frac{\left(x -u\right)^{2}}{2 \cdot \theta^{2}}}'  }

      it 'return the latex format CAM' do
        expect(subject.to_tex).to eq(expected)
      end
    end
  end

  describe '#to_gnu' do
    context 'when creating the spatial operator for constantly accelerated movement' do
      let(:expected) { '(1)/(v * sqrt(2 * pi)) * exp(-((x -u)**(2))/(2 * v**(2)))' }

      it 'return the gnu format CAM' do
        expect(subject.to_gnu).to eq(expected)
      end
    end
  end

  context 'when not passing variables' do
    subject { described_class::Gauss.new }

    describe '#to_tex' do
      let(:expected) { '\frac{1}{\sigma \cdot \sqrt{2 \cdot \pi}} \cdot e^{-\frac{\left(x -\mu\right)^{2}}{2 \cdot \sigma^{2}}}'  }

      it 'rely on default variables definition' do
        expect(subject.to_tex).to eq(expected)
      end
    end

    describe '#to_gnu' do
      let(:expected) { '(1)/(v * sqrt(2 * pi)) * exp(-((x -u)**(2))/(2 * v**(2)))' }

      it 'rely on default variables definition' do
        expect(subject.to_gnu).to eq(expected)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
danica-2.4.4 spec/lib/danica/function/gauss_spec.rb
danica-2.4.3 spec/lib/danica/function/gauss_spec.rb
danica-2.4.2 spec/lib/danica/function/gauss_spec.rb
danica-2.4.1 spec/lib/danica/function/gauss_spec.rb
danica-2.4.0 spec/lib/danica/function/gauss_spec.rb