Skip to content

Commit ba7cb43

Browse files
kojix2Copilot
andcommitted
Deduplicate to_plot_f64 into a shared common helper
Co-authored-by: Copilot <copilot@github.com>
1 parent 2304234 commit ba7cb43

3 files changed

Lines changed: 7 additions & 14 deletions

File tree

src/unicode_plot/common.cr

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ module UnicodePlot
174174
marker[0]
175175
end
176176

177+
private def to_plot_f64(values : Array(T)) : Array(Float64) forall T
178+
{% unless T <= Number %}
179+
{% raise "to_plot_f64 requires numeric array elements" %}
180+
{% end %}
181+
values.map(&.to_f64)
182+
end
183+
177184
def transform_name(tr : Symbol, basename : String = "") : String
178185
name = tr.to_s
179186
name == "identity" ? basename : "#{basename} [#{name}]"

src/unicode_plot/interface/lineplot.cr

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
module UnicodePlot
2-
private def to_plot_f64(values : Array(T)) : Array(Float64) forall T
3-
{% unless T <= Number %}
4-
{% raise "to_plot_f64 requires numeric array elements" %}
5-
{% end %}
6-
values.map(&.to_f64)
7-
end
8-
92
def lineplot(
103
x : Array(Float64),
114
y : Array(Float64),

src/unicode_plot/interface/scatterplot.cr

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
module UnicodePlot
2-
private def to_plot_f64(values : Array(T)) : Array(Float64) forall T
3-
{% unless T <= Number %}
4-
{% raise "to_plot_f64 requires numeric array elements" %}
5-
{% end %}
6-
values.map(&.to_f64)
7-
end
8-
92
def scatterplot(
103
x : Array(Float64),
114
y : Array(Float64),

0 commit comments

Comments
 (0)