Skip to content

Commit 31a8920

Browse files
committed
fix Fit::fit
1 parent f25b4f3 commit 31a8920

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/gnuplotrb/fit.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ def gnuplot_fit(function, data, options, initials, term_options)
186186
term = Terminal.new
187187
term.set(term_options)
188188
initials.each { |var_name, value| term.stream_puts "#{var_name} = #{value}" }
189-
command = "fit #{function} #{data.to_s(term)} #{options} via #{variables.join(',')}"
189+
command = "fit #{function} #{data.to_s(term, without_options: true)} " \
190+
"#{options} via #{variables.join(',')}"
190191
term.stream_puts(command)
191192
output = wait_for_output(term, variables)
192193
begin

lib/gnuplotrb/staff/dataset.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,18 @@ def initialize(data, **options)
7373
# @param terminal [Terminal] must be given if data given as Datablock and
7474
# it does not use temp file so data should be piped out
7575
# to gnuplot via terminal before use
76+
# @param :without_options [Boolean] do not add options to dataset if set
77+
# to true. Used by Fit::fit
7678
# @return [String] gnuplot dataset
7779
# @example
7880
# Dataset.new('points.data', with: 'lines', title: 'Points from file').to_s
79-
# #=> "'points.data' with lines title 'Points form file'"
81+
# #=> "'points.data' with lines title 'Points from file'"
8082
# Dataset.new(points, with: 'points', title: 'Points').to_s
8183
# #=> "$DATA1 with points title 'Points'"
82-
def to_s(terminal = nil)
83-
"#{@type == :datablock ? @data.name(terminal) : @data} #{options_to_string}"
84+
def to_s(terminal = nil, without_options: false)
85+
result = "#{@type == :datablock ? @data.name(terminal) : @data} "
86+
result += options_to_string unless without_options
87+
result
8488
end
8589

8690
##

0 commit comments

Comments
 (0)