Remove Processing module

This commit is contained in:
kojix2 2021-05-27 23:18:08 +09:00
parent 86c0d8ed53
commit 607e490d7a
3 changed files with 1 additions and 36 deletions

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
require 'enumerable/statistics'
module YouPlot
# plotting functions.
module Backends
module Processing
module_function
def count_values(arr, tally: true)
a = arr.value_counts
[a.keys, a.values]
end
end
end
end

View File

@ -1,6 +1,5 @@
# frozen_string_literal: true
require_relative 'processing'
require 'unicode_plot'
module YouPlot
@ -16,7 +15,7 @@ module YouPlot
series = data.series
# `uplot count`
if count
series = Processing.count_values(series[0])
series = series[0].value_counts.yield_self { |h| [h.keys, h.values] }
params.title = headers[0] if headers
end
if series.size == 1

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
require_relative '../../test_helper'
class YouPlotCommandTest < Test::Unit::TestCase
test :count_values do
@m = YouPlot::Backends::Processing
assert_equal([%i[a b c], [3, 2, 1]], @m.count_values(%i[a a a b b c]))
assert_equal([%i[c b a], [3, 2, 1]], @m.count_values(%i[a b b c c c]))
end
test :count_values_non_tally do
@m = YouPlot::Backends::Processing
assert_equal([%i[a b c], [3, 2, 1]], @m.count_values(%i[a a a b b c], tally: false))
assert_equal([%i[c b a], [3, 2, 1]], @m.count_values(%i[a b b c c c], tally: false))
end
end