1
0

Formula#calculate is using QuantityInput

Updated FormulaBuilder to properly index parts[]
This commit is contained in:
cryptogopher
2020-05-17 18:14:19 +02:00
parent c402fe8353
commit fa9c329a81
3 changed files with 24 additions and 6 deletions

View File

@@ -20,7 +20,7 @@ class Formula < ActiveRecord::Base
def calculate(inputs)
raise(InvalidInputs, 'No inputs') if inputs.empty?
deps = inputs.map { |q, v| [q.name, v.transpose.first] }.to_h
deps = inputs.map { |q, v| [q.name, QuantityInput.new(q, v.transpose.first)] }.to_h
length = deps.values.first.length
raise(InvalidFormula, 'Invalid formula') unless self.valid?
@@ -47,6 +47,10 @@ class Formula < ActiveRecord::Base
super(*args)
@quantity = q
end
def lastBefore(timepoints)
self.map{ BigDecimal(2000) }
end
end
def parse
@@ -77,7 +81,7 @@ class Formula < ActiveRecord::Base
errors
end
def get_binding(quantities, args, length)
def get_binding(quantities, parts, length)
binding
end
end