galaaz 0.5.0 → 2.1.0

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 (378) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -0
  3. data/LICENSE +0 -0
  4. data/README.md +1416 -667
  5. data/Rakefile +68 -41
  6. data/bin/galaaz-bootstrap +137 -0
  7. data/bin/galaaz-jruby +11 -0
  8. data/bin/galaaz-ruby +16 -0
  9. data/bin/galaaz_jruby_env.inc.sh +6 -0
  10. data/bin/galaaz_ruby_env.inc.sh +36 -0
  11. data/bin/gbookdown +63 -0
  12. data/bin/gknit +83 -13
  13. data/bin/gknit-draft.rb +0 -0
  14. data/bin/gstudio +5 -3
  15. data/bin/gstudio_irb.rb +0 -0
  16. data/bin/gstudio_pry.rb +0 -0
  17. data/bin/install-tinytex +6 -0
  18. data/bin/run_all_rspec +44 -0
  19. data/bin/run_example +17 -0
  20. data/bin/run_old_rspec +20 -0
  21. data/bin/run_rspec +24 -0
  22. data/bin/run_rspec_subset +38 -0
  23. data/bin/run_slow_rspec +20 -0
  24. data/blogs/R-on-Rails-Planning-Document.md +940 -0
  25. data/blogs/README.md +100 -0
  26. data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +38 -66
  27. data/blogs/galaaz_ggplot/galaaz_ggplot.log +754 -0
  28. data/blogs/galaaz_ggplot/galaaz_ggplot.md +115 -155
  29. data/blogs/galaaz_ggplot/galaaz_ggplot.tex +607 -0
  30. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-gfm/midwest_rb.png +0 -0
  31. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-gfm/scatter_plot_rb.png +0 -0
  32. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png +0 -0
  33. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png +0 -0
  34. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/midwest_rb.png +0 -0
  35. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/scatter_plot_rb.png +0 -0
  36. data/blogs/galaaz_ggplot/midwest.Rmd +3 -3
  37. data/blogs/galaaz_ggplot/midwest_external_png +0 -0
  38. data/blogs/gknit/gknit.Rmd +47 -52
  39. data/blogs/gknit/gknit.md +1430 -0
  40. data/blogs/gknit/gknit_files/figure-gfm/bubble-1.png +0 -0
  41. data/blogs/gknit/gknit_files/figure-gfm/diverging_bar.png +0 -0
  42. data/blogs/gknit/gknit_files/figure-html/bubble-1.png +0 -0
  43. data/blogs/gknit/gknit_files/figure-html/diverging_bar.png +0 -0
  44. data/blogs/gknit/lst.rds +0 -0
  45. data/blogs/gknit/model.rb +1 -1
  46. data/blogs/gknit/stats.bib +0 -0
  47. data/blogs/manual/include_model_local_repro.Rmd +14 -0
  48. data/blogs/manual/include_model_local_repro.md +75 -0
  49. data/blogs/manual/lst.rds +0 -0
  50. data/blogs/manual/manual.Rmd +855 -239
  51. data/blogs/manual/manual.log +1786 -0
  52. data/blogs/manual/manual.md +1416 -667
  53. data/blogs/manual/manual.tex +1883 -1161
  54. data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
  55. data/blogs/manual/manual_files/figure-html/diverging_bar.png +0 -0
  56. data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
  57. data/blogs/manual/model.rb +1 -1
  58. data/blogs/nse_dplyr/nse_dplyr.Rmd +84 -111
  59. data/blogs/nse_dplyr/nse_dplyr.log +928 -0
  60. data/blogs/nse_dplyr/nse_dplyr.md +198 -229
  61. data/blogs/oh_my/not_so.rb +0 -0
  62. data/blogs/oh_my/oh_my.Rmd +1234 -25
  63. data/blogs/oh_my/oh_my.log +804 -0
  64. data/blogs/oh_my/oh_my.md +1663 -86
  65. data/blogs/oh_my/oh_my.tex +821 -0
  66. data/blogs/oh_my/old.Rmd +15 -14
  67. data/blogs/ruby_plot/ruby_plot.Rmd +58 -82
  68. data/blogs/ruby_plot/ruby_plot.log +885 -0
  69. data/blogs/ruby_plot/ruby_plot.md +71 -102
  70. data/blogs/ruby_plot/ruby_plot.tex +940 -0
  71. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/dose_len.png +0 -0
  72. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facet_by_delivery.png +0 -0
  73. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facet_by_dose.png +0 -0
  74. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_by_delivery_color.png +0 -0
  75. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_by_delivery_color2.png +0 -0
  76. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_with_decorations.png +0 -0
  77. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_with_jitter.png +0 -0
  78. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/facets_with_points.png +0 -0
  79. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/final_box_plot.png +0 -0
  80. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/final_violin_plot.png +0 -0
  81. data/blogs/ruby_plot/ruby_plot_files/figure-gfm/violin_with_jitter.png +0 -0
  82. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
  83. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
  84. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
  85. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
  86. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
  87. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
  88. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
  89. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
  90. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
  91. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
  92. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
  93. data/blogs/ruby_plot/ruby_plot_files/figure-latex/dose_len.png +0 -0
  94. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
  95. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
  96. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
  97. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
  98. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
  99. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
  100. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
  101. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
  102. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
  103. data/blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
  104. data/blogs/test/test.Rmd +14 -0
  105. data/blogs/test/test.md +10 -0
  106. data/examples/50Plots_MasterList/Images/midwest-scatterplot.PNG +0 -0
  107. data/examples/50Plots_MasterList/ScatterPlot.rb +2 -1
  108. data/examples/50Plots_MasterList/scatter_plot.rb +1 -0
  109. data/examples/Bibliography/master.bib +0 -0
  110. data/examples/Bibliography/stats.bib +0 -0
  111. data/examples/R/calc.R +0 -0
  112. data/examples/R/java_interop.R +0 -0
  113. data/examples/bioconductor_deseq2_airway/Documentation/DESeq2-airway-walkthrough.md +56 -0
  114. data/examples/bioconductor_deseq2_airway/bench_galaaz_three_same_process.rb +54 -0
  115. data/examples/bioconductor_deseq2_airway/bench_r_three_same_process.R +34 -0
  116. data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb +34 -0
  117. data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz_optimized.rb +35 -0
  118. data/examples/bioconductor_deseq2_airway/deseq2_airway_minimal.R +30 -0
  119. data/examples/bioconductor_deseq2_airway/deseq2_airway_pipeline_for_bench.R +36 -0
  120. data/examples/islr/all.rb +14 -0
  121. data/examples/islr/ch2.spec.rb +38 -7
  122. data/examples/islr/ch3.spec.rb +12 -2
  123. data/examples/islr/ch3_boston.rb +28 -0
  124. data/examples/islr/ch3_multiple_regression.rb +1 -0
  125. data/examples/islr/ch6.spec.rb +25 -1
  126. data/examples/islr/x_y_rnorm.jpg +0 -0
  127. data/examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls +0 -0
  128. data/examples/latex_templates/Test-acm_article/sigproc.bib +0 -0
  129. data/examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib +0 -0
  130. data/examples/latex_templates/Test-acs_article/acs-my_output.bib +0 -0
  131. data/examples/latex_templates/Test-aea_article/BibFile.bib +0 -0
  132. data/examples/latex_templates/Test-aea_article/Test-aea_article.Rmd +0 -0
  133. data/examples/latex_templates/Test-aea_article/references.bib +0 -0
  134. data/examples/latex_templates/Test-amq_article/Test-amq_article.Rmd +0 -0
  135. data/examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync +0 -0
  136. data/examples/latex_templates/Test-ieee_article/IEEEtran.bst +0 -0
  137. data/examples/latex_templates/Test-ieee_article/mybibfile.bib +0 -0
  138. data/examples/latex_templates/Test-rjournal_article/RJournal.sty +0 -0
  139. data/examples/latex_templates/Test-rjournal_article/RJreferences.bib +0 -0
  140. data/examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd +0 -0
  141. data/examples/misc/baseball.csv +0 -0
  142. data/examples/misc/ggplot.rb +5 -3
  143. data/examples/misc/moneyball.rb +1 -0
  144. data/examples/misc/subsetting.rb +1 -0
  145. data/examples/multithread_shards_to_r/shards_to_r.rb +68 -0
  146. data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.Rmd +0 -0
  147. data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd +0 -0
  148. data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd +0 -0
  149. data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd +0 -0
  150. data/examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv +0 -0
  151. data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd +0 -0
  152. data/examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd +0 -0
  153. data/examples/sthda_ggplot/README.md +0 -0
  154. data/examples/sthda_ggplot/RUN.md +41 -0
  155. data/examples/sthda_ggplot/all.rb +1 -0
  156. data/examples/sthda_ggplot/one_variable_continuous/density_gg.rb +1 -0
  157. data/examples/sthda_ggplot/one_variable_continuous/geom_area.rb +1 -0
  158. data/examples/sthda_ggplot/one_variable_continuous/geom_density.rb +3 -0
  159. data/examples/sthda_ggplot/one_variable_continuous/geom_dotplot.rb +1 -0
  160. data/examples/sthda_ggplot/one_variable_continuous/geom_freqpoly.rb +1 -0
  161. data/examples/sthda_ggplot/one_variable_continuous/geom_histogram.rb +1 -0
  162. data/examples/sthda_ggplot/one_variable_continuous/histogram_density.rb +1 -0
  163. data/examples/sthda_ggplot/one_variable_continuous/stat.rb +1 -0
  164. data/examples/sthda_ggplot/one_variable_discrete/bar.rb +1 -0
  165. data/examples/sthda_ggplot/qplots/box_violin_dot.rb +1 -0
  166. data/examples/sthda_ggplot/qplots/scatter_plots.rb +1 -0
  167. data/examples/sthda_ggplot/scatter_gg.rb +1 -0
  168. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_bin2d.rb +1 -0
  169. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_density2d.rb +1 -0
  170. data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_hex.rb +1 -0
  171. data/examples/sthda_ggplot/two_variables_cont_cont/geom_point.rb +1 -0
  172. data/examples/sthda_ggplot/two_variables_cont_cont/geom_smooth.rb +1 -0
  173. data/examples/sthda_ggplot/two_variables_cont_cont/misc.rb +1 -0
  174. data/examples/sthda_ggplot/two_variables_cont_function/geom_area.rb +5 -3
  175. data/examples/sthda_ggplot/two_variables_disc_cont/geom_bar.rb +1 -0
  176. data/examples/sthda_ggplot/two_variables_disc_cont/geom_boxplot.rb +1 -0
  177. data/examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb +1 -0
  178. data/examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb +1 -0
  179. data/examples/sthda_ggplot/two_variables_disc_cont/geom_line.rb +1 -0
  180. data/examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb +1 -0
  181. data/examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb +1 -0
  182. data/examples/sthda_ggplot/two_variables_error/geom_crossbar.rb +1 -0
  183. data/ext/new_bridge/Makefile +46 -0
  184. data/ext/new_bridge/galaaz_gatekeeper_phase0.cpp +12 -0
  185. data/ext/new_bridge/galaaz_gatekeeper_phase1.cpp +1639 -0
  186. data/lib/R_interface/galaaz_device.R +20 -0
  187. data/lib/R_interface/include_engine.R +109 -0
  188. data/lib/R_interface/new_bridge_adapter.rb +824 -0
  189. data/lib/R_interface/r.rb +177 -25
  190. data/lib/R_interface/r_arrow.rb +113 -0
  191. data/lib/R_interface/r_libs.R +3 -3
  192. data/lib/R_interface/r_methods.rb +13 -126
  193. data/lib/R_interface/r_module_s.rb +0 -0
  194. data/lib/R_interface/rbinary_operators.rb +20 -2
  195. data/lib/R_interface/rclosure.rb +5 -1
  196. data/lib/R_interface/rdata_frame.rb +34 -70
  197. data/lib/R_interface/rdevice.rb +125 -0
  198. data/lib/R_interface/rdevices.R +0 -0
  199. data/lib/R_interface/renvironment.rb +10 -4
  200. data/lib/R_interface/rexpression.rb +5 -1
  201. data/lib/R_interface/rindexed_object.rb +41 -13
  202. data/lib/R_interface/rlanguage.rb +20 -62
  203. data/lib/R_interface/rlist.rb +115 -25
  204. data/lib/R_interface/rlogical_operators.rb +0 -0
  205. data/lib/R_interface/rmatrix.rb +2 -11
  206. data/lib/R_interface/rmd_indexed_object.rb +5 -1
  207. data/lib/R_interface/robject.rb +348 -290
  208. data/lib/R_interface/rpkg.rb +0 -0
  209. data/lib/R_interface/rsupport.rb +609 -328
  210. data/lib/R_interface/rsupport_scope.rb +2 -1
  211. data/lib/R_interface/rsymbol.rb +50 -0
  212. data/lib/R_interface/ruby_callback.rb +2 -3
  213. data/lib/R_interface/ruby_extensions.rb +225 -175
  214. data/lib/R_interface/runary_operators.rb +0 -0
  215. data/lib/R_interface/rvector.rb +162 -31
  216. data/lib/galaaz.rb +0 -0
  217. data/lib/galaaz_jruby.rb +22 -0
  218. data/lib/galaaz_ruby.rb +34 -0
  219. data/lib/gknit/diagnostics.rb +50 -0
  220. data/lib/gknit/draft.rb +23 -17
  221. data/lib/gknit/include_engine.rb +15 -7
  222. data/lib/gknit/knitr_engine.rb +223 -74
  223. data/lib/gknit/rb_engine.rb +3 -3
  224. data/lib/gknit/ruby_engine.rb +0 -0
  225. data/lib/gknit.rb +1 -0
  226. data/lib/new_bridge/bootstrap/windows_bootstrap.rb +285 -0
  227. data/lib/new_bridge/envelope.rb +51 -0
  228. data/lib/new_bridge/eval_result.rb +26 -0
  229. data/lib/new_bridge/framing.rb +39 -0
  230. data/lib/new_bridge/instance_pool_client.rb +38 -0
  231. data/lib/new_bridge/r_instance_manager.rb +404 -0
  232. data/lib/new_bridge/session_client.rb +530 -0
  233. data/lib/new_bridge/tcp_framed.rb +44 -0
  234. data/lib/new_bridge.rb +9 -0
  235. data/lib/util/exec_ruby.rb +95 -20
  236. data/lib/util/inline_file.rb +35 -30
  237. data/new_bridge_specs/benchmark_phase5_5_unboxing_spec.rb +96 -0
  238. data/new_bridge_specs/eval_r_async_spec.rb +113 -0
  239. data/new_bridge_specs/integration_phase5_1_concurrent_spec.rb +50 -0
  240. data/new_bridge_specs/integration_phase5_1_eval_spec.rb +16 -0
  241. data/new_bridge_specs/integration_phase5_1_r_api_spec.rb +25 -0
  242. data/new_bridge_specs/integration_phase5_1_smoke_spec.rb +31 -0
  243. data/new_bridge_specs/integration_phase5_2_dataframe_unboxing_spec.rb +19 -0
  244. data/new_bridge_specs/integration_phase5_2_handle_eval_unboxing_spec.rb +25 -0
  245. data/new_bridge_specs/integration_phase5_3_callback_args_spec.rb +28 -0
  246. data/new_bridge_specs/integration_phase5_3_callback_error_spec.rb +22 -0
  247. data/new_bridge_specs/integration_phase5_3_callback_timeout_spec.rb +28 -0
  248. data/new_bridge_specs/integration_phase5_3_callbacks_smoke_spec.rb +22 -0
  249. data/new_bridge_specs/integration_phase5_3_edge_cases_spec.rb +52 -0
  250. data/new_bridge_specs/integration_phase5_3_nested_spec.rb +30 -0
  251. data/new_bridge_specs/integration_phase5_4_concurrent_sessions_spec.rb +53 -0
  252. data/new_bridge_specs/integration_phase5_4_nested_session_callbacks_spec.rb +49 -0
  253. data/new_bridge_specs/integration_phase5_4_session_routing_spec.rb +38 -0
  254. data/new_bridge_specs/integration_phase5_5_stress_concurrency_spec.rb +52 -0
  255. data/new_bridge_specs/integration_phase5_5_unbox_walk_spec.rb +46 -0
  256. data/new_bridge_specs/phase0_protocol_spec.rb +96 -0
  257. data/new_bridge_specs/phase1_req_ret_spec.rb +66 -0
  258. data/new_bridge_specs/phase2_multi_instance_spec.rb +67 -0
  259. data/new_bridge_specs/phase3_callbacks_spec.rb +71 -0
  260. data/new_bridge_specs/phase4_2_hardening_spec.rb +252 -0
  261. data/new_bridge_specs/phase4_3_r_instance_manager_spec.rb +85 -0
  262. data/new_bridge_specs/phase4_nested_callbacks_spec.rb +123 -0
  263. data/r_requires/ggplot.rb +0 -0
  264. data/r_requires/knitr.rb +0 -0
  265. data/specs/all.rb +15 -11
  266. data/specs/arrow_from_ruby_batches_spec.rb +50 -0
  267. data/specs/arrow_semantics_spec.rb +64 -0
  268. data/specs/bridge_concurrent_spec.rb +46 -0
  269. data/specs/bridge_nested_spec.rb +25 -0
  270. data/specs/dataframe_semantics_spec.rb +122 -0
  271. data/specs/dataframe_single_index_logical_filter_spec.rb +21 -0
  272. data/specs/dispatch_probe_cache_spec.rb +38 -0
  273. data/specs/dispatch_probe_error_class_fallback_spec.rb +20 -0
  274. data/specs/dispatch_probe_fallback_spec.rb +18 -0
  275. data/specs/environment_semantics_spec.rb +89 -0
  276. data/specs/field_access_spec.rb +31 -0
  277. data/specs/figures/bg.jpeg +0 -0
  278. data/specs/figures/bg.png +0 -0
  279. data/specs/figures/bg.svg +168 -57
  280. data/specs/figures/dose_len.png +0 -0
  281. data/specs/figures/no_args.jpeg +0 -0
  282. data/specs/figures/no_args.png +0 -0
  283. data/specs/figures/no_args.svg +168 -57
  284. data/specs/figures/width_height.jpeg +0 -0
  285. data/specs/figures/width_height.png +0 -0
  286. data/specs/figures/width_height_units1.jpeg +0 -0
  287. data/specs/figures/width_height_units1.png +0 -0
  288. data/specs/figures/width_height_units2.jpeg +0 -0
  289. data/specs/figures/width_height_units2.png +0 -0
  290. data/specs/formula_semantics_spec.rb +81 -0
  291. data/specs/galaaz_util_exec_ruby_spec.rb +85 -0
  292. data/specs/galaaz_util_inline_file_spec.rb +54 -0
  293. data/specs/gknit_cli_option_permutation_spec.rb +24 -0
  294. data/specs/gknit_include_engine_spec.rb +72 -0
  295. data/specs/gknit_install_timeout_report_spec.rb +69 -0
  296. data/specs/gknit_internal_error_report_spec.rb +57 -0
  297. data/specs/gknit_vector_map_output_spec.rb +59 -0
  298. data/specs/globalenv_guardrail_spec.rb +52 -0
  299. data/specs/language_expression_semantics_spec.rb +145 -0
  300. data/specs/list_semantics_spec.rb +111 -0
  301. data/specs/new_bridge_bulk_dataframe_transfer_spec.rb +44 -0
  302. data/specs/new_bridge_bulk_vector_transfer_spec.rb +73 -0
  303. data/specs/new_bridge_callback_timeout_spec.rb +69 -0
  304. data/specs/new_bridge_eval_r_fallback_spec.rb +55 -0
  305. data/specs/nil_null_spec.rb +42 -0
  306. data/specs/object_build_phase2_spec.rb +53 -0
  307. data/specs/phase1_callback_bridge_spec.rb +84 -0
  308. data/specs/phase2_gknit_generic_rendering_guardrail_spec.rb +46 -0
  309. data/specs/phase2_gknit_no_raw_code_leakage_spec.rb +43 -0
  310. data/specs/phase3_gknit_generic_graphics_capture_spec.rb +71 -0
  311. data/specs/plot_device_semantics_spec.rb +28 -0
  312. data/specs/plot_snapshot_semantics_spec.rb +58 -0
  313. data/specs/protocol_result_spec.rb +236 -0
  314. data/specs/r_batch_fail_fast_spec.rb +47 -0
  315. data/specs/r_bridge_bootstrap_spec.rb +11 -0
  316. data/specs/r_devices.spec.rb +1 -1
  317. data/specs/r_eval.spec.rb +16 -18
  318. data/specs/r_function.spec.rb +1 -1
  319. data/specs/r_instance_manager_spec.rb +285 -0
  320. data/specs/r_list_apply.spec.rb +15 -15
  321. data/specs/r_matrix.spec.rb +0 -0
  322. data/specs/r_nse.spec.rb +5 -5
  323. data/specs/r_object_send_dispatch_spec.rb +13 -0
  324. data/specs/r_vector_comparator_spec.rb +8 -0
  325. data/specs/r_vector_creation.spec.rb +0 -0
  326. data/specs/r_vector_functions.spec.rb +0 -0
  327. data/specs/r_vector_object.spec.rb +0 -0
  328. data/specs/r_vector_operators.spec.rb +0 -0
  329. data/specs/r_vector_structured_scalar_reads_spec.rb +35 -0
  330. data/specs/r_vector_subsetting.spec.rb +0 -0
  331. data/specs/range_helper_spec.rb +21 -0
  332. data/specs/rsupport_scope_spec.rb +28 -0
  333. data/specs/rsupport_var_name_thread_safety_spec.rb +24 -0
  334. data/specs/scalar_character_spec.rb +44 -0
  335. data/specs/scoped_symbol_dsl_refinement_spec.rb +40 -0
  336. data/specs/session_env_bridge_spec.rb +25 -0
  337. data/specs/simplecov_bootstrap_spec.rb +10 -0
  338. data/specs/spec_helper.rb +10 -0
  339. data/specs/tmp.rb +0 -0
  340. data/specs/unboxing_recursion_regression_spec.rb +30 -0
  341. data/specs/unboxing_spec.rb +49 -0
  342. data/specs/verify_callbacks.rb +42 -0
  343. data/sty/galaaz.sty +0 -0
  344. data/version.rb +1 -1
  345. metadata +219 -63
  346. data/blogs/galaaz_ggplot/galaaz_ggplot.html +0 -520
  347. data/blogs/galaaz_ggplot/galaaz_ggplot.pdf +0 -0
  348. data/blogs/galaaz_ggplot/midwest.html +0 -188
  349. data/blogs/gknit/gknit.html +0 -2266
  350. data/blogs/gknit/gknit.pdf +0 -0
  351. data/blogs/manual/manual.html +0 -4638
  352. data/blogs/manual/manual.pdf +0 -0
  353. data/blogs/manual/manual_files/figure-latex/diverging_bar.pdf +0 -0
  354. data/blogs/nse_dplyr/nse_dplyr.html +0 -878
  355. data/blogs/nse_dplyr/nse_dplyr.pdf +0 -0
  356. data/blogs/oh_my/oh_my.html +0 -568
  357. data/blogs/ruby_plot/ruby_plot.html +0 -544
  358. data/blogs/ruby_plot/ruby_plot.pdf +0 -0
  359. data/examples/latex_templates/Test-acs_article/Test-acs_article.pdf +0 -0
  360. data/examples/latex_templates/Test-aea_article/Test-aea_article.pdf +0 -0
  361. data/examples/latex_templates/Test-amq_article/Test-amq_article.pdf +0 -0
  362. data/examples/latex_templates/Test-amq_article/pics/Figure2.pdf +0 -0
  363. data/examples/latex_templates/Test-asa_article/Test-asa_article.pdf +0 -0
  364. data/examples/latex_templates/Test-ieee_article/Test-ieee_article.pdf +0 -0
  365. data/examples/latex_templates/Test-rjournal_article/RJwrapper.pdf +0 -0
  366. data/examples/latex_templates/Test-springer_article/Test-springer_article.pdf +0 -0
  367. data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.pdf +0 -0
  368. data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.pdf +0 -0
  369. data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.pdf +0 -0
  370. data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.pdf +0 -0
  371. data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.pdf +0 -0
  372. data/specs/r_dataframe.spec.rb +0 -379
  373. data/specs/r_environment.spec.rb +0 -140
  374. data/specs/r_formula.spec.rb +0 -232
  375. data/specs/r_language.spec.rb +0 -112
  376. data/specs/r_list.spec.rb +0 -293
  377. data/specs/r_plots.spec.rb +0 -72
  378. data/specs/ruby_expression.spec.rb +0 -316
