galaaz 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -5
  3. data/README.md +200 -128
  4. data/Rakefile +17 -10
  5. data/bin/galaaz +10 -2
  6. data/bin/galaaz-jruby +3 -6
  7. data/bin/galaaz-ruby +16 -0
  8. data/bin/galaaz_jruby_env.inc.sh +19 -3
  9. data/bin/galaaz_ruby_env.inc.sh +38 -0
  10. data/bin/gbookdown +2 -3
  11. data/bin/gknit +2 -3
  12. data/bin/gstudio +4 -4
  13. data/bin/run_all_rspec +6 -5
  14. data/bin/run_example +10 -7
  15. data/bin/run_old_rspec +6 -5
  16. data/bin/run_rspec +9 -8
  17. data/bin/run_slow_rspec +6 -5
  18. data/blogs/R-on-Rails-Planning-Document.md +79 -112
  19. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-gfm/midwest_rb.png +0 -0
  20. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-gfm/scatter_plot_rb.png +0 -0
  21. data/blogs/gknit/gknit_files/figure-gfm/bubble-1.png +0 -0
  22. data/blogs/gknit/gknit_files/figure-gfm/diverging_bar.png +0 -0
  23. data/blogs/manual/manual.Rmd +22 -19
  24. data/blogs/manual/manual.md +200 -128
  25. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/dose_len.png +0 -0
  26. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facet_by_delivery.png +0 -0
  27. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facet_by_dose.png +0 -0
  28. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_by_delivery_color.png +0 -0
  29. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_by_delivery_color2.png +0 -0
  30. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_with_decorations.png +0 -0
  31. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_with_jitter.png +0 -0
  32. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_with_points.png +0 -0
  33. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/final_box_plot.png +0 -0
  34. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/final_violin_plot.png +0 -0
  35. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/violin_with_jitter.png +0 -0
  36. data/blogs/test/test.md +10 -0
  37. data/examples/50Plots_MasterList/ScatterPlot.rb +2 -1
  38. data/examples/50Plots_MasterList/scatter_plot.rb +1 -0
  39. data/examples/bioconductor_deseq2_airway/bench_galaaz_three_same_process.rb +1 -0
  40. data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb +1 -0
  41. data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz_optimized.rb +1 -0
  42. data/examples/islr/all.rb +1 -0
  43. data/examples/islr/ch2.spec.rb +1 -0
  44. data/examples/islr/ch3.spec.rb +1 -0
  45. data/examples/islr/ch3_boston.rb +1 -0
  46. data/examples/islr/ch3_multiple_regression.rb +1 -0
  47. data/examples/islr/ch6.spec.rb +1 -0
  48. data/examples/islr/x_y_rnorm.jpg +0 -0
  49. data/examples/misc/ggplot.rb +2 -1
  50. data/examples/misc/moneyball.rb +1 -0
  51. data/examples/misc/subsetting.rb +1 -0
  52. data/examples/multithread_shards_to_r/shards_to_r.rb +1 -0
  53. data/examples/sthda_ggplot/all.rb +1 -0
  54. data/examples/sthda_ggplot/one_variable_continuous/density_gg.rb +1 -0
  55. data/examples/sthda_ggplot/one_variable_continuous/geom_area.rb +1 -0
  56. data/examples/sthda_ggplot/one_variable_continuous/geom_density.rb +1 -0
  57. data/examples/sthda_ggplot/one_variable_continuous/geom_dotplot.rb +1 -0
  58. data/examples/sthda_ggplot/one_variable_continuous/geom_freqpoly.rb +1 -0
  59. data/examples/sthda_ggplot/one_variable_continuous/geom_histogram.rb +1 -0
  60. data/examples/sthda_ggplot/one_variable_continuous/histogram_density.rb +1 -0
  61. data/examples/sthda_ggplot/one_variable_continuous/stat.rb +1 -0
  62. data/examples/sthda_ggplot/one_variable_discrete/bar.rb +1 -0
  63. data/examples/sthda_ggplot/qplots/box_violin_dot.rb +1 -0
  64. data/examples/sthda_ggplot/qplots/scatter_plots.rb +1 -0
  65. data/examples/sthda_ggplot/scatter_gg.rb +1 -0
  66. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_bin2d.rb +1 -0
  67. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_density2d.rb +1 -0
  68. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_hex.rb +1 -0
  69. data/examples/sthda_ggplot/two_variables_cont_cont/geom_point.rb +1 -0
  70. data/examples/sthda_ggplot/two_variables_cont_cont/geom_smooth.rb +1 -0
  71. data/examples/sthda_ggplot/two_variables_cont_cont/misc.rb +1 -0
  72. data/examples/sthda_ggplot/two_variables_cont_function/geom_area.rb +1 -0
  73. data/examples/sthda_ggplot/two_variables_disc_cont/geom_bar.rb +1 -0
  74. data/examples/sthda_ggplot/two_variables_disc_cont/geom_boxplot.rb +1 -0
  75. data/examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb +1 -0
  76. data/examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb +1 -0
  77. data/examples/sthda_ggplot/two_variables_disc_cont/geom_line.rb +1 -0
  78. data/examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb +1 -0
  79. data/examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb +1 -0
  80. data/examples/sthda_ggplot/two_variables_error/geom_crossbar.rb +1 -0
  81. data/lib/R_interface/r_arrow.rb +37 -0
  82. data/lib/R_interface/rvector.rb +15 -0
  83. data/lib/galaaz/arrow_ipc/java_arrow_backend.rb +250 -0
  84. data/lib/galaaz/arrow_ipc/red_arrow_backend.rb +126 -0
  85. data/lib/galaaz/arrow_ipc.rb +167 -0
  86. data/lib/galaaz/cli.rb +531 -0
  87. data/lib/galaaz.rb +6 -0
  88. data/lib/galaaz_jruby.rb +17 -2
  89. data/lib/galaaz_ruby.rb +34 -0
  90. data/lib/new_bridge/envelope.rb +2 -2
  91. data/new_bridge_specs/arrow_ipc_async_spec.rb +90 -0
  92. data/new_bridge_specs/arrow_ipc_export_async_spec.rb +68 -0
  93. data/r_requires/arrow.txt +3 -0
  94. data/r_requires/knit-extras.txt +4 -0
  95. data/r_requires/knit.txt +4 -0
  96. data/specs/arrow_ipc_export_spec.rb +62 -0
  97. data/specs/arrow_ipc_handoff_spec.rb +97 -0
  98. data/specs/gknit_include_engine_spec.rb +2 -2
  99. data/specs/gknit_install_timeout_report_spec.rb +2 -2
  100. data/specs/gknit_internal_error_report_spec.rb +2 -2
  101. data/specs/gknit_vector_map_output_spec.rb +2 -2
  102. data/version.rb +1 -1
  103. metadata +50 -13
