debugging

pull/1/head
Oliver Kennedy 2018-04-27 20:47:45 -04:00
parent 39c63d126c
commit 73e1e7b9da
4 changed files with 6 additions and 4 deletions

View File

@ -1,3 +1,5 @@
require "stringio"
class Pipeline
def initialize(source)

View File

@ -118,7 +118,7 @@ class Array
Math.sqrt((avg ** 2 - (map{|i| i.to_f ** 2}.avg)).abs)
end
def my_reduce(&reducer)
def reduce(&reducer)
ret = Hash.new;
each do |k,v|
ret[k] = Array.new unless ret.has_key? k;
@ -289,7 +289,7 @@ class Array
map { |x| [x, 0] }.
to_h.
join(map { |x| (x.to_f / bin_width).to_i * bin_width }.
my_reduce { |k,v| v.count },
reduce { |k,v| v.count },
:left
).
map { |bin, cnt| [bin, cnt.compact.sum] }.

View File

@ -8,7 +8,7 @@ title: Funding Sources
<% $db["cv/okennedy/grants"].
where { |grant| ["accepted", "completed"].include? grant["status"] }.
map { |grant| [grant["start"].split(/\//)[-1].to_i, grant] }.
my_reduce.
reduce.
sort_by { |x| -x[0] }.
each do |year, grants| %>
<h2><%=year%></h2>

View File

@ -4,7 +4,7 @@ title: Publications
<div style="height: 20px">&nbsp;</div>
<div class="paper_list">
<% $db["publications"].map { |pub| [pub["year"].to_i, pub] }.my_reduce.each do |year, pubs| %>
<% $db["publications"].map { |pub| [pub["year"].to_i, pub] }.reduce.each do |year, pubs| %>
<div class="panel">
<div class="panel-heading">
<center><h2><%= year %></h2></center>