@@ -0,0 +1,14 @@
1
+ ---
2
+ title: "Minimal gknit callback test"
3
+ output: html_document
4
+ ---
5
+
6
+ ```{r setup, echo=FALSE}
7
+ # Empty setup so structure matches oh_my; first engine run is the ruby chunk below.
8
+ ```
9
+
10
+ ```{ruby fig.ext='png'}
11
+ # Minimal ruby chunk: triggers process_options and options['fig.ext'].unboxed_get(0).
12
+ # Same R code path as oh_my.Rmd first ruby chunk (sends .GlobalEnv$g2_vN <- g2_vM[[1]] for fig.ext).
13
+ puts "ok"
14
+ ```
@@ -0,0 +1,10 @@
1
+ Minimal gknit callback test
2
+ ================
3
+
4
+ ``` ruby
5
+ # Minimal ruby chunk: triggers process_options and options['fig.ext'].unboxed_get(0).
6
+ # Same R code path as oh_my.Rmd first ruby chunk (sends .GlobalEnv$g2_vN <- g2_vM[[1]] for fig.ext).
7
+ puts "ok"
8
+ ```
9
+
10
+ ## ok
@@ -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 CorpTheme
@@ -156,4 +157,4 @@ sp.add_smoothing_line(method: "glm")
156
157
  sp.plot