data/examples/islr/all.rb CHANGED
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  # load ISLR and MASS Libraries
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  context "ISLR" do
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  context "ISLR" do
@@ -21,6 +21,7 @@
21
21
  ##########################################################################################
22
22
 
23
23
  require 'galaaz'
24
+ using Galaaz::SymbolDSL
24
25
  require 'ggplot'
25
26
 
26
27
  R.install_and_loads('ISLR', 'MASS')
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.install_and_loads('ISLR', 'MASS')
@@ -23,6 +23,7 @@
23
23
 
24
24
  require 'galaaz'
25
25
 
26
+ using Galaaz::SymbolDSL
26
27
  R.install_and_loads('ISLR', 'MASS')
27
28
 
28
29
  context "ISLR" do
Binary file
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  module LightBlueTheme
@@ -154,7 +155,7 @@ R.grid__newpage
154
155
  R.geom_point('')).print
155
156
  =end
156
157
 
157
- a = gets.chomp
158
+ a = gets.chomp if $stdin.tty?
158
159
 
159
160
 
160
161
  =begin
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'galaaz'
4
4
 
5
+ using Galaaz::SymbolDSL
5
6
  local_dir = File.expand_path File.dirname(__FILE__)
6
7
 
7
8
  # This dataset comes from Baseball-Reference.com.
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'galaaz'
4
4
 
5
+ using Galaaz::SymbolDSL
5
6
  # This examples were extracted from "Advanced R", by Hadley Wickham, available on the
6
7
  # web at: http://adv-r.had.co.nz/Subsetting.html#applications
7
8
 
@@ -16,6 +16,7 @@
16
16
 
17
17
  require 'galaaz'
18
18
 
19
+ using Galaaz::SymbolDSL
19
20
  SHARD_COUNT = 3
20
21
  ROWS_PER_SHARD = 200
21
22
 
@@ -21,6 +21,7 @@
21
21
 
22
22
  require 'galaaz'
23
23
 
24
+ using Galaaz::SymbolDSL
24
25
  # Package Hmisc does not yet install on graalvm because of
25
26
  # problems with package data.table
