lib/remi/cucumber/business_rules.rb in remi-0.2.30 vs lib/remi/cucumber/business_rules.rb in remi-0.2.31
- old
+ new
@@ -388,10 +388,16 @@
def freq_by(*field_names)
@data_subject.df.group_by(field_names).size * 1.0 / @data_subject.df.size
end
+ def unique_integer_field(field_name)
+ vector_name = fields[field_name].field_name
+ i = 0
+ @data_subject.df[vector_name].recode! { |v| i += 1 }
+ end
+
def mock_extractor(filestore)
extractor = class << @data_subject.extractor; self; end
extractor.send(:define_method, :all_entries, ->() { filestore.sftp_entries })
extractor.send(:define_method, :download, ->(to_download) { to_download.map { |e| e.name } })
@@ -524,10 +530,17 @@
def to_df(seed_hash, field_symbolizer:)
table_headers = @table.headers.map { |h| h.symbolize(field_symbolizer) }
df = Daru::DataFrame.new([], order: seed_hash.keys | table_headers)
@table.hashes.each do |example_row|
example_row_sym = example_row.reduce({}) do |h, (k,v)|
- h[k.symbolize(field_symbolizer)] = ParseFormula.parse(v)
+ formula_value = ParseFormula.parse(v)
+ value = case formula_value
+ when '\nil'
+ nil
+ else
+ formula_value
+ end
+ h[k.symbolize(field_symbolizer)] = value
h
end
df.add_row(seed_hash.merge(example_row_sym))
end
df