157
158
 
158
159
 
159
- a = gets.chomp
160
+ a = gets.chomp if $stdin.tty?
@@ -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 package and data
File without changes
File without changes
data/examples/R/calc.R CHANGED
File without changes
File without changes
@@ -0,0 +1,56 @@
1
+ # DESeq2 Airway Walkthrough (Bioconductor + galaaz)
2
+
3
+ This document defines the first Bioconductor example we will implement with `galaaz`.
4
+
5
+ ## Goal
6
+
7
+ Run a canonical differential expression analysis from Bioconductor using `DESeq2` and the `airway` dataset, then validate that the workflow executes correctly with `galaaz`.
8
+
9
+ ## Scope
10
+
11
+ - Focus on workflow execution and interoperability.
12
+ - Install Bioconductor dependencies directly in R (outside `galaaz`).
13
+ - Keep biological interpretation minimal for this first example.
14
+
15
+ ## Precondition
16
+
17
+ Before running this example in `galaaz`, install and verify in R:
18
+
19
+ - `BiocManager`
20
+ - `DESeq2`
21
+ - `airway`
22
+
23
+ ## Primer (what we are doing)
24
+
25
+ - RNA-seq count data contains integer read counts per gene and per sample.
26
+ - We compare treated vs untreated samples to find genes with significant changes.
27
+ - `DESeq2` models count data and returns:
28
+ - `log2FoldChange` (effect size)
29
+ - `pvalue`
30
+ - `padj` (multiple-testing corrected p-value)
31
+
32
+ ## Planned Workflow
33
+
34
+ 1. Load `DESeq2` and `airway`.
35
+ 2. Load airway data and inspect counts plus sample metadata.
36
+ 3. Define a design formula for condition effect (with relevant covariate if used in canonical example).
37
+ 4. Build a `DESeqDataSet` object.
38
+ 5. Pre-filter low-count genes.
39
+ 6. Run `DESeq()` to fit the model.
40
+ 7. Extract `results()` for the treatment comparison.
41
+ 8. Sort and inspect top hits by adjusted p-value.
42
+ 9. Produce one standard QC/result plot (for example `plotMA`).
43
+
44
+ ## Validation Checks
45
+
46
+ - Packages load without runtime errors in the target environment.
47
+ - `DESeqDataSet` object is created successfully.
48
+ - `DESeq()` completes.
49
+ - `results()` returns expected columns and non-empty output.
50
+ - At least one standard DESeq2 plot call runs successfully.
51
+
52
+ ## Out of Scope (for now)
53
+
54
+ - Installing packages via `galaaz`.
55
+ - Performance tuning or optimization.
56
+ - Deep biological interpretation of gene-level findings.
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Run a galaaz DESeq2 airway example three times in one JRuby process (warm-up semantics).
4
+ #
5
+ # Usage (from repository root):
6
+ # bin/galaaz-jruby examples/bioconductor_deseq2_airway/bench_galaaz_three_same_process.rb
7
+ # bin/galaaz-jruby examples/bioconductor_deseq2_airway/bench_galaaz_three_same_process.rb optimized
8
+ # bin/galaaz-jruby examples/bioconductor_deseq2_airway/bench_galaaz_three_same_process.rb original
9
+
10
+ require 'galaaz'
11
+
12
+ using Galaaz::SymbolDSL
13
+ root = File.expand_path('../..', __dir__)
14
+ Dir.chdir(root)
15
+
16
+ variant = (ARGV[0] || 'optimized').downcase
17
+ script = case variant
18
+ when 'original'
19
+ 'deseq2_airway_galaaz.rb'
20
+ when 'optimized'
21
+ 'deseq2_airway_galaaz_optimized.rb'
22
+ else
23
+ warn "Unknown variant #{variant.inspect}; use 'optimized' or 'original'"
24
+ exit 1
25
+ end
26
+
27
+ path = File.expand_path(script, __dir__)
28
+
29
+ unless File.file?(path)
30
+ warn "Missing #{path}"
31
+ exit 1
32
+ end
33
+
34
+ puts "=== galaaz (#{variant}): three runs, same process (root: #{root})"
35
+ times = []
36
+ 3.times do |i|
37
+ t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
38
+ load path
39
+ t1 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
40
+ sec = t1 - t0
41
+ times << sec
42
+ puts format('galaaz run %d/3: %.2f s', i + 1, sec)
43
+ end
44
+
45
+ warm = times[1..2]
46
+ ws = warm.sort
47
+ warm_median = (ws[0] + ws[1]) / 2.0
48
+ all_sorted = times.sort
49
+ all_median = all_sorted[1]
50
+
51
+ puts '---'
52
+ puts format('Warm median (runs 2–3): %.2f s', warm_median)
53
+ puts format('Warm mean (runs 2–3): %.2f s', warm.sum / warm.size)
54
+ puts format('All-run median: %.2f s', all_median)
@@ -0,0 +1,34 @@
1
+ # Run the DESeq2 airway pipeline three times in a single R process (fair vs galaaz warm-up).
2
+ #
3
+ # Usage (from repository root):
4
+ # Rscript examples/bioconductor_deseq2_airway/bench_r_three_same_process.R
5
+ # Rscript examples/bioconductor_deseq2_airway/bench_r_three_same_process.R /path/to/galaaz
6
+
7
+ args <- commandArgs(trailingOnly = TRUE)
8
+ root <- if (length(args) >= 1L) {
9
+ normalizePath(args[[1L]], winslash = "/", mustWork = TRUE)
10
+ } else {
11
+ normalizePath(getwd(), winslash = "/", mustWork = TRUE)
12
+ }
13
+
14
+ Sys.setenv(GALAAZ_BENCH_ROOT = root)
15
+ pipeline <- file.path(root, "examples/bioconductor_deseq2_airway/deseq2_airway_pipeline_for_bench.R")
16
+ if (!file.exists(pipeline)) {
17
+ stop("Pipeline not found: ", pipeline, " (wrong GALAAZ_BENCH_ROOT?)")
18
+ }
19
+
20
+ cat("=== R: three runs, same process (repository root:", root, ")\n", sep = "")
21
+ times <- numeric(3L)
22
+ for (i in seq_len(3L)) {
23
+ st <- system.time({
24
+ sys.source(pipeline, envir = new.env(parent = globalenv()), keep.source = FALSE)
25
+ }, gcFirst = FALSE)
26
+ times[[i]] <- unname(st[["elapsed"]])
27
+ cat(sprintf("R run %d/3: %.2f s\n", i, times[[i]]))
28
+ }
29
+
30
+ warm <- times[2:3]
31
+ cat("---\n")
32
+ cat(sprintf("Warm median (runs 2–3): %.2f s\n", stats::median(warm)))
33
+ cat(sprintf("Warm mean (runs 2–3): %.2f s\n", mean(warm)))
34
+ cat(sprintf("All-run median: %.2f s\n", stats::median(times)))
@@ -0,0 +1,34 @@
1
+ require 'galaaz'
2
+
3
+ using Galaaz::SymbolDSL
4
+ R.library('DESeq2')
5
+ R.library('airway')
6
+ R.data('airway')
7
+
8
+ airway = ~:airway
9
+
10
+ # Build DESeq2 dataset with one-sided formula: ~ cell + dex.
11
+ dds = R.DESeqDataSet(airway, design: (:all.til :cell + :dex))
12
+
13
+ # Prefilter genes with almost no counts.
14
+ keep = R.rowSums(R.counts(dds)) >= 10
15
+ dds = dds[keep, :all]
16
+
17
+ # Fit DE model and extract treatment effect.
18
+ dds = R.DESeq(dds)
19
+ res = R.results(dds, contrast: R.c('dex', 'trt', 'untrt'))
20
+
21
+ # Compact sanity outputs for quick verification.
22
+ puts "Samples: #{R.ncol(dds)}"
23
+ puts "Genes after prefilter: #{R.nrow(dds)}"
24
+ puts "Result rows: #{R.nrow(res)}"
25
+ puts "Result columns: #{R.colnames(res)}"
26
+ puts "Significant genes (padj < 0.05): #{R.sum(res.padj < 0.05, na__rm: true)}"
27
+
28
+ res_ordered = res[R.order(res.padj), :all]
29
+ puts R.head(R.as__data__frame(res_ordered), 10)
30
+
31
+ # Standard DESeq2 plot call written to file.
32
+ R.pdf('examples/bioconductor_deseq2_airway/plotMA_galaaz.pdf')
33
+ R.plotMA(res, ylim: R.c(-5, 5))
34
+ R.dev__off
@@ -0,0 +1,35 @@
1
+ require 'galaaz'
2
+
3
+ using Galaaz::SymbolDSL
4
+ R.library('DESeq2')
5
+ R.library('airway')
6
+ R.data('airway')
7
+
8
+ airway = ~:airway
9
+
10
+ # Build DESeq2 dataset with one-sided formula: ~ cell + dex.
11
+ dds = R.DESeqDataSet(airway, design: (:all.til :cell + :dex))
12
+
13
+ # Prefilter genes with almost no counts.
14
+ keep = R.rowSums(R.counts(dds)) >= 10
15
+ dds = dds[keep, :all]
16
+
17
+ # Fit DE model and extract treatment effect.
18
+ dds = R.DESeq(dds)
19
+ res = R.results(dds, contrast: R.c('dex', 'trt', 'untrt'))
20
+
21
+ # Ruby-style optimization: delegate object rendering to R print/cat.
22
+ padj = res.padj
23
+ res_ordered = res[R.order(padj), :all]
24
+
25
+ R.cat('Samples:', R.ncol(dds), '\n')
26
+ R.cat('Genes after prefilter:', R.nrow(dds), '\n')
27
+ R.cat('Result rows:', R.nrow(res), '\n')
28
+ R.cat('Result columns:', R.paste(R.colnames(res), collapse: ', '), '\n')
29
+ R.cat('Significant genes (padj < 0.05):', R.sum(padj < 0.05, na__rm: true), '\n')
30
+ R.print(R.head(res_ordered, 10))
31
+
32
+ # Standard DESeq2 plot call written to file.
33
+ R.pdf('examples/bioconductor_deseq2_airway/plotMA_galaaz_optimized.pdf')
34
+ R.plotMA(res, ylim: R.c(-5, 5))
35
+ R.dev__off
@@ -0,0 +1,30 @@
1
+ library(DESeq2)
2
+ library(airway)
3
+
4
+ # Load canonical airway example data.
5
+ data(airway)
6
+ airway$dex <- relevel(airway$dex, ref = "untrt")
7
+
8
+ # Build DESeq2 dataset using cell line as covariate and dex as treatment.
9
+ dds <- DESeqDataSet(airway, design = ~ cell + dex)
10
+
11
+ # Prefilter genes with almost no counts.
12
+ keep <- rowSums(counts(dds)) >= 10
13
+ dds <- dds[keep, ]
14
+
15
+ # Fit DE model and extract treatment effect.
16
+ dds <- DESeq(dds)
17
+ res <- results(dds, contrast = c("dex", "trt", "untrt"))
18
+
19
+ # Compact sanity outputs for quick verification.
20
+ cat("Samples:", ncol(dds), "\n")
21
+ cat("Genes after prefilter:", nrow(dds), "\n")
22
+ cat("Result rows:", nrow(res), "\n")
23
+ cat("Result columns:", paste(colnames(res), collapse = ", "), "\n")
24
+ cat("Significant genes (padj < 0.05):", sum(res$padj < 0.05, na.rm = TRUE), "\n")
25
+
26
+ res_ordered <- res[order(res$padj), ]
27
+ print(head(as.data.frame(res_ordered), 10))
28
+
29
+ # Standard DESeq2 plot call used in the walkthrough.
30
+ plotMA(res, ylim = c(-5, 5))
@@ -0,0 +1,36 @@
1
+ # DESeq2 airway pipeline for timing benchmarks.
2
+ # Logic matches deseq2_airway_minimal.R; plot goes to PDF like the galaaz examples
3
+ # (avoids default graphics device variance in headless/automated runs).
4
+ #
5
+ # Not loaded by default from other examples — use only via bench_r_three_same_process.R.
6
+
7
+ library(DESeq2)
8
+ library(airway)
9
+
10
+ data(airway)
11
+ airway$dex <- relevel(airway$dex, ref = "untrt")
12
+
13
+ dds <- DESeqDataSet(airway, design = ~ cell + dex)
14
+
15
+ keep <- rowSums(counts(dds)) >= 10
16
+ dds <- dds[keep, ]
17
+
18
+ dds <- DESeq(dds)
19
+ res <- results(dds, contrast = c("dex", "trt", "untrt"))
20
+
21
+ cat("Samples:", ncol(dds), "\n")
22
+ cat("Genes after prefilter:", nrow(dds), "\n")
23
+ cat("Result rows:", nrow(res), "\n")
24
+ cat("Result columns:", paste(colnames(res), collapse = ", "), "\n")
25
+ cat("Significant genes (padj < 0.05):", sum(res$padj < 0.05, na.rm = TRUE), "\n")
26
+
27
+ res_ordered <- res[order(res$padj), ]
28
+ print(head(as.data.frame(res_ordered), 10))
29
+
30
+ root <- Sys.getenv("GALAAZ_BENCH_ROOT", unset = "")
31
+ if (!nzchar(root)) {
32
+ stop("Set GALAAZ_BENCH_ROOT to the galaaz repository root before sourcing this file (see bench_r_three_same_process.R).")
33
+ }
34
+ pdf(file.path(root, "examples/bioconductor_deseq2_airway/plotMA_bench_R.pdf"))
35
+ plotMA(res, ylim = c(-5, 5))
36
+ invisible(dev.off())
data/examples/islr/all.rb CHANGED
@@ -22,11 +22,25 @@
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
28
29
  R.install_and_loads('ISLR', 'MASS')
