danica 2.6.3 → 2.6.4

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: bf05d8589ce6ce95ce844f0ac85322cbdf21cf17
4
- data.tar.gz: 270bbcd3b2bf5f1f134706a2af56d1f326bc7cd3
3
+ metadata.gz: 4318506811f5ad7390ad5fac3edff89aad449100
4
+ data.tar.gz: ea17a7c84ebc531cb69a834299c289d0c3bb61e5
5
5
  SHA512:
6
- metadata.gz: 7a09f2532b3dbe9b2265051781daec18e84a861d32c86a29b45c098717e12e2da39f6697e95f7c37c2025f73bccce707e7c290af0e57f889174ab8a283839da0
7
- data.tar.gz: d37d4442d434cba7f5179c2688b05aecb8dafb4bf1f6fabbc1279896b5c7a2fbb3b15364b70397ffa31eb21ae306b8f526f3fbba1d91bf5936cc3a635082b3b7
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(
@@ -19,7 +19,20 @@ module Danica
19
19
  private
20
20
 
21
21
  def description_variables(format)
22
- non_constant_variables.map { |v| v.to(format) }.join(', ')
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
@@ -1,3 +1,3 @@
1
1
  module Danica
2
- VERSION = '2.6.3'
2
+ VERSION = '2.6.4'
3
3
  end
@@ -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 'sohws the variable as number' do
262
- expect(function.to_gnu).to eq('f(2, y) = 2**(y)')
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 'sohws the variable as number' do
272
- expect(function.to_gnu).to eq('f(2, y) = 2**(y)')
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danica
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.3
4
+ version: 2.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darthjee