GSoC 2017 - Coding Period | Week 12

Posted on 20/08/2017 at 8:00 PM by The Vibe.

Software Development Documentation Ruby GSoC 2017

GSoC Banner image

Throughout this week, I was mostly working on the sample Rails application along with Shekhar and also on the documentation of the daru-io gem repository. With the coding period coming closer and closer to an end, the focus is currently on turning the project into a deliverable open-source project, which could benefit from community (open-source) contribution.

Sample Rails Application

With the Rails application being deployed to Heroku, demonstrating the sample application is much easier. The Pull Requests Download as {format} and HTML Importer showcase have been merged and deployed. As it can be seen from the election controller, all the visualization entities like DataTable, Pie Chart and Column Chart have been achieved in just a couple of lines of code. Here's a code snippet of the controller -

  #! app/controllers/election_controller.rb

  class ElectionController < ApplicationController

    layout :resolve_layout

    def data
      @df_stock = Daru::DataFrame.from_html('').first
      @df_stock.delete_row(-1) # delete the 'Total' row for visualization purpose
      data                = @df_stock.map_vectors { |x| [, { |y| y.to_i.to_s==y ? y.to_i : y } ] }.to_h
      new_df              ='Party' => data['Party'], 'Won' => data['Won'])
      opts                = { adapter: :googlecharts, height: 500, width: 1000 }
      table_opts          = { adapter: :googlecharts, pageSize: 10, height: 300, width: 400 }
      @df_stock_table     =, table_opts) # DataTable entity
      @df_stock_pie_chart =, type: :pie, **opts) # Pie Chart entity
      @df_stock_col_chart =, type: :histogram, **opts) # Column Chart entity


    def resolve_layout
     case action_name
       when 'data'
        Daru::View.plotting_library = :nyaplot

Great, the controller part is done. But for visualization, we obviously need to have the views part. Here's the most simple way to embed the DataTable or Charts.

  #! app/views/election/data.erb

  <%=raw @df_stock_table.div %>
  <%=raw @df_stock_pie_chart.div %>
  <%=raw @df_stock_col_chart.div %>

Here are a few screenshots showcasing the above example of election data with the use of HTML Importer.

Visualization as DataTable

Visualization as Pie Chart

Visualization as Column Chart

Documenting the daru-io repository

Irrespective of how well written the code is, the software won't be friendly for users unless it is well documented. With daru-io to be transferred to SciRuby organzization on GitHub soon enough, it is quite necessary to add files : README, LICENSE, CODE OF CONDUCT, CONTRIBUTING and so on. They are being added quite exhaustively in this Pull Request, to ensure that users and contributors of daru-io, find it easier to develop with daru-io.

Meanwhile, a discussion regarding the calls of read-write methods from daru to daru-io is going on, in this issue. Also, Pjotr's suggestion of adding benchmarks for daru-io to identify the IO modules that might require faster approaches, sounds good and this is something that daru-io users could need, to decide on faster formats to import / export. Though this might not be possible within the GSoC 2017 timeline, I'd definitely like to add these benchmarks after GSoC 2017.