29
30
 
31
+ def galaaz_islr_all_debug(msg)
32
+ STDERR.puts "[DEBUG islr][all] #{Time.now.strftime('%H:%M:%S')} #{msg}"
33
+ STDERR.flush
34
+ end
35
+
36
+ galaaz_islr_all_debug('before require ch2.spec')
30
37
  require_relative 'ch2.spec'
38
+ galaaz_islr_all_debug('after require ch2.spec')
39
+
40
+ galaaz_islr_all_debug('before require ch3.spec')
31
41
  require_relative 'ch3.spec'
42
+ galaaz_islr_all_debug('after require ch3.spec')
43
+
44
+ galaaz_islr_all_debug('before require ch6.spec')
32
45
  require_relative 'ch6.spec'
46
+ galaaz_islr_all_debug('after require ch6.spec')
@@ -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
@@ -69,8 +70,11 @@ context "ISLR" do
69
70
  R.set__seed(3)
70
71
  x = R.rnorm(50)
71
72
  y = x + R.rnorm(50, mean: 40, sd: 0.1)
72
- expect(R.cor(x, y).all__equal(0.995717314227608)).to eq true
73
- expect(x.cor(y).all__equal(0.995717314227608)).to eq true
73
+ cor_xy = R.cor(x, y)
74
+ expected = 0.995717314227608
75
+ expect(cor_xy.respond_to?(:all__equal) ? cor_xy.all__equal(expected) : (cor_xy - expected).abs < 1e-9).to eq true
76
+ cor_xy2 = x.cor(y)
77
+ expect(cor_xy2.respond_to?(:all__equal) ? cor_xy2.all__equal(expected) : (cor_xy2 - expected).abs < 1e-9).to eq true
74
78
  end
