mirror of
https://github.com/red-data-tools/YouPlot.git
synced 2025-05-07 07:31:12 +08:00
218 lines
6.8 KiB
HTML
218 lines
6.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>
|
|
Module: YouPlot::Backends::Processing
|
|
|
|
— Documentation by YARD 0.9.28
|
|
|
|
</title>
|
|
|
|
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
|
|
|
|
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
|
|
|
|
<script type="text/javascript">
|
|
pathId = "YouPlot::Backends::Processing";
|
|
relpath = '../../';
|
|
</script>
|
|
|
|
|
|
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
|
|
|
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
|
|
|
|
|
</head>
|
|
<body>
|
|
<div class="nav_wrap">
|
|
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
|
<div id="resizer"></div>
|
|
</div>
|
|
|
|
<div id="main" tabindex="-1">
|
|
<div id="header">
|
|
<div id="menu">
|
|
|
|
<a href="../../_index.html">Index (P)</a> »
|
|
<span class='title'><span class='object_link'><a href="../../YouPlot.html" title="YouPlot (module)">YouPlot</a></span></span> » <span class='title'><span class='object_link'><a href="../Backends.html" title="YouPlot::Backends (module)">Backends</a></span></span>
|
|
»
|
|
<span class="title">Processing</span>
|
|
|
|
</div>
|
|
|
|
<div id="search">
|
|
|
|
<a class="full_list_link" id="class_list_link"
|
|
href="../../class_list.html">
|
|
|
|
<svg width="24" height="24">
|
|
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
|
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
|
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
|
</svg>
|
|
</a>
|
|
|
|
</div>
|
|
<div class="clear"></div>
|
|
</div>
|
|
|
|
<div id="content"><h1>Module: YouPlot::Backends::Processing
|
|
|
|
|
|
|
|
</h1>
|
|
<div class="box_info">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<dl>
|
|
<dt>Defined in:</dt>
|
|
<dd>lib/youplot/backends/processing.rb</dd>
|
|
</dl>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2>
|
|
Class Method Summary
|
|
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
</h2>
|
|
|
|
<ul class="summary">
|
|
|
|
<li class="public ">
|
|
<span class="summary_signature">
|
|
|
|
<a href="#count_values-class_method" title="count_values (class method)">.<strong>count_values</strong>(arr, tally: true, reverse: false) ⇒ Object </a>
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<span class="summary_desc"><div class='inline'></div></span>
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<div id="class_method_details" class="method_details_list">
|
|
<h2>Class Method Details</h2>
|
|
|
|
|
|
<div class="method_details first">
|
|
<h3 class="signature first" id="count_values-class_method">
|
|
|
|
.<strong>count_values</strong>(arr, tally: true, reverse: false) ⇒ <tt>Object</tt>
|
|
|
|
|
|
|
|
|
|
|
|
</h3><table class="source_code">
|
|
<tr>
|
|
<td>
|
|
<pre class="lines">
|
|
|
|
|
|
9
|
|
10
|
|
11
|
|
12
|
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
|
18
|
|
19
|
|
20
|
|
21
|
|
22
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28
|
|
29
|
|
30
|
|
31
|
|
32
|
|
33</pre>
|
|
</td>
|
|
<td>
|
|
<pre class="code"><span class="info file"># File 'lib/youplot/backends/processing.rb', line 9</span>
|
|
|
|
<span class='kw'>def</span> <span class='id identifier rubyid_count_values'>count_values</span><span class='lparen'>(</span><span class='id identifier rubyid_arr'>arr</span><span class='comma'>,</span> <span class='label'>tally:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>reverse:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
|
<span class='comment'># tally was added in Ruby 2.7
|
|
</span> <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> \
|
|
<span class='kw'>if</span> <span class='id identifier rubyid_tally'>tally</span> <span class='op'>&&</span> <span class='const'>Enumerable</span><span class='period'>.</span><span class='id identifier rubyid_method_defined?'>method_defined?</span><span class='lparen'>(</span><span class='symbol'>:tally</span><span class='rparen'>)</span>
|
|
<span class='id identifier rubyid_arr'>arr</span><span class='period'>.</span><span class='id identifier rubyid_tally'>tally</span>
|
|
<span class='kw'>else</span>
|
|
<span class='comment'># value_counts Enumerable::Statistics
|
|
</span> <span class='id identifier rubyid_arr'>arr</span><span class='period'>.</span><span class='id identifier rubyid_value_counts'>value_counts</span><span class='lparen'>(</span><span class='label'>dropna:</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
|
<span class='kw'>end</span>
|
|
|
|
<span class='comment'># sorting
|
|
</span> <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_sort'>sort</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_a'>a</span><span class='comma'>,</span> <span class='id identifier rubyid_b'>b</span><span class='op'>|</span>
|
|
<span class='comment'># compare values
|
|
</span> <span class='id identifier rubyid_r'>r</span> <span class='op'>=</span> <span class='id identifier rubyid_b'>b</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='op'><=></span> <span class='id identifier rubyid_a'>a</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span>
|
|
<span class='comment'># If the values are the same, compare by name
|
|
</span> <span class='id identifier rubyid_r'>r</span> <span class='op'>=</span> <span class='id identifier rubyid_a'>a</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'><=></span> <span class='id identifier rubyid_b'>b</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='kw'>if</span> <span class='id identifier rubyid_r'>r</span><span class='period'>.</span><span class='id identifier rubyid_zero?'>zero?</span>
|
|
<span class='id identifier rubyid_r'>r</span>
|
|
<span class='kw'>end</span>
|
|
|
|
<span class='comment'># --reverse option
|
|
</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_reverse!'>reverse!</span> <span class='kw'>if</span> <span class='id identifier rubyid_reverse'>reverse</span>
|
|
|
|
<span class='comment'># prepare for barplot
|
|
</span> <span class='id identifier rubyid_result'>result</span><span class='period'>.</span><span class='id identifier rubyid_transpose'>transpose</span>
|
|
<span class='kw'>end</span></pre>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="footer">
|
|
Generated on Thu Jan 5 02:42:52 2023 by
|
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
0.9.28 (ruby-3.2.0).
|
|
</div>
|
|
|
|
</div>
|
|
</body>
|
|
</html> |