Skip to content

Commit

Permalink
is_numeric?
Browse files Browse the repository at this point in the history
  • Loading branch information
brianlball committed Feb 27, 2018
1 parent 665b17b commit 12bfb71
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion server/lib/analysis_library/r/doe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
# *******************************************************************************

module AnalysisLibrary::R
class String
def is_number? string
true if Float(string) rescue false
end
end

class Doe
def initialize(r_session)
@r = r_session
Expand Down Expand Up @@ -250,7 +256,11 @@ def full_factorial(selected_variables, number_of_samples)
logger.info("samples_temp is #{samples_temp}")

selected_variables.each_with_index do |var, idx|
samples[var.id.to_s] = samples_temp[idx]
if samples_temp[idx][0].is_number?
samples[var.id.to_s] = samples_temp[idx].to_f
else
samples[var.id.to_s] = samples_temp[idx]
end
end

logger.info("samples is #{samples}")
Expand Down

0 comments on commit 12bfb71

Please sign in to comment.