75
79
 
76
80
  it "should allow to setting the seed" do
@@ -84,16 +88,24 @@ context "ISLR" do
84
88
  it "should calculate the mean" do
85
89
  R.set__seed(3)
86
90
  y = R.rnorm(100)
87
- expect(y.mean.all__equal(0.0110355710)).to eq true
91
+ m = y.mean
92
+ expect(m.respond_to?(:all__equal) ? m.all__equal(0.0110355710) : (m - 0.0110355710).abs < 1e-9).to eq true
88
93
  end
89
94
 
90
95
  it "should calculate the variance" do
91
96
  R.set__seed(3)
92
97
  y = R.rnorm(100)
93
-
94
- expect(y.var.all__equal(0.732867501277449)).to eq true
95
- expect(y.var.sqrt.all__equal(0.856076808047881)).to eq true
96
- expect(y.sd.all__equal(0.856076808047881)).to eq true
98
+ v = y.var
99
+ sd = y.sd
100
+ expected_var = 0.732867501277449
101
+ expected_sd = 0.856076808047881
102
+ expect(v.respond_to?(:all__equal) ? v.all__equal(expected_var) : (v - expected_var).abs < 1e-9).to eq true
103
+ expect(sd.respond_to?(:all__equal) ? sd.all__equal(expected_sd) : (sd - expected_sd).abs < 1e-9).to eq true
104
+ # var.sqrt should match sd when both are available
105
+ if v.respond_to?(:sqrt)
106
+ s = v.sqrt
107
+ expect(s.respond_to?(:all__equal) ? s.all__equal(expected_sd) : (s - expected_sd).abs < 1e-9).to eq true
108
+ end
97
109
  end
