danica 2.6.3 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +34 -0
- data/lib/danica/function/name.rb +14 -1
- data/lib/danica/version.rb +1 -1
- data/spec/integration/readme/function_spec.rb +15 -0
- data/spec/lib/danica/function_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4318506811f5ad7390ad5fac3edff89aad449100
|
4
|
+
data.tar.gz: ea17a7c84ebc531cb69a834299c289d0c3bb61e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d53e9dfdb02e7c754d0095f95715961e4e2f1a806206453933660c96bdfbac2ae715b5177a2e8b88959a822c2e43b52f935fc961960839df828f6b24ecdf5cf7
|
7
|
+
data.tar.gz: 60b93a47b8d32246fd246d4ca05eb4bea775612986996bdb6f4df67da580a7abd8c9a6407965d544072ef0cef595ef02047dc89246508eb6f49c6cbd54e45935
|
data/README.md
CHANGED
@@ -265,6 +265,23 @@ returns
|
|
265
265
|
f(t, a, S_0, V_0) = S_0 + V_0 \cdot t + \frac{a \cdot t^{2}}{2}
|
266
266
|
```
|
267
267
|
|
268
|
+
functions ignore constants variables on the function definition (left side of the equation)
|
269
|
+
|
270
|
+
|
271
|
+
```ruby
|
272
|
+
class Func < Danica::Function.build(:x, :y, :z) { z*(x ** y) }
|
273
|
+
end
|
274
|
+
|
275
|
+
f = Func.new(y: 3, z: Danica::PI)
|
276
|
+
|
277
|
+
f.to_tex
|
278
|
+
```
|
279
|
+
|
280
|
+
returns
|
281
|
+
```tex
|
282
|
+
f(x, 3) = \pi \cdot x^{3}
|
283
|
+
```
|
284
|
+
|
268
285
|
##### to_gnu
|
269
286
|
```ruby
|
270
287
|
fx.to_gnu
|
@@ -275,6 +292,23 @@ returns
|
|
275
292
|
f(t, a, S0, V0) = S0 + V0 * t + (a * t**(2))/(2)
|
276
293
|
```
|
277
294
|
|
295
|
+
functions ignore constants AND numeric variables on the function
|
296
|
+
definition (left side of the equation)
|
297
|
+
|
298
|
+
```ruby
|
299
|
+
class Func < Danica::Function.build(:x, :y, :z) { z*(x ** y) }
|
300
|
+
end
|
301
|
+
|
302
|
+
f = Func.new(y: 3, z: Danica::PI)
|
303
|
+
|
304
|
+
f.to_gnu
|
305
|
+
```
|
306
|
+
|
307
|
+
returns
|
308
|
+
```tex
|
309
|
+
f(x) = pi * x**(3)
|
310
|
+
```
|
311
|
+
|
278
312
|
##### calculate / to_f
|
279
313
|
```ruby
|
280
314
|
fx = Danica::Function::Spatial.new(
|
data/lib/danica/function/name.rb
CHANGED
@@ -19,7 +19,20 @@ module Danica
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def description_variables(format)
|
22
|
-
|
22
|
+
variables_for(format).map { |v| v.to(format) }.join(', ')
|
23
|
+
end
|
24
|
+
|
25
|
+
def variables_for(format)
|
26
|
+
case format.to_sym
|
27
|
+
when :tex
|
28
|
+
non_constant_variables
|
29
|
+
when :gnu
|
30
|
+
non_valued_variables
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def non_valued_variables
|
35
|
+
variables.reject(&:valued?)
|
23
36
|
end
|
24
37
|
|
25
38
|
def non_constant_variables
|
data/lib/danica/version.rb
CHANGED
@@ -80,3 +80,18 @@ describe Danica::Function::QuadraticSum do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
describe Danica::Function do
|
85
|
+
subject { described_class.build(:x, :y, :z) { z*(x ** y) }.new(y: 3, z: Danica::PI) }
|
86
|
+
describe '#to_tex' do
|
87
|
+
it do
|
88
|
+
expect(subject.to_tex).to eq('f(x, 3) = \pi \cdot x^{3}')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#to_gnu' do
|
93
|
+
it do
|
94
|
+
expect(subject.to_gnu).to eq('f(x) = pi * x**(3)')
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -258,8 +258,8 @@ describe Danica::Function do
|
|
258
258
|
function_class.new(name: :f, x: { name: :x, value: 2 })
|
259
259
|
end
|
260
260
|
|
261
|
-
it '
|
262
|
-
expect(function.to_gnu).to eq('f(
|
261
|
+
it 'hides the numver variable from name' do
|
262
|
+
expect(function.to_gnu).to eq('f(y) = 2**(y)')
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
@@ -268,8 +268,8 @@ describe Danica::Function do
|
|
268
268
|
function_class.new(name: :f, x: 2)
|
269
269
|
end
|
270
270
|
|
271
|
-
it '
|
272
|
-
expect(function.to_gnu).to eq('f(
|
271
|
+
it 'hides the numver variable from name' do
|
272
|
+
expect(function.to_gnu).to eq('f(y) = 2**(y)')
|
273
273
|
end
|
274
274
|
end
|
275
275
|
end
|