danica 2.6.2 → 2.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -0
- data/docker-compose.yml +1 -1
- data/lib/danica/function.rb +6 -0
- data/lib/danica/version.rb +1 -1
- data/spec/integration/readme/constant_spec.rb +22 -0
- data/spec/integration/readme/function_spec.rb +8 -0
- data/spec/lib/danica/expression_spec.rb +2 -2
- data/spec/lib/danica/function_spec.rb +32 -2
- data/spec/support/models/expression/{hyperbole.rb → parabole.rb} +2 -2
- data/spec/support/models/expression/quadratic_sum.rb +6 -0
- data/spec/support/models/function/parabole.rb +16 -0
- data/spec/support/models/function/quadratic_sum.rb +8 -0
- metadata +13 -7
- data/spec/support/models/function/hyperbole.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf05d8589ce6ce95ce844f0ac85322cbdf21cf17
|
4
|
+
data.tar.gz: 270bbcd3b2bf5f1f134706a2af56d1f326bc7cd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a09f2532b3dbe9b2265051781daec18e84a861d32c86a29b45c098717e12e2da39f6697e95f7c37c2025f73bccce707e7c290af0e57f889174ab8a283839da0
|
7
|
+
data.tar.gz: d37d4442d434cba7f5179c2688b05aecb8dafb4bf1f6fabbc1279896b5c7a2fbb3b15364b70397ffa31eb21ae306b8f526f3fbba1d91bf5936cc3a635082b3b7
|
data/README.md
CHANGED
@@ -341,6 +341,31 @@ returns
|
|
341
341
|
```gnuplot
|
342
342
|
x**(2) -y**(2)
|
343
343
|
```
|
344
|
+
|
345
|
+
#### Danica::Function.for
|
346
|
+
A function can also created after an expression
|
347
|
+
|
348
|
+
```ruby
|
349
|
+
module Danica
|
350
|
+
class Expression
|
351
|
+
class QuadraticSum < build(:x, :y) { (x + y) ** 2 }
|
352
|
+
end
|
353
|
+
end
|
354
|
+
class Function
|
355
|
+
class QuadraticSum < Function.for(Expression::QuadraticSum)
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
fx = Danica::Function::QuadraticSum.new
|
361
|
+
|
362
|
+
fx.to_tex
|
363
|
+
```
|
364
|
+
|
365
|
+
```tex
|
366
|
+
f(x, y) = \left(x + y\right)^{2}
|
367
|
+
```
|
368
|
+
|
344
369
|
### DSL and building
|
345
370
|
An expression can be created using the DSL direct from ```Danica```
|
346
371
|
|
data/docker-compose.yml
CHANGED
data/lib/danica/function.rb
CHANGED
data/lib/danica/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Danica::Wrapper::Constant do
|
4
|
+
subject do
|
5
|
+
Danica::Wrapper::Constant.new(gnu: 'pi', latex: '\pi', value: 3.141592)
|
6
|
+
end
|
7
|
+
let(:output) do
|
8
|
+
{
|
9
|
+
tex: '\pi',
|
10
|
+
gnu: 'pi',
|
11
|
+
f: 3.141592
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'outputs' do
|
16
|
+
it do
|
17
|
+
output.each do |format, expected|
|
18
|
+
expect(subject.to(format)).to eq(expected)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -72,3 +72,11 @@ describe Danica::Function::MyFunction do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
describe Danica::Function::QuadraticSum do
|
77
|
+
describe '#to_tex' do
|
78
|
+
it 'creates a funcion out of an expression' do
|
79
|
+
expect(subject.to_tex).to eq("f(x, y) = \\left(x + y\\right)^{2}")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -52,7 +52,7 @@ describe Danica::Expression do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
context 'when creating a class using build' do
|
55
|
-
let(:expression_class) { Danica::
|
55
|
+
let(:expression_class) { Danica::Parabole }
|
56
56
|
|
57
57
|
it_behaves_like 'an object with basic operation'
|
58
58
|
it_behaves_like 'an object that respond to basic_methods'
|
@@ -78,7 +78,7 @@ describe Danica::Expression do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
context 'when using a class that inherits from another class' do
|
81
|
-
let(:expression_class) { Danica::
|
81
|
+
let(:expression_class) { Danica::SaddleParabole }
|
82
82
|
|
83
83
|
it_behaves_like 'an object with basic operation'
|
84
84
|
it_behaves_like 'an object that respond to basic_methods'
|
@@ -34,6 +34,36 @@ describe Danica::Function do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
describe '.for' do
|
38
|
+
let(:expression_class) { Danica::Expression::Gauss }
|
39
|
+
let(:expression) { expression_class.new }
|
40
|
+
subject do
|
41
|
+
described_class.for(expression_class).new
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'returns a function' do
|
45
|
+
expect(subject).to be_a(described_class)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'behaves like a function' do
|
49
|
+
expect do
|
50
|
+
subject.to_tex
|
51
|
+
end.not_to raise_error
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'creates a funcion out of an expression' do
|
55
|
+
expect(subject.to_tex).to eq("f(x, \\mu, \\sigma) = #{expression.to_tex}")
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when passing an operator' do
|
59
|
+
let(:expression_class) { Danica::Operator::Cos }
|
60
|
+
|
61
|
+
it do
|
62
|
+
expect(subject.to_tex).to eq("f(value) = #{expression.to_tex}")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
37
67
|
describe '.build' do
|
38
68
|
let(:function) do
|
39
69
|
function_class.new(name: :f)
|
@@ -52,7 +82,7 @@ describe Danica::Function do
|
|
52
82
|
end
|
53
83
|
|
54
84
|
context 'when creating a class using build' do
|
55
|
-
let(:function_class) { Danica::Function::
|
85
|
+
let(:function_class) { Danica::Function::Parabole }
|
56
86
|
|
57
87
|
it 'has the defined variables on class definition' do
|
58
88
|
expect(function_class.variables_names).to eq([:x])
|
@@ -76,7 +106,7 @@ describe Danica::Function do
|
|
76
106
|
end
|
77
107
|
|
78
108
|
context 'when using a class that inherits from another class' do
|
79
|
-
let(:function_class) { Danica::Function::
|
109
|
+
let(:function_class) { Danica::Function::SaddleParabole }
|
80
110
|
|
81
111
|
it 'has the defined variables on class definition' do
|
82
112
|
expect(function_class.variables_names).to eq([:x, :y])
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Danica
|
2
|
-
class
|
2
|
+
class Parabole < Expression.build(:x) { power(x, 2) }
|
3
3
|
end
|
4
4
|
end
|
5
5
|
|
6
6
|
module Danica
|
7
|
-
class
|
7
|
+
class SaddleParabole < Parabole
|
8
8
|
variables :y
|
9
9
|
|
10
10
|
def expression_block
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
module Danica
|
3
|
+
class Function::Parabole < Function.build(:x) { Danica::Parabole.new }
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module Danica
|
8
|
+
class Function::SaddleParabole < Function::Parabole
|
9
|
+
variables :y
|
10
|
+
|
11
|
+
def function_block
|
12
|
+
super - power(y, 2)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darthjee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- spec/integration/negative_spec.rb
|
182
182
|
- spec/integration/plus_minus_spec.rb
|
183
183
|
- spec/integration/power_spec.rb
|
184
|
+
- spec/integration/readme/constant_spec.rb
|
184
185
|
- spec/integration/readme/danica_spec.rb
|
185
186
|
- spec/integration/readme/equation_spec.rb
|
186
187
|
- spec/integration/readme/expression_spec.rb
|
@@ -217,10 +218,12 @@ files:
|
|
217
218
|
- spec/lib/danica_spec.rb
|
218
219
|
- spec/spec_helper.rb
|
219
220
|
- spec/support/models/expression/baskara.rb
|
220
|
-
- spec/support/models/expression/
|
221
|
+
- spec/support/models/expression/parabole.rb
|
222
|
+
- spec/support/models/expression/quadratic_sum.rb
|
221
223
|
- spec/support/models/expression/spatial.rb
|
222
|
-
- spec/support/models/function/hyperbole.rb
|
223
224
|
- spec/support/models/function/my_function.rb
|
225
|
+
- spec/support/models/function/parabole.rb
|
226
|
+
- spec/support/models/function/quadratic_sum.rb
|
224
227
|
- spec/support/models/function/spatial.rb
|
225
228
|
- spec/support/models/operator/inverse.rb
|
226
229
|
- spec/support/models/operator/my_operator.rb
|
@@ -251,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
251
254
|
version: '0'
|
252
255
|
requirements: []
|
253
256
|
rubyforge_project:
|
254
|
-
rubygems_version: 2.6.
|
257
|
+
rubygems_version: 2.6.11
|
255
258
|
signing_key:
|
256
259
|
specification_version: 4
|
257
260
|
summary: Danica
|
@@ -261,6 +264,7 @@ test_files:
|
|
261
264
|
- spec/integration/negative_spec.rb
|
262
265
|
- spec/integration/plus_minus_spec.rb
|
263
266
|
- spec/integration/power_spec.rb
|
267
|
+
- spec/integration/readme/constant_spec.rb
|
264
268
|
- spec/integration/readme/danica_spec.rb
|
265
269
|
- spec/integration/readme/equation_spec.rb
|
266
270
|
- spec/integration/readme/expression_spec.rb
|
@@ -297,10 +301,12 @@ test_files:
|
|
297
301
|
- spec/lib/danica_spec.rb
|
298
302
|
- spec/spec_helper.rb
|
299
303
|
- spec/support/models/expression/baskara.rb
|
300
|
-
- spec/support/models/expression/
|
304
|
+
- spec/support/models/expression/parabole.rb
|
305
|
+
- spec/support/models/expression/quadratic_sum.rb
|
301
306
|
- spec/support/models/expression/spatial.rb
|
302
|
-
- spec/support/models/function/hyperbole.rb
|
303
307
|
- spec/support/models/function/my_function.rb
|
308
|
+
- spec/support/models/function/parabole.rb
|
309
|
+
- spec/support/models/function/quadratic_sum.rb
|
304
310
|
- spec/support/models/function/spatial.rb
|
305
311
|
- spec/support/models/operator/inverse.rb
|
306
312
|
- spec/support/models/operator/my_operator.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
|
2
|
-
module Danica
|
3
|
-
class Function::Hyperbole < Function.build(:x) { Danica::Hyperbole.new }
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
module Danica
|
8
|
-
class Function::SaddleHyperbole < Function::Hyperbole
|
9
|
-
variables :y
|
10
|
-
|
11
|
-
def function_block
|
12
|
-
super - power(y, 2)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|