98
110
 
99
111
  end
@@ -101,8 +113,15 @@ context "ISLR" do
101
113
  context "Chapter 2 - Graphics" do
102
114
 
103
115
  it "should plot graphics" do
116
+ def galaaz_islr_debug(msg)
117
+ STDERR.puts "[DEBUG islr][ch2.spec][#{Time.now.strftime('%H:%M:%S')}] #{msg}"
118
+ STDERR.flush
119
+ end
120
+
104
121
  # To see the graphic we need to set the device to awt
122
+ galaaz_islr_debug 'before R.awt'
105
123
  R.awt
124
+ galaaz_islr_debug 'after R.awt'
106
125
  x = R.rnorm(100)
107
126
  y = R.rnorm(100)
108
127
  # plot commands do not work. Need to work with ggplot or grid
@@ -113,16 +132,28 @@ context "ISLR" do
113
132
  ylab: "this is the y-axis",
114
133
  main: "Plot of X vs Y")
115
134
  .print
135
+ galaaz_islr_debug 'after qplot.print'
116
136
  # the graphics dies when the script ends... waiting 3 secs
117
137
  # so that the graphic can be seen
138
+ galaaz_islr_debug 'before sleep(3)'
118
139
  sleep(3)
140
+ galaaz_islr_debug 'after sleep(3)'
141
+ R.dev__off
119
142
  end