26
27
  # install.packages('Hmisc')
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.set__seed(1234)
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.set__seed(1234)
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.set__seed(1234)
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.set__seed(1234)
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.set__seed(1234)
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.set__seed(1234)
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.set__seed(1234)
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.set__seed(1234)
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  # puts ~:mpg
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.set__seed(1234)
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  # Load the data
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.awt
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  diamonds = ~:diamonds
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  faithful = ~:faithful
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.install_and_loads('hexbin')
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  mtcars = ~:mtcars
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  mtcars = ~:mtcars
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.install_and_loads('quantreg')
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  economics = ~:economics
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  df = R.data__frame(dose: R.c("D0.5", "D1", "D2"),
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  tooth_growth = ~:ToothGrowth
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.install_and_loads('Hmisc')
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
  R.install_and_loads('Hmisc')
27
28
 
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  df = R.data__frame(supp: R.rep(R.c("VC", "OJ"), each: 3),
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
  R.install_and_loads('Hmisc')
27
28
 
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  diamonds = ~:diamonds
@@ -22,6 +22,7 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
28
  R.install_and_loads('Hmisc')
@@ -63,6 +63,43 @@ module R
63
63
  R.arrow___as_arrow_table(r_df)
64
64
  end
65
65
 
66
+ # Open an Arrow IPC file (written by Galaaz::ArrowIpc or compatible) as an
67
+ # R-side Arrow Table. Materializes the table in R so the Ruby process may
68
+ # unlink the path immediately after this call returns (Stage B1 lifetime).
69
+ #
70
+ # This is IPC/mmap file handoff — not zero-copy shared heap with Ruby.
71
+ #
72
+ # @param path [String] filesystem path visible to the R process
73
+ # @return [R::Object] Arrow Table proxy
74
+ def self.open_ipc(path)
75
+ path = File.expand_path(path.to_s)
76
+ ok = R::Support.eval("requireNamespace('arrow', quietly=TRUE)")
77
+ unless ok == true
78
+ raise LoadError, "R package 'arrow' is required for R::Arrow.open_ipc"
79
+ end
80
+
81
+ R.arrow___read_ipc_file(path, as_data_frame: false)
82
+ end
83
+
84
+ # Write an R Arrow Table / data.frame to an Arrow IPC file Ruby can read
85
+ # with Galaaz::ArrowIpc.read (Stage B2). Only the path should cross NewBridge.
86
+ #
87
+ # @param r_obj [R::Object] Table, RecordBatch, or data.frame/tibble in R
88
+ # @param path [String, nil] destination; default a new scratch path
89
+ # @return [String] absolute path (fsync'd from Ruby after R returns)
90
+ def self.write_ipc(r_obj, path = nil)
91
+ ok = R::Support.eval("requireNamespace('arrow', quietly=TRUE)")
92
+ unless ok == true
93
+ raise LoadError, "R package 'arrow' is required for R::Arrow.write_ipc"
94
+ end
95
+
96
+ path = path.nil? || path.to_s.empty? ? Galaaz::ArrowIpc.allocate_path : File.expand_path(path.to_s)
97
+ # uncompressed so JRuby Arrow Java can read without arrow-compression JARs
98
+ R.arrow___write_ipc_file(r_obj, path, compression: 'uncompressed')
99
+ File.open(path, 'rb') { |f| f.fsync }
100
+ path
101
+ end
102
+
66
103
  # Open a Parquet/Feather directory or file as an Arrow Dataset
67
104
  # using arrow::open_dataset().
68
105
  #
@@ -177,6 +177,21 @@ module R
177
177
  end
178
178
  end
179
179
 
180
+ # CRuby Enumerable#sum probes begin/end (range fast-path). R::Object#respond_to?
181
+ # always returns true, so that probe would hit method_missing and call R's begin.
182
+ # Implement sum in Ruby so MRI matches JRuby Enumerable behavior for blocks;
183
+ # without a block, forward to R's sum via method_missing.
184
+ def sum(*args, &block)
185
+ if block
186
+ ::Kernel.raise(::ArgumentError, "wrong number of arguments (given #{args.size}, expected 0..1)") if args.size > 1
187
+ acc = args.empty? ? 0 : args[0]
188
+ each { |el| acc = acc + block.call(el) }
189
+ acc
190
+ else
191
+ method_missing(:sum, *args)
192
+ end
193
+ end
194
+
180
195
  #--------------------------------------------------------------------------------------
181
196
  # Need to override each_with_index, as R indexing starts at 1
182
197
  #--------------------------------------------------------------------------------------