dydx 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 895af6b98a1440dd693b35dd9e697ee6838f3a23
4
- data.tar.gz: 5f987b396090e719f7aa22a524db87f34299b8af
3
+ metadata.gz: 05d9adcc67c3ad1cbaf217f11bf2d71a5926588a
4
+ data.tar.gz: bd230293d17b20bf98ab7b6af22d03a544454f15
5
5
  SHA512:
6
- metadata.gz: 88dbb76bf4c5927fee44379a563ace65744db1e39b9215a47f0f94cde888756ce34e203b30a60a02a47f8f2a4d66879c9d5a6d0987c3f4986b1e00cbcfd275e2
7
- data.tar.gz: 7e879f730952367fd530e3f356292f17c45913eba3aaab1b8989951924da4772b8c1173e78486ee0636045d75e5b9c50d914bfcb3731882ef4497d4e02fb83b6
6
+ metadata.gz: 96db75da9bb34f1dd34b4f7dc725d380031fd3092d93062e7d9289a41c35132612521ece1e3770ed0649f3c936ebd0daea965b13465a9c060f7b63258e7aa882
7
+ data.tar.gz: 47038bba5523d403d3f07153e22236e6f71d15846256d9f2db0772bf679834ac4c0b3ec9a16bd2b86f953ad268ee831e9fb9c6257529e4fe2b35046befafebd5
data/lib/dydx.rb CHANGED
@@ -13,12 +13,16 @@ module Dydx
13
13
  raise ArgumentError, "invalid number of values (#{vars.count} for #{function.vars.count})" unless function.vars.count == vars.count
14
14
  return function if function.vars == vars
15
15
  if function.algebra
16
- string = function.algebra.to_s
17
- .gsub('cos', 'Math.cos')
18
- .gsub('sin', 'Math.sin')
19
- .gsub('log', 'Math.log')
20
- .gsub('e', 'Math::E')
21
- .gsub('pi', 'Math::PI')
16
+ if vars.all?{|v| v.is_a?(Numeric)}
17
+ string = function.algebra.to_s
18
+ .gsub('cos', 'Math.cos')
19
+ .gsub('sin', 'Math.sin')
20
+ .gsub('log', 'Math.log')
21
+ .gsub('e', 'Math::E')
22
+ .gsub('pi', 'Math::PI')
23
+ else
24
+ string = function.algebra.to_s
25
+ end
22
26
  function.vars.each_with_index do |var, i|
23
27
  string.gsub!(var.to_s, vars[i].to_s)
24
28
  end
data/lib/dydx/helper.rb CHANGED
@@ -125,5 +125,9 @@ module Dydx
125
125
  [:+, :*].include?(self)
126
126
  end
127
127
  end
128
+
129
+ def ==(x)
130
+ to_s == x.to_s
131
+ end
128
132
  end
129
133
  end
data/lib/dydx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dydx
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -30,4 +30,10 @@ describe Dydx:Function do
30
30
  it{ expect(h(a, b, c) <= d/db(g(a, b))).to eq($h) }
31
31
  it{ expect(h(a, b, c)).to eq(( ( 2 * b ) + a )) }
32
32
  it{ expect(h(a, b, c).algebra).to eq(( ( 2 * b ) + a )) }
33
+
34
+ it 'ex.4' do
35
+ $f = nil
36
+ f(x) <= log(x)
37
+ expect(f(a)).to eq(log(a))
38
+ end
33
39
  end
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Dydx:Integrand do
4
4
  it 'ex1' do
5
+ $f = nil
5
6
  f(x, y) <= x * y
6
7
  integrand = S(f(x, y), dx)
7
8
  expect(integrand.function).to eq(f(x, y))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dydx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-25 00:00:00.000000000 Z
11
+ date: 2014-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler