daru 0.1.3.1 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rspec +2 -1
  4. data/.rspec_formatter.rb +33 -0
  5. data/.rubocop.yml +26 -2
  6. data/History.md +38 -0
  7. data/README.md +22 -13
  8. data/Rakefile +50 -2
  9. data/benchmarks/csv_reading.rb +22 -0
  10. data/daru.gemspec +9 -2
  11. data/lib/daru.rb +36 -4
  12. data/lib/daru/accessors/array_wrapper.rb +6 -1
  13. data/lib/daru/accessors/dataframe_by_row.rb +10 -2
  14. data/lib/daru/accessors/gsl_wrapper.rb +1 -3
  15. data/lib/daru/accessors/nmatrix_wrapper.rb +9 -0
  16. data/lib/daru/category.rb +935 -0
  17. data/lib/daru/core/group_by.rb +29 -38
  18. data/lib/daru/core/merge.rb +186 -145
  19. data/lib/daru/core/query.rb +22 -11
  20. data/lib/daru/dataframe.rb +976 -885
  21. data/lib/daru/date_time/index.rb +166 -166
  22. data/lib/daru/date_time/offsets.rb +66 -77
  23. data/lib/daru/formatters/table.rb +54 -0
  24. data/lib/daru/helpers/array.rb +40 -0
  25. data/lib/daru/index.rb +476 -73
  26. data/lib/daru/io/io.rb +66 -45
  27. data/lib/daru/io/sql_data_source.rb +33 -62
  28. data/lib/daru/iruby/helpers.rb +38 -0
  29. data/lib/daru/iruby/templates/dataframe.html.erb +52 -0
  30. data/lib/daru/iruby/templates/dataframe_mi.html.erb +58 -0
  31. data/lib/daru/iruby/templates/multi_index.html.erb +12 -0
  32. data/lib/daru/iruby/templates/vector.html.erb +27 -0
  33. data/lib/daru/iruby/templates/vector_mi.html.erb +36 -0
  34. data/lib/daru/maths/arithmetic/dataframe.rb +16 -18
  35. data/lib/daru/maths/arithmetic/vector.rb +4 -6
  36. data/lib/daru/maths/statistics/dataframe.rb +8 -15
  37. data/lib/daru/maths/statistics/vector.rb +120 -98
  38. data/lib/daru/monkeys.rb +12 -40
  39. data/lib/daru/plotting/gruff.rb +3 -0
  40. data/lib/daru/plotting/gruff/category.rb +49 -0
  41. data/lib/daru/plotting/gruff/dataframe.rb +91 -0
  42. data/lib/daru/plotting/gruff/vector.rb +57 -0
  43. data/lib/daru/plotting/nyaplot.rb +3 -0
  44. data/lib/daru/plotting/nyaplot/category.rb +34 -0
  45. data/lib/daru/plotting/nyaplot/dataframe.rb +187 -0
  46. data/lib/daru/plotting/nyaplot/vector.rb +46 -0
  47. data/lib/daru/vector.rb +694 -421
  48. data/lib/daru/version.rb +1 -1
  49. data/profile/_base.rb +23 -0
  50. data/profile/df_to_a.rb +10 -0
  51. data/profile/filter.rb +13 -0
  52. data/profile/joining.rb +13 -0
  53. data/profile/sorting.rb +12 -0
  54. data/profile/vector_each_with_index.rb +9 -0
  55. data/spec/accessors/wrappers_spec.rb +2 -4
  56. data/spec/categorical_spec.rb +1734 -0
  57. data/spec/core/group_by_spec.rb +52 -2
  58. data/spec/core/merge_spec.rb +63 -2
  59. data/spec/core/query_spec.rb +236 -80
  60. data/spec/dataframe_spec.rb +1373 -79
  61. data/spec/date_time/data_spec.rb +3 -5
  62. data/spec/date_time/index_spec.rb +154 -17
  63. data/spec/date_time/offsets_spec.rb +3 -4
  64. data/spec/fixtures/empties.dat +2 -0
  65. data/spec/fixtures/strings.dat +2 -0
  66. data/spec/formatters/table_formatter_spec.rb +99 -0
  67. data/spec/helpers_spec.rb +8 -0
  68. data/spec/index/categorical_index_spec.rb +168 -0
  69. data/spec/index/index_spec.rb +283 -0
  70. data/spec/index/multi_index_spec.rb +570 -0
  71. data/spec/io/io_spec.rb +31 -4
  72. data/spec/io/sql_data_source_spec.rb +0 -1
  73. data/spec/iruby/dataframe_spec.rb +172 -0
  74. data/spec/iruby/helpers_spec.rb +49 -0
  75. data/spec/iruby/multi_index_spec.rb +37 -0
  76. data/spec/iruby/vector_spec.rb +107 -0
  77. data/spec/math/arithmetic/dataframe_spec.rb +71 -13
  78. data/spec/math/arithmetic/vector_spec.rb +8 -10
  79. data/spec/math/statistics/dataframe_spec.rb +3 -5
  80. data/spec/math/statistics/vector_spec.rb +45 -55
  81. data/spec/monkeys_spec.rb +32 -9
  82. data/spec/plotting/dataframe_spec.rb +386 -0
  83. data/spec/plotting/vector_spec.rb +230 -0
  84. data/spec/shared/vector_display_spec.rb +215 -0
  85. data/spec/spec_helper.rb +23 -0
  86. data/spec/vector_spec.rb +905 -138
  87. metadata +143 -11
  88. data/.rubocop_todo.yml +0 -44
  89. data/lib/daru/plotting/dataframe.rb +0 -104
  90. data/lib/daru/plotting/vector.rb +0 -38
  91. data/spec/daru_spec.rb +0 -58
  92. data/spec/index_spec.rb +0 -375
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 642c2417e86205ee8188be300da3740364e5a0b9
4
- data.tar.gz: b1c4cea3ce18551587e30424210f9183fa83c97b
3
+ metadata.gz: 4dd52552d2407c0d16e3aee91f9307366d3d1a02
4
+ data.tar.gz: 2b07b71542fd4b30f75be8d6daecb97dde4954d1
5
5
  SHA512:
6
- metadata.gz: 18857c15c6156ea817e9874b16b76a7c022f58ff3cca9e9255f4cda32d50db67a53cca60ab734daa086891d0991962f2c5afe15d966029a8ebc74e7781667626
7
- data.tar.gz: ac0a49fd0776d6b21ac3a4b57f8c8cb0f06f75d1598afab152e07242c3f94f3fc22c32252e4aa8a6c1faffe204fbd110328b76526a5eef83c97a4cdac1b7c6e7
6
+ metadata.gz: 6d747ea4ac8387f54dab130fb5e2dcd7119327dc5b2395706c9f434f438c245194527eef3b7139c8b7ecb8d9fa2a108b93dae83b1f03bb0048cabe4c205cce06
7
+ data.tar.gz: 49ffad5ced3bd2386edce4c9fc1278c679f923de6ccb29823147fd83a351d26dcd5ac638b3a93bebfc26cb49dc2c3c16c98c6e2a89a515bc25feb90d9cba7a24
data/.gitignore CHANGED
@@ -4,3 +4,5 @@ doc/
4
4
  .yardoc/
5
5
  .bundle
6
6
  vendor/
7
+ profile/out/
8
+ coverage/
data/.rspec CHANGED
@@ -1 +1,2 @@
1
- --color
1
+ --require ./spec/spec_helper.rb
2
+ --color
@@ -0,0 +1,33 @@
1
+ RSpec::Support.require_rspec_core 'formatters/base_text_formatter'
2
+
3
+ class SimpleFormatter < RSpec::Core::Formatters::BaseTextFormatter
4
+ RSpec::Core::Formatters.register self,
5
+ :example_passed, :example_pending, :example_failed, :dump_pending, :dump_failures, :dump_summary
6
+
7
+ def example_passed(message)
8
+ # Do nothing
9
+ end
10
+
11
+ def example_pending(message)
12
+ # Do nothing
13
+ end
14
+
15
+ def example_failed(message)
16
+ # Do nothing
17
+ end
18
+
19
+ def dump_pending(message)
20
+ # Do nothing
21
+ end
22
+
23
+ def dump_failures(message)
24
+ end
25
+
26
+ def dump_summary(message)
27
+ colorizer = ::RSpec::Core::Formatters::ConsoleCodes
28
+
29
+ output.puts "\nFinished in #{message.formatted_duration} " \
30
+ "(files took #{message.formatted_load_time} to load)\n" \
31
+ "#{message.colorized_totals_line(colorizer)}\n"
32
+ end
33
+ end
@@ -1,14 +1,15 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
1
  AllCops:
4
2
  Include:
5
3
  - 'lib/**/*'
6
4
  Exclude:
5
+ - '**/*.erb'
7
6
  - 'spec/*'
8
7
  - 'spec/**/*'
9
8
  - 'vendor/**/*'
10
9
  - 'benchmarks/*'
10
+ - 'profile/*'
11
11
  DisplayCopNames: true
12
+ TargetRubyVersion: 2.0
12
13
 
13
14
  # Preferred codebase style ---------------------------------------------
14
15
  Style/ExtraSpacing:
@@ -35,6 +36,15 @@ Style/AlignParameters:
35
36
  Style/EmptyElse:
36
37
  EnforcedStyle: empty
37
38
 
39
+ Metrics/LineLength:
40
+ Max: 120
41
+
42
+ Metrics/ModuleLength:
43
+ Max: 200
44
+
45
+ Metrics/ClassLength:
46
+ Max: 200
47
+
38
48
  Style/ParallelAssignment:
39
49
  Enabled: false
40
50
 
@@ -56,10 +66,24 @@ Style/SpaceAroundOperators:
56
66
  Style/EmptyCaseCondition:
57
67
  Enabled: false
58
68
 
69
+ Style/MultilineBlockChain:
70
+ Enabled: false
71
+
59
72
  # Neither of prefered styles are good enough :(
60
73
  Style/BlockDelimiters:
61
74
  Enabled: false
62
75
 
76
+ # Current preferred metrics --------------------------------------------
77
+ # Better values are encouraged, but not required.
78
+ Metrics/AbcSize:
79
+ Max: 20
80
+
81
+ Metrics/MethodLength:
82
+ Max: 15
83
+
84
+ Metrics/CyclomaticComplexity:
85
+ Max: 7
86
+
63
87
  # TODO -----------------------------------------------------------------
64
88
 
65
89
  Style/Documentation:
data/History.md CHANGED
@@ -1,3 +1,41 @@
1
+ # 0.1.4 ()
2
+
3
+ * Major Enhancements
4
+ - Added new dependency 'backports' to support #to_h in Ruby 2.0. (@lokeshh)
5
+ - Greatly improve code test coverage. (@zverok)
6
+ - Greatly refactor code and make some methods faster, smaller and more readable. (@zverok)
7
+ - Add support for categorical data with different coding schemes and several methods for in built categorical data support. Add a new index 'Daru::CategoricalIndex'. (@lokeshh)
8
+ - Removed runtime dependencies on 'spreadsheet' and 'reportbuilder'. They are now loaded if the libraries are already present in the system. (@v0dro)
9
+
10
+ * Minor enhancements
11
+ - Update SqlDataSource to improve the performance of DataFrame.from_sql. (@dansbits)
12
+ - Remove default DataFrame name. Now DataFrames will no name by default. (@zverok)
13
+ - Better looking #inspect for Vector and DataFrame. (@zverok)
14
+ - Better looking #to_html for Vector and DataFrame. Also better #to_html for MultiIndex. (@zverok)
15
+ - Remove monkey patching on Array and add those methods to Daru::ArrayHelper. (@zverok)
16
+ - Add a rake task for running RSpec for every Ruby version with a single command. (@lokeshh)
17
+ - Add rake tasks for easily setting up and testing test harness. (@lokeshh)
18
+ - Added `Daru::Vector#to_nmatrix`.
19
+ - Remove the 'metadata' feature introduced in v0.1.3. (@gnilrets)
20
+ - Added `DataFrame#to_df` and `Vector#to_df`. (@gnilrets)
21
+
22
+ * Fixes
23
+ - DataFrame#clone preserves order and name. (@wlevine)
24
+ - Vector#where preserves name. (@v0dro)
25
+ - Fix bug in DataFrame#pivot_table that prevented anything other than Array or Symbol to be specified in the :values option. (@v0dro)
26
+ - Daru::Index#each returns an Enumerator if block is not specified. (@v0dro)
27
+ - Fixes bug where joins failed when nils were in join keys. (@gnilrets)
28
+ - DataFrame#merge now preserves the vector name type when merging. (@lokeshh)
29
+
30
+ * Deprecations
31
+ - Remove methods DataFrame#vector and DataFrame#column. (@zverok)
32
+ - Remove the missing_values feature of daru. The only values that are now treated as 'missing' are `nil` and `Float::NAN`. (@lokeshh)
33
+
34
+ # 0.1.3.1 (12 May 2016)
35
+
36
+ * Fixes
37
+ - Fixed small error with usage of newly introduced #each_with_object (@v0dro).
38
+
1
39
  # 0.1.3 (May 2016)