120
143
 
121
144
  it "should create a jpeg file" do
145
+ def galaaz_islr_debug(msg)
146
+ STDERR.puts "[DEBUG islr][ch2.spec][#{Time.now.strftime('%H:%M:%S')}] #{msg}"
147
+ STDERR.flush
148
+ end
149
+
150
+ galaaz_islr_debug 'jpeg test: start'
122
151
  R.jpeg("/home/rbotafogo/desenv/galaaz/examples/islr/x_y_rnorm.jpg")
123
152
  R.df = R.data__frame(x: R.rnorm(100), y: R.rnorm(100))
153
+ galaaz_islr_debug 'jpeg test: about to qplot'
124
154
  puts R.qplot(:x, :y, data: :df, col: "green")
125
155
  R.dev__off
156
+ galaaz_islr_debug 'jpeg test: after R.dev__off'
126
157
  end
127
158
 
128
159
  it "creates sequences with 'seq'" do
@@ -22,7 +22,17 @@
22
22
  ##########################################################################################
23
23
 
24
24
  require 'galaaz'
25
+ using Galaaz::SymbolDSL
25
26
  require 'ggplot'
26
27
 
27
- require_relative 'ch3_boston'
28
- require_relative 'ch3_multiple_regression'
28
+ context "ISLR" do
29
+ context "Chapter 3 - Lab" do
30
+ it "runs ch3_boston (graphics + regression)" do
31
+ load File.expand_path('ch3_boston.rb', __dir__)
32
+ end
33
+
34
+ it "runs ch3_multiple_regression (non-linear transformations)" do
35
+ load File.expand_path('ch3_multiple_regression.rb', __dir__)
36
+ end
37
+ end
38
+ end
@@ -21,16 +21,28 @@
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')
27
28
 
