Skip to content

Commit

Permalink
lambda-> proc, changing specs, adding backports
Browse files Browse the repository at this point in the history
  • Loading branch information
rajithv committed Jul 23, 2016
1 parent b45d182 commit 850a45d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion lib/symengine.rb
Expand Up @@ -57,7 +57,7 @@ def lambdify_code(exp, syms)
sym_map = syms.join(",")
str.gsub!(/[\d\.]+/, 'Rational(\0,1)')
str = REPLACEMENTS.inject(str) { |res, (from, to)| res.gsub(from, to)}
"lambda { | #{sym_map} | #{str} }"
"proc { | #{sym_map} | #{str} }"
end
end
end
Expand Down
40 changes: 20 additions & 20 deletions spec/lambdify_spec.rb
Expand Up @@ -9,26 +9,26 @@ def l(code)
end

it 'creates lambda codes' do
expect(SymEngine::Utils::lambdify_code( x + y + z, [x, y, z])).to eq("lambda { | x,y,z | x + y + z }")
expect(l( x + 5 )).to eq("lambda { | x | Rational(5,1) + x }")
expect(l( SymEngine::sin(x) )).to eq("lambda { | x | Math.sin(x) }")
expect(l( SymEngine::cos(x) )).to eq("lambda { | x | Math.cos(x) }")
expect(l( SymEngine::tan(x) )).to eq("lambda { | x | Math.tan(x) }")
expect(l( SymEngine::asin(x) )).to eq("lambda { | x | Math.asin(x) }")
expect(l( SymEngine::acos(x) )).to eq("lambda { | x | Math.acos(x) }")
expect(l( SymEngine::atan(x) )).to eq("lambda { | x | Math.atan(x) }")
expect(l( SymEngine::sinh(x) )).to eq("lambda { | x | Math.sinh(x) }")
expect(l( SymEngine::cosh(x) )).to eq("lambda { | x | Math.cosh(x) }")
expect(l( SymEngine::tanh(x) )).to eq("lambda { | x | Math.tanh(x) }")
expect(l( SymEngine::asinh(x) )).to eq("lambda { | x | Math.asinh(x) }")
expect(l( SymEngine::acosh(x) )).to eq("lambda { | x | Math.acosh(x) }")
expect(l( SymEngine::atanh(x) )).to eq("lambda { | x | Math.atanh(x) }")
expect(l( SymEngine::gamma(x) )).to eq("lambda { | x | Math.gamma(x) }")
expect(l( x + SymEngine::PI )).to eq("lambda { | x | x + Math::PI }")
expect(l( x + SymEngine::E )).to eq("lambda { | x | x + Math::E }")
expect(l( x * SymEngine::I )).to eq("lambda { | x | ::Complex::I*x }")
expect(l( SymEngine::dirichlet_eta(x) )).to eq("lambda { | x | SymEngine::Utils::evalf_dirichlet_eta(x) }")
expect(l( SymEngine::zeta(x) )).to eq("lambda { | x | SymEngine::Utils::evalf_zeta(x, Rational(1,1)) }")
expect(SymEngine::Utils::lambdify_code( x + y + z, [x, y, z])).to eq("proc { | x,y,z | x + y + z }")
expect(l( x + 5 )).to eq("proc { | x | Rational(5,1) + x }")
expect(l( SymEngine::sin(x) )).to eq("proc { | x | Math.sin(x) }")
expect(l( SymEngine::cos(x) )).to eq("proc { | x | Math.cos(x) }")
expect(l( SymEngine::tan(x) )).to eq("proc { | x | Math.tan(x) }")
expect(l( SymEngine::asin(x) )).to eq("proc { | x | Math.asin(x) }")
expect(l( SymEngine::acos(x) )).to eq("proc { | x | Math.acos(x) }")
expect(l( SymEngine::atan(x) )).to eq("proc { | x | Math.atan(x) }")
expect(l( SymEngine::sinh(x) )).to eq("proc { | x | Math.sinh(x) }")
expect(l( SymEngine::cosh(x) )).to eq("proc { | x | Math.cosh(x) }")
expect(l( SymEngine::tanh(x) )).to eq("proc { | x | Math.tanh(x) }")
expect(l( SymEngine::asinh(x) )).to eq("proc { | x | Math.asinh(x) }")
expect(l( SymEngine::acosh(x) )).to eq("proc { | x | Math.acosh(x) }")
expect(l( SymEngine::atanh(x) )).to eq("proc { | x | Math.atanh(x) }")
expect(l( SymEngine::gamma(x) )).to eq("proc { | x | Math.gamma(x) }")
expect(l( x + SymEngine::PI )).to eq("proc { | x | x + Math::PI }")
expect(l( x + SymEngine::E )).to eq("proc { | x | x + Math::E }")
expect(l( x * SymEngine::I )).to eq("proc { | x | ::Complex::I*x }")
expect(l( SymEngine::dirichlet_eta(x) )).to eq("proc { | x | SymEngine::Utils::evalf_dirichlet_eta(x) }")
expect(l( SymEngine::zeta(x) )).to eq("proc { | x | SymEngine::Utils::evalf_zeta(x, Rational(1,1)) }")


end
Expand Down
1 change: 1 addition & 0 deletions symengine.gemspec
Expand Up @@ -16,4 +16,5 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'rspec', '~> 3.0'
gem.add_development_dependency 'rspec-its'
gem.add_development_dependency 'rdoc', '~> 4.0'
gem.add_development_dependency 'backports'
end

0 comments on commit 850a45d

Please sign in to comment.