2
40
 
3
41
  * Enhancements
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/daru.svg)](http://badge.fury.io/rb/daru)
4
4
  [![Build Status](https://travis-ci.org/v0dro/daru.svg)](https://travis-ci.org/v0dro/daru)
5
+ [![Gitter](https://badges.gitter.im/v0dro/daru.svg)](https://gitter.im/v0dro/daru?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
5
6
 
6
7
  ## Introduction
7
8
 
@@ -33,20 +34,33 @@ daru makes it easy and intuitive to process data predominantly through 2 data st
33
34
  * [Basic Creation of Vectors and DataFrame](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Creation%20of%20Vector%20and%20DataFrame.ipynb)
34
35
  * [Detailed Usage of Daru::Vector](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Usage%20of%20Vector.ipynb)
35
36
  * [Detailed Usage of Daru::DataFrame](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Usage%20of%20DataFrame.ipynb)
36
- * [Visualizing Data With Daru::DataFrame](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Visualization/Visualizing%20data%20with%20daru%20DataFrame.ipynb)
37
37
  * [Searching and combining data in daru](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Searching%20and%20Combining%20Data.ipynb)
38
38
  * [Grouping, Splitting and Pivoting Data](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Grouping%2C%20Splitting%20and%20Pivoting.ipynb)
39
+ * [Usage of Catgorical Data](http://nbviewer.jupyter.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Categorical%20Data/Categorical%20Data.ipynb)
40
+
41
+ #### Visualization
42
+ * [Visualizing Data With Daru::DataFrame](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Visualization/Visualizing%20data%20with%20daru%20DataFrame.ipynb)
43
+ * [Plotting using Nyaplot](http://nbviewer.jupyter.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Plotting/Visualization.ipynb)
44
+ * [Plotting using GnuplotRB](http://nbviewer.jupyter.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Plotting/Gnuplotrb.ipynb)
45
+ * [Vector plotting with Gruff](http://nbviewer.jupyter.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Plotting/Gruff%20Vector.ipynb)
46
+ * [DataFrame plotting with Gruff](http://nbviewer.jupyter.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Plotting/Gruff%20DataFrame.ipynb)
39
47
 
40
48
  #### Notebooks on Time series
41
49
 
42
50
  * [Basic Time Series](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Basic%20Time%20Series.ipynb)
43
51
  * [Time Series Analysis and Plotting](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Time%20Series%20Functions.ipynb)
44
52
 
53
+ #### Notebooks on Indexing
54
+ * [Indexing in Vector](http://nbviewer.jupyter.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Categorical%20Data/Indexing%20in%20Vector.ipynb)
55
+ * [Indexing in DataFrame](http://nbviewer.jupyter.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Categorical%20Data/Indexing%20in%20DataFrame.ipynb)
56
+
45
57
  ### Case Studies
46
58
 
47
59
  * [Logistic Regression Analysis with daru and statsample-glm](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Logistic%20Regression%20with%20daru%20and%20statsample-glm.ipynb)
48
60
  * [Finding and Plotting most heard artists from a Last.fm dataset](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Finding%20and%20plotting%20the%20most%20heard%20artists%20on%20last%20fm.ipynb)
49
61
  * [Analyzing baby names with daru](http://nbviewer.ipython.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Analyzing%20baby%20names/Use%20Case%20-%20Daru%20for%20analyzing%20baby%20names%20data.ipynb)
62
+ * [Example usage of Categorical Data](http://nbviewer.jupyter.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Categorical%20Data/examples/%5BExample%5D%20Categorical%20Data.ipynb)
63
+ * [Example usage of Categorical Index](http://nbviewer.jupyter.org/github/SciRuby/sciruby-notebooks/blob/master/Data%20Analysis/Categorical%20Data/examples/%5BExample%5D%20Categorical%20Index.ipynb)
50
64
 
51
65
  ## Blog Posts
52
66
 
@@ -59,6 +73,12 @@ daru makes it easy and intuitive to process data predominantly through 2 data st
59
73
  * [Analysis of Time Series in daru](http://v0dro.github.io/blog/2015/07/31/analysis-of-time-series-in-daru/)
60
74
  * [Date Offsets in Daru](http://v0dro.github.io/blog/2015/07/27/date-offsets-in-daru/)
61
75
 
76
+ ### Categorical Data
77
+
78
+ * [Categorical Index](http://lokeshh.github.io/blog/2016/06/14/categorical-index/)
79
+ * [Categorical Data](http://lokeshh.github.io/blog/2016/06/21/categorical-data/)
80
+ * [Visualization with Categorical Data](http://lokeshh.github.io/blog/2016/07/02/visualization/)
81
+
62
82
  ## Basic Usage
63
83
 
64
84
  daru exposes two major data structures: `DataFrame` and `Vector`. The Vector is a basic 1-D structure corresponding to a labelled Array, while the `DataFrame` - daru's primary data structure - is 2-D spreadsheet-like structure for manipulating and storing data sets.
@@ -168,18 +188,6 @@ In addition to nyaplot, daru also supports plotting out of the box with [gnuplot
168
188
 
169
189
  Docs can be found [here](https://rubygems.org/gems/daru).
170
190
 
171
- ## Roadmap
172
-
173
- * Enable creation of DataFrame by only specifying an NMatrix/MDArray in initialize. Vector naming happens automatically (alphabetic) or is specified in an Array.
174
- * Assignment of a column to a single number should set the entire column to that number.
175
- * Multiple column assignment with []=
176
- * Multiple value assignment for vectors with []=.
177
- * #find\_max function which will evaluate a block and return the row for the value of the block is max.
178
- * Sort by index.
179
- * Statistics on DataFrame over rows.
180
- * Calculate percentage change.
181
- * Have some sample data sets for users to play around with. Should be able to load these from the code itself.
182
-
183
191
  ## Contributing
184
192
 
185
193
  Pick a feature from the Roadmap or the issue tracker or think of your own and send me a Pull Request!
@@ -188,6 +196,7 @@ For details see [CONTRIBUTING](https://github.com/v0dro/daru/blob/master/CONTRIB
188
196
 
189
197
  ## Acknowledgements
190
198
 
199
+ * Google and the Ruby Science Foundation for the Google Summer of Code 2016 grant for speed enhancements and implementation of support for categorical data. Special thanks to [@lokeshh](https://github.com/lokeshh), [@zverok](https://github.com/zverok) and [@agisga](https://github.com/agisga) for their efforts.
191
200
  * Google and the Ruby Science Foundation for the Google Summer of Code 2015 grant for further developing daru and integrating it with other ruby gems.
192
201
  * Thank you [last.fm](http://www.last.fm/) for making user data accessible to the public.
193
202
 
data/Rakefile CHANGED
@@ -2,7 +2,50 @@ require 'rspec/core/rake_task'
2
2
  require 'bundler/gem_tasks'
3
3
 
4
4
  lib_folder = File.expand_path("../lib", __FILE__)
5
- RSpec::Core::RakeTask.new(:spec)
5
+
6
+ RUBIES = ['ruby-2.0.0-p643', 'ruby-2.1.5', 'ruby-2.2.1', 'ruby-2.3.0']
7
+
8
+ def spec_run_all
9
+ RUBIES.each do |ruby_v|
10
+ puts "\n Using #{ruby_v}\n\n"
11
+ command = "$rvm_path/wrappers/#{ruby_v}/rake summary"
12
+ run command
13
+ end
14
+ end
15
+
16
+ task :spec do
17
+ case ARGV[1]
18
+ when 'setup'
19
+ spec_setup
20
+ when 'run'
21
+ spec_run_all if ARGV[2] == 'all'
22
+ when nil
23
+ run 'rspec spec'
24
+ end
25
+ end
26
+
27
+ # Stubs
28
+ task :setup
29
+ task :run
30
+ task :all
31
+
32
+ def spec_setup
33
+ RUBIES.each do |ruby_v|
34
+ puts "Installing #{ruby_v}..."
35
+ run "rvm install #{ruby_v}"
36
+ path = "$rvm_path/wrappers/#{ruby_v}"
37
+ run "#{path}/gem install bundler"
38
+ run "#{path}/bundle install"
39
+ end
40
+ end
41
+
42
+ #task all: [:cop, :run_all]
43
+
44
+ task :summary do
45
+ run 'rspec spec/ -r ./.rspec_formatter.rb -f SimpleFormatter' rescue nil
46
+ end
47
+
48
+ #RSpec::Core::RakeTask.new(:spec)
6
49
 
7
50
  task :default => :spec
8
51
 
@@ -11,6 +54,10 @@ task :console do |task|
11
54
  run *cmd
12
55
  end
13
56
 
57
+ task :cop do |task|
58
+ run 'rubocop' rescue nil
59
+ end
60
+
14
61
  task :pry do |task|
15
62
  cmd = [ 'pry', "-r '#{lib_folder}/daru.rb'" ]
16
63
  run *cmd
@@ -18,4 +65,5 @@ end
18
65
 
19
66
  def run *cmd
20
67
  sh(cmd.join(" "))
21
- end
68
+ end
69
+
@@ -0,0 +1,22 @@
1
+ # Date - 28 june 2016. daru version - 0.1.3.1
2
+ # Compare speed of Ruby stdlib CSV and DataFrame.from_csv.
3
+
4
+ require 'benchmark'
5
+ require 'csv'
6
+ require 'daru'
7
+
8
+ Benchmark.bm do |x|
9
+ x.report("Ruby CSV") do
10
+ CSV.read("TradeoffData.csv")
11
+ end
12
+
13
+ x.report("DataFrame.from_csv") do
14
+ Daru::DataFrame.from_csv("TradeoffData.csv")
15
+ end
16
+ end
17
+
18
+ # FIXME: Improve this. It's 4 times slower than Ruby CSV reading!!
19
+
20
+ # user system total real
21
+ # Ruby CSV 0.010000 0.000000 0.010000 ( 0.002385)
22
+ # DataFrame.from_csv 0.000000 0.000000 0.000000 ( 0.008225)
@@ -49,15 +49,18 @@ Cheers!
49
49
  *************************************************************************
50
50
  EOF
51
51
 
52
- spec.add_runtime_dependency 'reportbuilder', '~> 1.4'
53
- spec.add_runtime_dependency 'spreadsheet', '~> 1.1.1'
54
52
 
53
+ spec.add_runtime_dependency 'backports'
54
+
55
+ spec.add_development_dependency 'reportbuilder', '~> 1.4'
56
+ spec.add_development_dependency 'spreadsheet', '~> 1.1.1'
55
57
  spec.add_development_dependency 'bundler', '~> 1.10'
56
58
  spec.add_development_dependency 'rake', '~>10.5'
57
59
  spec.add_development_dependency 'pry', '~> 0.10'
58
60
  spec.add_development_dependency 'pry-byebug'
59
61
  spec.add_development_dependency 'rserve-client', '~> 0.3'
60
62
  spec.add_development_dependency 'rspec', '~> 3.4'
63
+ spec.add_development_dependency 'rspec-its'
61
64
  spec.add_development_dependency 'awesome_print'
62
65
  spec.add_development_dependency 'nyaplot', '~> 0.1.5'
63
66
  spec.add_development_dependency 'nmatrix', '~> 0.2.1'
@@ -68,4 +71,8 @@ EOF
68
71
  spec.add_development_dependency 'activerecord', '~> 4.0'
69
72
  spec.add_development_dependency 'sqlite3'
70
73
  spec.add_development_dependency 'rubocop', '>= 0.40.0'
74
+ spec.add_development_dependency 'ruby-prof'
75
+ spec.add_development_dependency 'simplecov'
76
+ spec.add_development_dependency 'nokogiri'
77
+ spec.add_development_dependency 'gruff'
71
78
  end
@@ -1,6 +1,8 @@
1
+ # :nocov:
1
2
  def jruby?
2
3
  RUBY_ENGINE == 'jruby'
3
4
  end
5
+ # :nocov:
4
6
 
5
7
  module Daru
6
8
  DAYS_OF_WEEK = {
@@ -28,15 +30,20 @@ module Daru
28
30
  12 => 31
29
31
  }.freeze
30
32
 
33
+ MISSING_VALUES = [nil, Float::NAN].freeze
34
+
31
35
  @lazy_update = false
32
36
 
33
37
  SPLIT_TOKEN = ','.freeze
34
38
 
39
+ @plotting_library = :nyaplot
40
+
35
41
  class << self
36
42
  # A variable which will set whether Vector metadata is updated immediately or lazily.
37
43
  # Call the #update method every time a values are set or removed in order to update
38
44
  # metadata like positions of missing values.
39
45
  attr_accessor :lazy_update
46
+ attr_reader :plotting_library
40
47
 
41
48
  def create_has_library(library)
42
49
  lib_underscore = library.to_s.tr('-', '_')
@@ -48,31 +55,54 @@ module Daru
48
55
  require library.to_s
49
56
  class_variable_set(cv, true)
50
57
  rescue LoadError
58
+ # :nocov:
51
59
  class_variable_set(cv, false)
60
+ # :nocov:
52
61
  end
53
62
  end
54
63
  class_variable_get(cv)
55
64
  end
56
65
  end
66
+
67
+ def plotting_library= lib
68
+ case lib
69
+ when :gruff, :nyaplot
70
+ @plotting_library = lib
71
+ else
72
+ raise ArgumentError, "Unsupported library #{lib}"
73
+ end
74
+ end
57
75
  end
58
76
 
59
77
  create_has_library :gsl
60
78
  create_has_library :nmatrix
61
79
  create_has_library :nyaplot
80
+ create_has_library :gruff
62
81
  end
63
82
 
64
- autoload :Spreadsheet, 'spreadsheet'
65
- autoload :CSV, 'csv'
83
+ [['reportbuilder', '~>1.4'], ['spreadsheet', '~>1.1.1']].each do |lib|
84
+ begin
85
+ gem lib[0], lib[1]
86
+ require lib[0]
87
+ rescue LoadError
88
+ STDERR.puts "\nInstall the #{lib[0]} gem version #{lib[1]} for using"\
89
+ " #{lib[0]} functions."
90
+ end
91
+ end
66
92
 
93
+ autoload :CSV, 'csv'
67
94
  require 'matrix'
68
- require 'securerandom'
69
- require 'reportbuilder'
70
95
 
71
96
  require 'daru/version.rb'
97
+
98
+ require 'daru/helpers/array.rb'
72
99
  require 'daru/index.rb'
73
100
  require 'daru/vector.rb'
74
101
  require 'daru/dataframe.rb'
75
102
  require 'daru/monkeys.rb'
103
+ require 'daru/formatters/table'
104
+ require 'daru/iruby/helpers'
105
+ require 'daru/exceptions.rb'
76
106
 
77
107
  require 'daru/core/group_by.rb'
78
108
  require 'daru/core/query.rb'
@@ -80,3 +110,5 @@ require 'daru/core/merge.rb'
80
110
 
81
111
  require 'daru/date_time/offsets.rb'
82
112
  require 'daru/date_time/index.rb'
113
+
114
+ require 'backports'