29
+ # Minimal breadcrumb logging to understand where the script gets stuck
30
+ # when running `rake islr:all` (chapters are executed as scripts).
31
+ def galaaz_islr_debug(msg)
32
+ STDERR.puts "[DEBUG islr][ch3_boston] #{Time.now.strftime('%H:%M:%S')} #{msg}"
33
+ STDERR.flush
34
+ end
35
+
28
36
  # Simple linear regression from ISLR book. Chapter 3 Lab
29
37
  # We are using qplot for plotting. It would be better to use
30
38
  # ggplot2, but this is just to show simple ploting.
31
39
 
32
40
  # load boston data frame on variable boston
41
+ bala = nil
42
+ bala2 = nil
43
+ galaaz_islr_debug('start; loading Boston')
33
44
  boston = ~:Boston
45
+ galaaz_islr_debug('Boston loaded; printing names/lm')
34
46
 
35
47
  puts boston.names
36
48
 
@@ -49,7 +61,9 @@ puts pred
49
61
  puts boston.lstat
50
62
  puts boston.medv
51
63
 
64
+ galaaz_islr_debug('before R.awt')
52
65
  R.awt
66
+ galaaz_islr_debug('after R.awt; before first plot')
53
67
 
54
68
  puts R.qplot(:lstat, :medv, data: :Boston, col: "red") +
55
69
  R.geom_abline(intercept: boston_lm.coef[1],
@@ -62,25 +76,39 @@ puts R.qplot(:lstat, :medv, data: :Boston, col: "red") +
62
76
  # a = gets.chomp
63
77
 
64
78
  # sleep two seconds so that the graph shows up
79
+ galaaz_islr_debug('sleep(2) after first plot')
65
80
  sleep(2)
81
+ galaaz_islr_debug('grid__newpage #1')
66
82
  R.grid__newpage
67
83
 
84
+ galaaz_islr_debug('building my_data #2 and plotting #2')
68
85
  R.my_data = R.data__frame(pred: R.predict(boston_lm), res: R.residuals(boston_lm))
69
86
  puts R.qplot(:pred, :res, data: :my_data)
70
87
 
88
+ galaaz_islr_debug('sleep(2) after plot #2')
71
89
  sleep(2)
90
+ galaaz_islr_debug('grid__newpage #2')
72
91
  R.grid__newpage
73
92
 
93
+ galaaz_islr_debug('building my_data #3 and plotting #3')
74
94
  R.my_data = R.data__frame(pred: R.predict(boston_lm), res: R.rstudent(boston_lm))
75
95
  puts R.qplot(:pred, :res, data: :my_data)
76
96
 
97
+ galaaz_islr_debug('sleep(2) after plot #3')
77
98
  sleep(2)
99
+ galaaz_islr_debug('grid__newpage #3')
78
100
  R.grid__newpage
79
101
 
102
+ galaaz_islr_debug('hatvalues + plotting #4')
80
103
  vals = R.hatvalues(boston_lm)
81
104
  R.my_data = R.data__frame(size: (1..vals.size), values: vals)
82
105
  # method size returns a Numeric... size is equivalent to 'length << 0'
83
106
  puts R.qplot(:size, :values, data: :my_data)
84
107
 
108
+ galaaz_islr_debug('sleep(2) after plot #4')
85
109
  sleep(2)
110
+ galaaz_islr_debug('grid__newpage #4')
86
111
  R.grid__newpage
112
+
113
+ # Close the graphics device so later chapters don't keep an open AWT window.
114
+ R.dev__off