From 607e490d7a8b4caa27a3fd01586ffaf17748e11f Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Thu, 27 May 2021 23:18:08 +0900 Subject: [PATCH] Remove Processing module --- lib/youplot/backends/processing.rb | 17 ----------------- lib/youplot/backends/unicode_plot_backend.rb | 3 +-- test/youplot/backends/processing_test.rb | 17 ----------------- 3 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 lib/youplot/backends/processing.rb delete mode 100644 test/youplot/backends/processing_test.rb diff --git a/lib/youplot/backends/processing.rb b/lib/youplot/backends/processing.rb deleted file mode 100644 index eb5aea3..0000000 --- a/lib/youplot/backends/processing.rb +++ /dev/null @@ -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 diff --git a/lib/youplot/backends/unicode_plot_backend.rb b/lib/youplot/backends/unicode_plot_backend.rb index 95a34e9..53bc9b2 100644 --- a/lib/youplot/backends/unicode_plot_backend.rb +++ b/lib/youplot/backends/unicode_plot_backend.rb @@ -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 diff --git a/test/youplot/backends/processing_test.rb b/test/youplot/backends/processing_test.rb deleted file mode 100644 index 88954b5..0000000 --- a/test/youplot/backends/processing_test.rb +++ /dev/null @@ -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