galaaz 0.5.0 → 2.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/LICENSE +0 -0
- data/README.md +1360 -636
- data/Rakefile +61 -41
- data/bin/galaaz-bootstrap +137 -0
- data/bin/galaaz-jruby +14 -0
- data/bin/galaaz_jruby_env.inc.sh +6 -0
- data/bin/gbookdown +64 -0
- data/bin/gknit +84 -13
- data/bin/gknit-draft.rb +0 -0
- data/bin/gstudio +5 -3
- data/bin/gstudio_irb.rb +0 -0
- data/bin/gstudio_pry.rb +0 -0
- data/bin/install-tinytex +6 -0
- data/bin/run_all_rspec +43 -0
- data/bin/run_example +14 -0
- data/bin/run_old_rspec +19 -0
- data/bin/run_rspec +23 -0
- data/bin/run_rspec_subset +38 -0
- data/bin/run_slow_rspec +19 -0
- data/blogs/R-on-Rails-Planning-Document.md +940 -0
- data/blogs/README.md +100 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +38 -66
- data/blogs/galaaz_ggplot/galaaz_ggplot.log +754 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot.md +115 -155
- data/blogs/galaaz_ggplot/galaaz_ggplot.tex +607 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/midwest_rb.png +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/scatter_plot_rb.png +0 -0
- data/blogs/galaaz_ggplot/midwest.Rmd +3 -3
- data/blogs/galaaz_ggplot/midwest_external_png +0 -0
- data/blogs/gknit/gknit.Rmd +47 -52
- data/blogs/gknit/gknit.md +1430 -0
- data/blogs/gknit/gknit_files/figure-html/bubble-1.png +0 -0
- data/blogs/gknit/gknit_files/figure-html/diverging_bar.png +0 -0
- data/blogs/gknit/lst.rds +0 -0
- data/blogs/gknit/model.rb +1 -1
- data/blogs/gknit/stats.bib +0 -0
- data/blogs/manual/include_model_local_repro.Rmd +14 -0
- data/blogs/manual/include_model_local_repro.md +75 -0
- data/blogs/manual/lst.rds +0 -0
- data/blogs/manual/manual.Rmd +852 -239
- data/blogs/manual/manual.log +1786 -0
- data/blogs/manual/manual.md +1360 -636
- data/blogs/manual/manual.tex +1883 -1161
- data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
- data/blogs/manual/manual_files/figure-html/diverging_bar.png +0 -0
- data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
- data/blogs/manual/model.rb +1 -1
- data/blogs/nse_dplyr/nse_dplyr.Rmd +84 -111
- data/blogs/nse_dplyr/nse_dplyr.log +928 -0
- data/blogs/nse_dplyr/nse_dplyr.md +198 -229
- data/blogs/oh_my/not_so.rb +0 -0
- data/blogs/oh_my/oh_my.Rmd +1234 -25
- data/blogs/oh_my/oh_my.log +804 -0
- data/blogs/oh_my/oh_my.md +1663 -86
- data/blogs/oh_my/oh_my.tex +821 -0
- data/blogs/oh_my/old.Rmd +15 -14
- data/blogs/ruby_plot/ruby_plot.Rmd +58 -82
- data/blogs/ruby_plot/ruby_plot.log +885 -0
- data/blogs/ruby_plot/ruby_plot.md +71 -102
- data/blogs/ruby_plot/ruby_plot.tex +940 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/dose_len.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
- data/blogs/test/test.Rmd +14 -0
- data/examples/50Plots_MasterList/Images/midwest-scatterplot.PNG +0 -0
- data/examples/50Plots_MasterList/ScatterPlot.rb +0 -0
- data/examples/50Plots_MasterList/scatter_plot.rb +0 -0
- data/examples/Bibliography/master.bib +0 -0
- data/examples/Bibliography/stats.bib +0 -0
- data/examples/R/calc.R +0 -0
- data/examples/R/java_interop.R +0 -0
- data/examples/bioconductor_deseq2_airway/Documentation/DESeq2-airway-walkthrough.md +56 -0
- data/examples/bioconductor_deseq2_airway/bench_galaaz_three_same_process.rb +53 -0
- data/examples/bioconductor_deseq2_airway/bench_r_three_same_process.R +34 -0
- data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz.rb +33 -0
- data/examples/bioconductor_deseq2_airway/deseq2_airway_galaaz_optimized.rb +34 -0
- data/examples/bioconductor_deseq2_airway/deseq2_airway_minimal.R +30 -0
- data/examples/bioconductor_deseq2_airway/deseq2_airway_pipeline_for_bench.R +36 -0
- data/examples/islr/all.rb +13 -0
- data/examples/islr/ch2.spec.rb +37 -7
- data/examples/islr/ch3.spec.rb +11 -2
- data/examples/islr/ch3_boston.rb +27 -0
- data/examples/islr/ch3_multiple_regression.rb +0 -0
- data/examples/islr/ch6.spec.rb +24 -1
- data/examples/islr/x_y_rnorm.jpg +0 -0
- data/examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls +0 -0
- data/examples/latex_templates/Test-acm_article/sigproc.bib +0 -0
- data/examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib +0 -0
- data/examples/latex_templates/Test-acs_article/acs-my_output.bib +0 -0
- data/examples/latex_templates/Test-aea_article/BibFile.bib +0 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.Rmd +0 -0
- data/examples/latex_templates/Test-aea_article/references.bib +0 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.Rmd +0 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync +0 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.bst +0 -0
- data/examples/latex_templates/Test-ieee_article/mybibfile.bib +0 -0
- data/examples/latex_templates/Test-rjournal_article/RJournal.sty +0 -0
- data/examples/latex_templates/Test-rjournal_article/RJreferences.bib +0 -0
- data/examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd +0 -0
- data/examples/misc/baseball.csv +0 -0
- data/examples/misc/ggplot.rb +3 -2
- data/examples/misc/moneyball.rb +0 -0
- data/examples/misc/subsetting.rb +0 -0
- data/examples/multithread_shards_to_r/shards_to_r.rb +67 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.Rmd +0 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd +0 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd +0 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd +0 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv +0 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd +0 -0
- data/examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd +0 -0
- data/examples/sthda_ggplot/README.md +0 -0
- data/examples/sthda_ggplot/RUN.md +41 -0
- data/examples/sthda_ggplot/all.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/density_gg.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_area.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_density.rb +2 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_dotplot.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_freqpoly.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/geom_histogram.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/histogram_density.rb +0 -0
- data/examples/sthda_ggplot/one_variable_continuous/stat.rb +0 -0
- data/examples/sthda_ggplot/one_variable_discrete/bar.rb +0 -0
- data/examples/sthda_ggplot/qplots/box_violin_dot.rb +0 -0
- data/examples/sthda_ggplot/qplots/scatter_plots.rb +0 -0
- data/examples/sthda_ggplot/scatter_gg.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_bin2d.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_density2d.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_bivariate/geom_hex.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/geom_point.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/geom_smooth.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_cont/misc.rb +0 -0
- data/examples/sthda_ggplot/two_variables_cont_function/geom_area.rb +4 -3
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_bar.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_boxplot.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_dotplot.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_jitter.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_line.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_cont/geom_violin.rb +0 -0
- data/examples/sthda_ggplot/two_variables_disc_disc/geom_jitter.rb +0 -0
- data/examples/sthda_ggplot/two_variables_error/geom_crossbar.rb +0 -0
- data/ext/new_bridge/Makefile +46 -0
- data/ext/new_bridge/galaaz_gatekeeper_phase0.cpp +12 -0
- data/ext/new_bridge/galaaz_gatekeeper_phase1.cpp +1639 -0
- data/lib/R_interface/galaaz_device.R +20 -0
- data/lib/R_interface/include_engine.R +109 -0
- data/lib/R_interface/new_bridge_adapter.rb +824 -0
- data/lib/R_interface/r.rb +177 -25
- data/lib/R_interface/r_arrow.rb +113 -0
- data/lib/R_interface/r_libs.R +3 -3
- data/lib/R_interface/r_methods.rb +13 -126
- data/lib/R_interface/r_module_s.rb +0 -0
- data/lib/R_interface/rbinary_operators.rb +20 -2
- data/lib/R_interface/rclosure.rb +5 -1
- data/lib/R_interface/rdata_frame.rb +34 -70
- data/lib/R_interface/rdevice.rb +125 -0
- data/lib/R_interface/rdevices.R +0 -0
- data/lib/R_interface/renvironment.rb +10 -4
- data/lib/R_interface/rexpression.rb +5 -1
- data/lib/R_interface/rindexed_object.rb +41 -13
- data/lib/R_interface/rlanguage.rb +20 -62
- data/lib/R_interface/rlist.rb +115 -25
- data/lib/R_interface/rlogical_operators.rb +0 -0
- data/lib/R_interface/rmatrix.rb +2 -11
- data/lib/R_interface/rmd_indexed_object.rb +5 -1
- data/lib/R_interface/robject.rb +348 -290
- data/lib/R_interface/rpkg.rb +0 -0
- data/lib/R_interface/rsupport.rb +609 -328
- data/lib/R_interface/rsupport_scope.rb +2 -1
- data/lib/R_interface/rsymbol.rb +50 -0
- data/lib/R_interface/ruby_callback.rb +2 -3
- data/lib/R_interface/ruby_extensions.rb +225 -175
- data/lib/R_interface/runary_operators.rb +0 -0
- data/lib/R_interface/rvector.rb +147 -31
- data/lib/galaaz.rb +0 -0
- data/lib/galaaz_jruby.rb +22 -0
- data/lib/gknit/diagnostics.rb +50 -0
- data/lib/gknit/draft.rb +23 -17
- data/lib/gknit/include_engine.rb +15 -7
- data/lib/gknit/knitr_engine.rb +223 -74
- data/lib/gknit/rb_engine.rb +3 -3
- data/lib/gknit/ruby_engine.rb +0 -0
- data/lib/gknit.rb +1 -0
- data/lib/new_bridge/bootstrap/windows_bootstrap.rb +285 -0
- data/lib/new_bridge/envelope.rb +51 -0
- data/lib/new_bridge/eval_result.rb +26 -0
- data/lib/new_bridge/framing.rb +39 -0
- data/lib/new_bridge/instance_pool_client.rb +38 -0
- data/lib/new_bridge/r_instance_manager.rb +404 -0
- data/lib/new_bridge/session_client.rb +530 -0
- data/lib/new_bridge/tcp_framed.rb +44 -0
- data/lib/new_bridge.rb +9 -0
- data/lib/util/exec_ruby.rb +95 -20
- data/lib/util/inline_file.rb +35 -30
- data/new_bridge_specs/benchmark_phase5_5_unboxing_spec.rb +96 -0
- data/new_bridge_specs/eval_r_async_spec.rb +113 -0
- data/new_bridge_specs/integration_phase5_1_concurrent_spec.rb +50 -0
- data/new_bridge_specs/integration_phase5_1_eval_spec.rb +16 -0
- data/new_bridge_specs/integration_phase5_1_r_api_spec.rb +25 -0
- data/new_bridge_specs/integration_phase5_1_smoke_spec.rb +31 -0
- data/new_bridge_specs/integration_phase5_2_dataframe_unboxing_spec.rb +19 -0
- data/new_bridge_specs/integration_phase5_2_handle_eval_unboxing_spec.rb +25 -0
- data/new_bridge_specs/integration_phase5_3_callback_args_spec.rb +28 -0
- data/new_bridge_specs/integration_phase5_3_callback_error_spec.rb +22 -0
- data/new_bridge_specs/integration_phase5_3_callback_timeout_spec.rb +28 -0
- data/new_bridge_specs/integration_phase5_3_callbacks_smoke_spec.rb +22 -0
- data/new_bridge_specs/integration_phase5_3_edge_cases_spec.rb +52 -0
- data/new_bridge_specs/integration_phase5_3_nested_spec.rb +30 -0
- data/new_bridge_specs/integration_phase5_4_concurrent_sessions_spec.rb +53 -0
- data/new_bridge_specs/integration_phase5_4_nested_session_callbacks_spec.rb +49 -0
- data/new_bridge_specs/integration_phase5_4_session_routing_spec.rb +38 -0
- data/new_bridge_specs/integration_phase5_5_stress_concurrency_spec.rb +52 -0
- data/new_bridge_specs/integration_phase5_5_unbox_walk_spec.rb +46 -0
- data/new_bridge_specs/phase0_protocol_spec.rb +96 -0
- data/new_bridge_specs/phase1_req_ret_spec.rb +66 -0
- data/new_bridge_specs/phase2_multi_instance_spec.rb +67 -0
- data/new_bridge_specs/phase3_callbacks_spec.rb +71 -0
- data/new_bridge_specs/phase4_2_hardening_spec.rb +252 -0
- data/new_bridge_specs/phase4_3_r_instance_manager_spec.rb +85 -0
- data/new_bridge_specs/phase4_nested_callbacks_spec.rb +123 -0
- data/r_requires/ggplot.rb +0 -0
- data/r_requires/knitr.rb +0 -0
- data/specs/all.rb +15 -11
- data/specs/arrow_from_ruby_batches_spec.rb +50 -0
- data/specs/arrow_semantics_spec.rb +64 -0
- data/specs/bridge_concurrent_spec.rb +46 -0
- data/specs/bridge_nested_spec.rb +25 -0
- data/specs/dataframe_semantics_spec.rb +122 -0
- data/specs/dataframe_single_index_logical_filter_spec.rb +21 -0
- data/specs/dispatch_probe_cache_spec.rb +38 -0
- data/specs/dispatch_probe_error_class_fallback_spec.rb +20 -0
- data/specs/dispatch_probe_fallback_spec.rb +18 -0
- data/specs/environment_semantics_spec.rb +89 -0
- data/specs/field_access_spec.rb +31 -0
- data/specs/figures/bg.jpeg +0 -0
- data/specs/figures/bg.png +0 -0
- data/specs/figures/bg.svg +168 -57
- data/specs/figures/dose_len.png +0 -0
- data/specs/figures/no_args.jpeg +0 -0
- data/specs/figures/no_args.png +0 -0
- data/specs/figures/no_args.svg +168 -57
- data/specs/figures/width_height.jpeg +0 -0
- data/specs/figures/width_height.png +0 -0
- data/specs/figures/width_height_units1.jpeg +0 -0
- data/specs/figures/width_height_units1.png +0 -0
- data/specs/figures/width_height_units2.jpeg +0 -0
- data/specs/figures/width_height_units2.png +0 -0
- data/specs/formula_semantics_spec.rb +81 -0
- data/specs/galaaz_util_exec_ruby_spec.rb +85 -0
- data/specs/galaaz_util_inline_file_spec.rb +54 -0
- data/specs/gknit_cli_option_permutation_spec.rb +24 -0
- data/specs/gknit_include_engine_spec.rb +72 -0
- data/specs/gknit_install_timeout_report_spec.rb +69 -0
- data/specs/gknit_internal_error_report_spec.rb +57 -0
- data/specs/gknit_vector_map_output_spec.rb +59 -0
- data/specs/globalenv_guardrail_spec.rb +52 -0
- data/specs/language_expression_semantics_spec.rb +145 -0
- data/specs/list_semantics_spec.rb +111 -0
- data/specs/new_bridge_bulk_dataframe_transfer_spec.rb +44 -0
- data/specs/new_bridge_bulk_vector_transfer_spec.rb +73 -0
- data/specs/new_bridge_callback_timeout_spec.rb +69 -0
- data/specs/new_bridge_eval_r_fallback_spec.rb +55 -0
- data/specs/nil_null_spec.rb +42 -0
- data/specs/object_build_phase2_spec.rb +53 -0
- data/specs/phase1_callback_bridge_spec.rb +84 -0
- data/specs/phase2_gknit_generic_rendering_guardrail_spec.rb +46 -0
- data/specs/phase2_gknit_no_raw_code_leakage_spec.rb +43 -0
- data/specs/phase3_gknit_generic_graphics_capture_spec.rb +71 -0
- data/specs/plot_device_semantics_spec.rb +28 -0
- data/specs/plot_snapshot_semantics_spec.rb +58 -0
- data/specs/protocol_result_spec.rb +236 -0
- data/specs/r_batch_fail_fast_spec.rb +47 -0
- data/specs/r_bridge_bootstrap_spec.rb +11 -0
- data/specs/r_devices.spec.rb +1 -1
- data/specs/r_eval.spec.rb +16 -18
- data/specs/r_function.spec.rb +1 -1
- data/specs/r_instance_manager_spec.rb +285 -0
- data/specs/r_list_apply.spec.rb +15 -15
- data/specs/r_matrix.spec.rb +0 -0
- data/specs/r_nse.spec.rb +5 -5
- data/specs/r_object_send_dispatch_spec.rb +13 -0
- data/specs/r_vector_comparator_spec.rb +8 -0
- data/specs/r_vector_creation.spec.rb +0 -0
- data/specs/r_vector_functions.spec.rb +0 -0
- data/specs/r_vector_object.spec.rb +0 -0
- data/specs/r_vector_operators.spec.rb +0 -0
- data/specs/r_vector_structured_scalar_reads_spec.rb +35 -0
- data/specs/r_vector_subsetting.spec.rb +0 -0
- data/specs/range_helper_spec.rb +21 -0
- data/specs/rsupport_scope_spec.rb +28 -0
- data/specs/rsupport_var_name_thread_safety_spec.rb +24 -0
- data/specs/scalar_character_spec.rb +44 -0
- data/specs/scoped_symbol_dsl_refinement_spec.rb +40 -0
- data/specs/session_env_bridge_spec.rb +25 -0
- data/specs/simplecov_bootstrap_spec.rb +10 -0
- data/specs/spec_helper.rb +10 -0
- data/specs/tmp.rb +0 -0
- data/specs/unboxing_recursion_regression_spec.rb +30 -0
- data/specs/unboxing_spec.rb +49 -0
- data/specs/verify_callbacks.rb +42 -0
- data/sty/galaaz.sty +0 -0
- data/version.rb +1 -1
- metadata +194 -64
- data/blogs/galaaz_ggplot/galaaz_ggplot.html +0 -520
- data/blogs/galaaz_ggplot/galaaz_ggplot.pdf +0 -0
- data/blogs/galaaz_ggplot/midwest.html +0 -188
- data/blogs/gknit/gknit.html +0 -2266
- data/blogs/gknit/gknit.pdf +0 -0
- data/blogs/manual/manual.html +0 -4638
- data/blogs/manual/manual.pdf +0 -0
- data/blogs/manual/manual_files/figure-latex/diverging_bar.pdf +0 -0
- data/blogs/nse_dplyr/nse_dplyr.html +0 -878
- data/blogs/nse_dplyr/nse_dplyr.pdf +0 -0
- data/blogs/oh_my/oh_my.html +0 -568
- data/blogs/ruby_plot/ruby_plot.html +0 -544
- data/blogs/ruby_plot/ruby_plot.pdf +0 -0
- data/examples/latex_templates/Test-acs_article/Test-acs_article.pdf +0 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.pdf +0 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdf +0 -0
- data/examples/latex_templates/Test-amq_article/pics/Figure2.pdf +0 -0
- data/examples/latex_templates/Test-asa_article/Test-asa_article.pdf +0 -0
- data/examples/latex_templates/Test-ieee_article/Test-ieee_article.pdf +0 -0
- data/examples/latex_templates/Test-rjournal_article/RJwrapper.pdf +0 -0
- data/examples/latex_templates/Test-springer_article/Test-springer_article.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-anon-ms-example/svm-rmarkdown-anon-ms-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.pdf +0 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.pdf +0 -0
- data/specs/r_dataframe.spec.rb +0 -379
- data/specs/r_environment.spec.rb +0 -140
- data/specs/r_formula.spec.rb +0 -232
- data/specs/r_language.spec.rb +0 -112
- data/specs/r_list.spec.rb +0 -293
- data/specs/r_plots.spec.rb +0 -72
- data/specs/ruby_expression.spec.rb +0 -316
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
describe 'Phase 2 gknit generic rendering guardrail' do
|
|
4
|
+
it 'does not contain plotting-class-specific branches in gknit engine code' do
|
|
5
|
+
root = File.expand_path('..', __dir__)
|
|
6
|
+
targets = [
|
|
7
|
+
File.join(root, 'lib/gknit/knitr_engine.rb'),
|
|
8
|
+
File.join(root, 'lib/gknit/ruby_engine.rb'),
|
|
9
|
+
File.join(root, 'lib/gknit/rb_engine.rb'),
|
|
10
|
+
File.join(root, 'lib/gknit/include_engine.rb')
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
# Guard only executable lines (skip comments/blank lines).
|
|
14
|
+
branch_tokens = [
|
|
15
|
+
/if\b.*\bggplot\b/,
|
|
16
|
+
/case\b.*\bggplot\b/,
|
|
17
|
+
/when\b.*\bggplot\b/,
|
|
18
|
+
/if\b.*\blattice\b/,
|
|
19
|
+
/case\b.*\blattice\b/,
|
|
20
|
+
/when\b.*\blattice\b/,
|
|
21
|
+
/if\b.*\bgrid\b/,
|
|
22
|
+
/case\b.*\bgrid\b/,
|
|
23
|
+
/when\b.*\bgrid\b/,
|
|
24
|
+
/inherits\s*\(.*["']ggplot["']/,
|
|
25
|
+
/inherits\s*\(.*["']lattice["']/,
|
|
26
|
+
/\bis\.ggplot\b/,
|
|
27
|
+
/\bclass\s*\(.*\).*ggplot/
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
hits = []
|
|
31
|
+
|
|
32
|
+
targets.each do |path|
|
|
33
|
+
File.readlines(path, chomp: true).each_with_index do |line, idx|
|
|
34
|
+
stripped = line.strip
|
|
35
|
+
next if stripped.empty? || stripped.start_with?('#')
|
|
36
|
+
|
|
37
|
+
if branch_tokens.any? { |rx| stripped.match?(rx) }
|
|
38
|
+
rel = path.sub("#{root}/", '')
|
|
39
|
+
hits << "#{rel}:#{idx + 1}: #{stripped}"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
expect(hits).to eq([])
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'tmpdir'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'open3'
|
|
6
|
+
|
|
7
|
+
describe 'Phase 2 gknit raw code leakage' do
|
|
8
|
+
it 'does not leak unevaluated ruby source when echo is FALSE' do
|
|
9
|
+
root = File.expand_path('..', __dir__)
|
|
10
|
+
tmp_root = File.join(root, 'tmp')
|
|
11
|
+
FileUtils.mkdir_p(tmp_root)
|
|
12
|
+
work = Dir.mktmpdir('gknit_phase2_no_leak_', tmp_root)
|
|
13
|
+
input = File.join(work, 'fixture.Rmd')
|
|
14
|
+
output = File.join(work, 'rendered.md')
|
|
15
|
+
|
|
16
|
+
File.write(input, <<~RMD)
|
|
17
|
+
---
|
|
18
|
+
title: "phase2-no-leak"
|
|
19
|
+
output:
|
|
20
|
+
github_document: default
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
```{ruby, echo=FALSE, eval=TRUE, include=TRUE}
|
|
24
|
+
leak_source_line = "PHASE2_RAW_SOURCE_SHOULD_NOT_LEAK"
|
|
25
|
+
puts "PHASE2_EVALUATED_OUTPUT_OK"
|
|
26
|
+
```
|
|
27
|
+
RMD
|
|
28
|
+
|
|
29
|
+
begin
|
|
30
|
+
rel_input = input.sub("#{root}/", '')
|
|
31
|
+
cmd = ['bin/gknit', '-f', rel_input, '--output_format', 'github_document', '-o', 'rendered.md']
|
|
32
|
+
stdout, stderr, status = Open3.capture3(*cmd, chdir: root)
|
|
33
|
+
expect(status.success?).to eq(true), "gknit failed:\nSTDOUT:\n#{stdout}\nSTDERR:\n#{stderr}"
|
|
34
|
+
|
|
35
|
+
rendered = File.read(output)
|
|
36
|
+
expect(rendered).to include('PHASE2_EVALUATED_OUTPUT_OK')
|
|
37
|
+
expect(rendered).not_to include('PHASE2_RAW_SOURCE_SHOULD_NOT_LEAK')
|
|
38
|
+
expect(rendered).not_to include('leak_source_line =')
|
|
39
|
+
ensure
|
|
40
|
+
FileUtils.rm_rf(work) if work && File.directory?(work)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'tmpdir'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'open3'
|
|
6
|
+
|
|
7
|
+
describe 'Phase 3 gknit generic graphics capture' do
|
|
8
|
+
def render_github_doc(input_path, output_filename = 'rendered.md')
|
|
9
|
+
root = File.expand_path('..', __dir__)
|
|
10
|
+
rel_input = input_path.sub("#{root}/", '')
|
|
11
|
+
cmd = ['bin/gknit', '-f', rel_input, '--output_format', 'github_document', '-o', output_filename]
|
|
12
|
+
Open3.capture3(*cmd, chdir: root)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'captures and includes base/grid/ggplot figures generically' do
|
|
16
|
+
root = File.expand_path('..', __dir__)
|
|
17
|
+
tmp_root = File.join(root, 'tmp')
|
|
18
|
+
FileUtils.mkdir_p(tmp_root)
|
|
19
|
+
work = Dir.mktmpdir('gknit_phase3_graphics_', tmp_root)
|
|
20
|
+
input = File.join(work, 'fixture.Rmd')
|
|
21
|
+
output = File.join(work, 'rendered.md')
|
|
22
|
+
|
|
23
|
+
begin
|
|
24
|
+
File.write(input, <<~RMD)
|
|
25
|
+
---
|
|
26
|
+
title: "phase3-generic-graphics"
|
|
27
|
+
output:
|
|
28
|
+
github_document: default
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
This document mixes multiple graphics systems.
|
|
32
|
+
|
|
33
|
+
```{ruby, echo=FALSE, eval=TRUE, include=TRUE}
|
|
34
|
+
R.plot(R.c(1, 2, 3), R.c(1, 4, 9), type: "b")
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```{ruby, echo=FALSE, eval=TRUE, include=TRUE}
|
|
38
|
+
R::Support.eval("grid::grid.newpage(); grid::grid.rect(gp = grid::gpar(fill='grey85'))")
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```{ruby, echo=FALSE, eval=TRUE, include=TRUE}
|
|
42
|
+
unless R::Support.eval("requireNamespace('ggplot2', quietly=TRUE)") == true
|
|
43
|
+
raise "ggplot2 is not available"
|
|
44
|
+
end
|
|
45
|
+
R::Support.eval("p <- ggplot2::ggplot(mtcars, ggplot2::aes(wt, mpg)) + ggplot2::geom_point(); print(p)")
|
|
46
|
+
```
|
|
47
|
+
RMD
|
|
48
|
+
|
|
49
|
+
stdout, stderr, status = render_github_doc(input)
|
|
50
|
+
expect(status.success?).to eq(true), "gknit failed:\nSTDOUT:\n#{stdout}\nSTDERR:\n#{stderr}"
|
|
51
|
+
expect(File.exist?(output)).to eq(true)
|
|
52
|
+
|
|
53
|
+
md = File.read(output)
|
|
54
|
+
expect(md).to include('phase3-generic-graphics')
|
|
55
|
+
expect(stderr).not_to include('ggplot2 is not available')
|
|
56
|
+
fig_dir = File.join(work, 'rendered_files', 'figure-gfm')
|
|
57
|
+
expect(File.directory?(fig_dir)).to eq(true)
|
|
58
|
+
|
|
59
|
+
# gknit/github_document should emit markdown image markup so pandoc can
|
|
60
|
+
# render figures consistently across output formats.
|
|
61
|
+
image_paths = md.scan(%r{!\[\]\((rendered_files/figure-gfm/[^\)]+)\)}).flatten
|
|
62
|
+
expect(image_paths.length).to be >= 3
|
|
63
|
+
image_paths.each do |rel|
|
|
64
|
+
rel = rel.sub(%r{^\./}, '')
|
|
65
|
+
expect(File.exist?(File.join(work, rel))).to eq(true), "missing figure artifact: #{rel}"
|
|
66
|
+
end
|
|
67
|
+
ensure
|
|
68
|
+
FileUtils.rm_rf(work) if work && File.directory?(work)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'galaaz'
|
|
4
|
+
|
|
5
|
+
describe R::Device do
|
|
6
|
+
it 'renders a base plot to png and writes a non-empty artifact' do
|
|
7
|
+
dev = R::Device.new('png', width: 4, height: 3, dpi: 96)
|
|
8
|
+
dev.open
|
|
9
|
+
R.barplot(R.c(2, 5, 3, 4))
|
|
10
|
+
dev.close
|
|
11
|
+
|
|
12
|
+
path = dev.instance_variable_get(:@dev_path)
|
|
13
|
+
expect(path).not_to be_nil
|
|
14
|
+
expect(File.exist?(path)).to eq(true)
|
|
15
|
+
expect(File.size(path)).to be > 0
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'supports block form for svg device and writes artifact' do
|
|
19
|
+
dev = R::Device.new('svg', width: 4, height: 3, dpi: 96) do
|
|
20
|
+
R.plot(R.c(1, 2, 3, 4))
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
path = dev.instance_variable_get(:@dev_path)
|
|
24
|
+
expect(path).not_to be_nil
|
|
25
|
+
expect(File.exist?(path)).to eq(true)
|
|
26
|
+
expect(File.size(path)).to be > 0
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'galaaz'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
describe 'Plot snapshot/save semantics' do
|
|
7
|
+
it 'captures and saves recorded plot via R::Device helpers in plain runtime' do
|
|
8
|
+
work = Dir.mktmpdir('plot_snapshot_')
|
|
9
|
+
|
|
10
|
+
begin
|
|
11
|
+
Dir.chdir(work) do
|
|
12
|
+
dev = R::Device.new('png', width: 4, height: 3, dpi: 96, record: true)
|
|
13
|
+
dev.open
|
|
14
|
+
R.barplot(R.c(3, 1, 4, 2))
|
|
15
|
+
snap = dev.plot_snapshot
|
|
16
|
+
out_file = dev.save_plot(snap, 'snapshot_test', 'png', 4, 3, 'png', 96)
|
|
17
|
+
dev.close
|
|
18
|
+
|
|
19
|
+
path = File.join(work, out_file.to_s)
|
|
20
|
+
expect(File.exist?(path)).to eq(true)
|
|
21
|
+
expect(File.size(path)).to be > 0
|
|
22
|
+
end
|
|
23
|
+
ensure
|
|
24
|
+
FileUtils.rm_rf(work) if work && File.directory?(work)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'captures snapshots across plot pages and saves both artifacts' do
|
|
29
|
+
work = Dir.mktmpdir('plot_snapshot_multi_')
|
|
30
|
+
|
|
31
|
+
begin
|
|
32
|
+
Dir.chdir(work) do
|
|
33
|
+
dev = R::Device.new('png', width: 4, height: 3, dpi: 96, record: true)
|
|
34
|
+
dev.open
|
|
35
|
+
|
|
36
|
+
R.barplot(R.c(2, 5, 3, 4))
|
|
37
|
+
snap1 = dev.plot_snapshot
|
|
38
|
+
out1 = dev.save_plot(snap1, 'snapshot_page1', 'png', 4, 3, 'png', 96)
|
|
39
|
+
|
|
40
|
+
R::Support.eval('grid::grid.newpage(recording = TRUE)')
|
|
41
|
+
R.plot(R.c(1, 2, 3, 4))
|
|
42
|
+
snap2 = dev.plot_snapshot
|
|
43
|
+
out2 = dev.save_plot(snap2, 'snapshot_page2', 'png', 4, 3, 'png', 96)
|
|
44
|
+
|
|
45
|
+
dev.close
|
|
46
|
+
|
|
47
|
+
path1 = File.join(work, out1.to_s)
|
|
48
|
+
path2 = File.join(work, out2.to_s)
|
|
49
|
+
expect(File.exist?(path1)).to eq(true)
|
|
50
|
+
expect(File.size(path1)).to be > 0
|
|
51
|
+
expect(File.exist?(path2)).to eq(true)
|
|
52
|
+
expect(File.size(path2)).to be > 0
|
|
53
|
+
end
|
|
54
|
+
ensure
|
|
55
|
+
FileUtils.rm_rf(work) if work && File.directory?(work)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Phase 5: Per-call result protocol — all returns via result buffer (no fallback).
|
|
3
|
+
# These specs assert that eval and exec_function return correct types from the
|
|
4
|
+
# protocol envelope. When Phase 5 is complete (fallback removed), these tests
|
|
5
|
+
# ensure every result path goes through the buffer.
|
|
6
|
+
|
|
7
|
+
require 'galaaz'
|
|
8
|
+
|
|
9
|
+
describe "Result protocol (Phase 5)" do
|
|
10
|
+
|
|
11
|
+
context "R::Support.eval returns via protocol envelope" do
|
|
12
|
+
|
|
13
|
+
it "returns scalar double as Float" do
|
|
14
|
+
v = R::Support.eval("3.14")
|
|
15
|
+
expect(v).to be_a(Numeric)
|
|
16
|
+
expect(v).to eq 3.14
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "returns scalar integer as Numeric (unboxed)" do
|
|
20
|
+
v = R::Support.eval("42L")
|
|
21
|
+
expect(v).to be_a(Numeric)
|
|
22
|
+
expect(v).to eq 42
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "returns scalar logical as true/false" do
|
|
26
|
+
expect(R::Support.eval("TRUE")).to eq true
|
|
27
|
+
expect(R::Support.eval("FALSE")).to eq false
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "returns scalar symbol as Ruby Symbol" do
|
|
31
|
+
v = R::Support.eval("as.symbol('foo')")
|
|
32
|
+
expect(v).to be_a(Symbol)
|
|
33
|
+
expect(v).to eq :foo
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "returns length-1 character as R::Vector (not unboxed)" do
|
|
37
|
+
v = R::Support.eval("'hello'")
|
|
38
|
+
expect(v).to be_a(R::Vector)
|
|
39
|
+
expect(v.length).to eq 1
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "returns vector (handle) as R::Vector with correct class" do
|
|
43
|
+
v = R::Support.eval("c(1, 2, 3)")
|
|
44
|
+
expect(v).to be_a(R::Vector)
|
|
45
|
+
rcls = v.rclass.to_s
|
|
46
|
+
expect(rcls).to match(/numeric|integer/)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "returns list (handle) as R::List" do
|
|
50
|
+
v = R::Support.eval("list(1, 'a', TRUE)")
|
|
51
|
+
expect(v).to be_a(R::List)
|
|
52
|
+
expect(v.length).to be >= 1
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "returns matrix (handle) as R::Matrix" do
|
|
56
|
+
v = R::Support.eval("matrix(1:4, nrow = 2)")
|
|
57
|
+
expect(v).to be_a(R::Matrix)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "returns data.frame (handle) as R::DataFrame" do
|
|
61
|
+
v = R::Support.eval("data.frame(a = 1:2, b = c('x', 'y'))")
|
|
62
|
+
expect(v).to be_a(R::DataFrame)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "returns function (handle) as R::Closure" do
|
|
66
|
+
v = R::Support.eval("identity")
|
|
67
|
+
expect(v).to be_a(R::Closure)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
context "R::Support.exec_function returns via protocol envelope" do
|
|
72
|
+
|
|
73
|
+
it "c() returns R::Vector" do
|
|
74
|
+
v = R::Support.exec_function("c", 1, 2, 3)
|
|
75
|
+
expect(v).to be_a(R::Vector)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "list() returns R::List" do
|
|
79
|
+
v = R::Support.exec_function("list", 1, "x")
|
|
80
|
+
expect(v).to be_a(R::List)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "matrix() returns R::Matrix" do
|
|
84
|
+
v = R::Support.exec_function("matrix", R.c(1, 2, 3, 4), 2)
|
|
85
|
+
expect(v).to be_a(R::Matrix)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "identity (function) returns R::Closure" do
|
|
89
|
+
v = R::Support.exec_function("identity", 42)
|
|
90
|
+
expect(v).to eq 42
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "length() returns R object (protocol handle or scalar)" do
|
|
94
|
+
vec = R.c(1, 2, 3)
|
|
95
|
+
# length is special-cased to not unbox; returns R::Vector
|
|
96
|
+
v = R::Support.exec_function("length", vec)
|
|
97
|
+
expect(v).to be_a(R::Object)
|
|
98
|
+
expect(vec.length).to eq 3 # Vector#length uses unboxed_get
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
context "Public API uses protocol (R.c, R.list, ~R[:sym])" do
|
|
103
|
+
|
|
104
|
+
it "R.c builds vector via protocol" do
|
|
105
|
+
v = R.c(1, 2, 3)
|
|
106
|
+
expect(v).to be_a(R::Vector)
|
|
107
|
+
expect(v.length).to eq 3
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "R.list builds list via protocol" do
|
|
111
|
+
v = R.list(1, "a")
|
|
112
|
+
expect(v).to be_a(R::List)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "~R[:x] retrieves object via protocol" do
|
|
116
|
+
R::Support.eval("x_protocol_test <- c(10, 20)")
|
|
117
|
+
v = ~R[:x_protocol_test]
|
|
118
|
+
expect(v).to be_a(R::Vector)
|
|
119
|
+
expect(v[1]).to eq 10
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Phase A (BasicObject migration): ensure R::Object has the explicit Ruby surface
|
|
124
|
+
# we need. Run with protocol + minimal set to catch regressions.
|
|
125
|
+
context "R::Object Ruby surface (Phase A — BasicObject migration)" do
|
|
126
|
+
|
|
127
|
+
let(:vec) { R.c(1, 2, 3) }
|
|
128
|
+
let(:lst) { R.list(1, "a") }
|
|
129
|
+
|
|
130
|
+
it "responds to class and returns the concrete Ruby class" do
|
|
131
|
+
expect(vec).to respond_to(:class)
|
|
132
|
+
expect(vec.class).to eq R::Vector
|
|
133
|
+
expect(lst.class).to eq R::List
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
it "responds to to_s and returns a string (R print output)" do
|
|
137
|
+
expect(vec).to respond_to(:to_s)
|
|
138
|
+
expect(vec.to_s).to be_a(String)
|
|
139
|
+
expect(vec.to_s).to match(/[1-3]/)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it "responds to respond_to? and reports explicit and forwarded methods" do
|
|
143
|
+
expect(vec).to respond_to(:respond_to?)
|
|
144
|
+
expect(vec.respond_to?(:r_interop)).to eq true
|
|
145
|
+
expect(vec.respond_to?(:length)).to eq true
|
|
146
|
+
expect(vec.respond_to?(:class)).to eq true
|
|
147
|
+
expect(vec.respond_to?(:>>)).to eq true
|
|
148
|
+
expect(vec.respond_to?(:[])).to eq true
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "responds to is_a? and kind_of? with correct type checks" do
|
|
152
|
+
expect(vec).to respond_to(:is_a?)
|
|
153
|
+
expect(vec).to respond_to(:kind_of?)
|
|
154
|
+
expect(vec.is_a?(R::Vector)).to eq true
|
|
155
|
+
expect(vec.is_a?(R::Object)).to eq true
|
|
156
|
+
expect(vec.kind_of?(R::Vector)).to eq true
|
|
157
|
+
expect(vec.is_a?(R::List)).to eq false
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "responds to instance_of? with correct class check" do
|
|
161
|
+
expect(vec).to respond_to(:instance_of?)
|
|
162
|
+
expect(vec.instance_of?(R::Vector)).to eq true
|
|
163
|
+
expect(vec.instance_of?(R::Object)).to eq false
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
it "responds to inspect and returns a string with class and handle" do
|
|
167
|
+
expect(vec).to respond_to(:inspect)
|
|
168
|
+
expect(vec.inspect).to be_a(String)
|
|
169
|
+
expect(vec.inspect).to include("R::Vector")
|
|
170
|
+
expect(vec.inspect).to include("r_interop")
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "responds to object_id and returns an integer" do
|
|
174
|
+
expect(vec).to respond_to(:object_id)
|
|
175
|
+
expect(vec.object_id).to be_a(Integer)
|
|
176
|
+
expect(vec.object_id).to eq vec.__id__
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Phase 1 performance: gatekeeper sends stable wrapper_tag on handle results (docs/performance_plan.md).
|
|
181
|
+
context "eval_r_with_result handle envelopes include wrapper_tag" do
|
|
182
|
+
def envelope_for_rhs(rhs_r)
|
|
183
|
+
vn = R::Support.generate_var_name
|
|
184
|
+
R.bridge.eval_r_with_result("#{vn} <- #{rhs_r}")
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
it "tags multi-element vector" do
|
|
188
|
+
env = envelope_for_rhs("c(1L, 2L, 3L)")
|
|
189
|
+
expect(env[:type]).to eq(:handle)
|
|
190
|
+
expect(env[:wrapper_tag]).to eq("vector")
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it "tags data.frame" do
|
|
194
|
+
env = envelope_for_rhs("data.frame(a = 1:2, b = c('u', 'v'))")
|
|
195
|
+
expect(env[:type]).to eq(:handle)
|
|
196
|
+
expect(env[:wrapper_tag]).to eq("data_frame")
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it "tags matrix" do
|
|
200
|
+
env = envelope_for_rhs("matrix(1:4, nrow = 2)")
|
|
201
|
+
expect(env[:type]).to eq(:handle)
|
|
202
|
+
expect(env[:wrapper_tag]).to eq("matrix")
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it "tags list" do
|
|
206
|
+
env = envelope_for_rhs("list(1L, 'a', TRUE)")
|
|
207
|
+
expect(env[:type]).to eq(:handle)
|
|
208
|
+
expect(env[:wrapper_tag]).to eq("list")
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
it "tags closure" do
|
|
212
|
+
env = envelope_for_rhs("identity")
|
|
213
|
+
expect(env[:type]).to eq(:handle)
|
|
214
|
+
expect(env[:wrapper_tag]).to eq("closure")
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
it "tags environment" do
|
|
218
|
+
env = envelope_for_rhs("new.env()")
|
|
219
|
+
expect(env[:type]).to eq(:handle)
|
|
220
|
+
expect(env[:wrapper_tag]).to eq("environment")
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
it "tags language (call)" do
|
|
224
|
+
env = envelope_for_rhs("quote(1 + 2)")
|
|
225
|
+
expect(env[:type]).to eq(:handle)
|
|
226
|
+
expect(env[:wrapper_tag]).to eq("language")
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
it "omits wrapper_tag for scalar results" do
|
|
230
|
+
vn = R::Support.generate_var_name
|
|
231
|
+
env = R.bridge.eval_r_with_result("#{vn} <- 42L")
|
|
232
|
+
expect(env[:type]).to eq(:scalar_integer)
|
|
233
|
+
expect(env).not_to have_key(:wrapper_tag)
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'galaaz'
|
|
4
|
+
|
|
5
|
+
describe 'R.batch (Phase 4 — fail-fast multi-op bridge)' do
|
|
6
|
+
it 'returns one legacy envelope per op when all succeed' do
|
|
7
|
+
a = R::Support.generate_var_name
|
|
8
|
+
b = R::Support.generate_var_name
|
|
9
|
+
c = R::Support.generate_var_name
|
|
10
|
+
|
|
11
|
+
res = R.batch do |batch|
|
|
12
|
+
batch.eval_with_result("#{a} <- 10L")
|
|
13
|
+
batch.eval_with_result("#{b} <- #{a} + 5L")
|
|
14
|
+
batch.eval_with_result("#{c} <- #{b} * 2L")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
expect(res.size).to eq(3)
|
|
18
|
+
expect(res[0][:type]).to eq(:scalar_integer)
|
|
19
|
+
expect(res[0][:value]).to eq(10)
|
|
20
|
+
expect(res[1][:value]).to eq(15)
|
|
21
|
+
expect(res[2][:value]).to eq(30)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'raises BatchEvaluationError on first failing op with 0-based index' do
|
|
25
|
+
v1 = R::Support.generate_var_name
|
|
26
|
+
v3 = R::Support.generate_var_name
|
|
27
|
+
|
|
28
|
+
err = nil
|
|
29
|
+
expect do
|
|
30
|
+
R.batch do |batch|
|
|
31
|
+
batch.eval_with_result("#{v1} <- 1L")
|
|
32
|
+
batch.eval_with_result("stop('galaaz_batch_intentional_failure')")
|
|
33
|
+
batch.eval_with_result("#{v3} <- 99L")
|
|
34
|
+
end
|
|
35
|
+
end.to raise_error(R::BatchEvaluationError) { |e| err = e }
|
|
36
|
+
|
|
37
|
+
expect(err.failed_index).to eq(1)
|
|
38
|
+
expect(R::Support.eval(v1)).to eq(1)
|
|
39
|
+
expect { R::Support.eval(v3) }.to raise_error(NewBridge::SessionClient::RProcessError, /not found/i)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'rejects empty batch' do
|
|
43
|
+
expect do
|
|
44
|
+
R.batch { |_b| }
|
|
45
|
+
end.to raise_error(ArgumentError, /at least one/)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'galaaz'
|
|
2
|
+
|
|
3
|
+
describe 'R bridge bootstrap' do
|
|
4
|
+
it 'uses NewBridge adapter' do
|
|
5
|
+
expect(R.bridge).to be_a(R::NewBridgeAdapter)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it 'does not expose shadow bridge selector API' do
|
|
9
|
+
expect(R.respond_to?(:shadow_bridge_selected?)).to eq(false)
|
|
10
|
+
end
|
|
11
|
+
end
|
data/specs/r_devices.spec.rb
CHANGED
|
@@ -30,7 +30,7 @@ describe R do
|
|
|
30
30
|
# Read the R ToothGrowth variable and assign it to the
|
|
31
31
|
# Ruby instance variable @tooth_growth that will be
|
|
32
32
|
# available to all Ruby chunks in this document.
|
|
33
|
-
@tooth_growth =
|
|
33
|
+
@tooth_growth = ~R[:ToothGrowth]
|
|
34
34
|
|
|
35
35
|
# convert the dose to a factor
|
|
36
36
|
@tooth_growth.dose = @tooth_growth.dose.as__factor
|
data/specs/r_eval.spec.rb
CHANGED
|
@@ -45,33 +45,31 @@ describe R do
|
|
|
45
45
|
|
|
46
46
|
it "Interop pointers can be operated through eval" do
|
|
47
47
|
var = R::Support.eval("5L")
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
expect("integer").to eq R::Support.eval("class").call(var).to_s
|
|
48
|
+
# class(var) returns length-1 character (boxed); unbox to scalar for comparison
|
|
49
|
+
expect("integer").to eq (R::Support.eval("class").call(var) >> 0)
|
|
51
50
|
end
|
|
52
51
|
|
|
53
52
|
it "A number evaluated in R is automatically unboxed as float in Ruby" do
|
|
54
53
|
var = R::Support.eval("4")
|
|
55
54
|
expect(4.0).to eq var
|
|
56
|
-
expect("numeric").to eq R::Support.eval("class").call(var)
|
|
55
|
+
expect("numeric").to eq (R::Support.eval("class").call(var) >> 0)
|
|
57
56
|
end
|
|
58
57
|
|
|
59
58
|
it "R vectors can be indexed by the indexing method of the host language" do
|
|
60
59
|
var = R::Support.eval("'Hello'")
|
|
61
|
-
expect(var[
|
|
60
|
+
expect(var[1]).to eq "Hello"
|
|
62
61
|
end
|
|
63
62
|
|
|
64
|
-
it "should retrieve named R objects to Ruby variables using eval. Returned value should be an
|
|
63
|
+
it "should retrieve named R objects to Ruby variables using eval. Returned value should be an R::Object" do
|
|
65
64
|
# retrieve x and hyp from R and attribute it to local Ruby variables
|
|
66
65
|
x = R::Support.eval("x")
|
|
67
66
|
# hyp is an R function and works like a named function in Ruby
|
|
68
67
|
hyp = R::Support.eval("hyp")
|
|
69
68
|
|
|
70
|
-
#
|
|
71
|
-
expect(
|
|
72
|
-
#
|
|
73
|
-
|
|
74
|
-
expect(x[0]).to eq 1.0
|
|
69
|
+
# In Galaaz 2.0 we get R::Object wrappers (no Truffle interop)
|
|
70
|
+
expect(x).to be_a(R::Object)
|
|
71
|
+
# Indexing: R uses 1-based; we can get first element with [1] or >> 0
|
|
72
|
+
expect(x[1]).to eq 1.0
|
|
75
73
|
|
|
76
74
|
# calling a named function or block is done by use of the 'call' method
|
|
77
75
|
expect(hyp.call(3, 4)).to eq 5.0
|
|
@@ -83,12 +81,12 @@ describe R do
|
|
|
83
81
|
|
|
84
82
|
it "should retrieve named R objects to Ruby variables by using '~' " do
|
|
85
83
|
# retrieve x and hyp from R and attribute it to local Ruby variables
|
|
86
|
-
x =
|
|
84
|
+
x = ~R[:x]
|
|
87
85
|
|
|
88
86
|
expect(x.is_a? R::Vector).to eq true
|
|
89
87
|
expect(x.length).to eq 3
|
|
90
|
-
#
|
|
91
|
-
expect(
|
|
88
|
+
# In Galaaz 2.0 we always get R::Object subclasses (e.g. R::Vector), not raw interop
|
|
89
|
+
expect(x).to be_a(R::Vector)
|
|
92
90
|
# Values are indexed starting with 1, the same as R notation
|
|
93
91
|
expect(x[1]).to eq 1.0
|
|
94
92
|
end
|
|
@@ -109,7 +107,7 @@ describe R do
|
|
|
109
107
|
# to create a double vector through the Ruby interface, we need that at least
|
|
110
108
|
# one element of the vector is a 'float'
|
|
111
109
|
double = R.c(1.0, 2, 3)
|
|
112
|
-
expect((
|
|
110
|
+
expect((~R[:x]).identical double).to eq true
|
|
113
111
|
expect(R.hyp(3, 4).all__equal(5)).to eq true
|
|
114
112
|
# @TODO: this should work but raises the following error:
|
|
115
113
|
# TypeError:
|
|
@@ -121,7 +119,7 @@ describe R do
|
|
|
121
119
|
|
|
122
120
|
it "should box R functions in R::Closure Ruby class" do
|
|
123
121
|
# hyp is an R function and works like a named function in Ruby
|
|
124
|
-
hyp =
|
|
122
|
+
hyp = ~R[:hyp]
|
|
125
123
|
|
|
126
124
|
# calling a named function or block is done by use of the 'call' method
|
|
127
125
|
expect(hyp.call(3, 4)).to eq 5.0
|
|
@@ -131,7 +129,7 @@ describe R do
|
|
|
131
129
|
|
|
132
130
|
it "should print values the same way as R" do
|
|
133
131
|
# retrieve x and hyp from R and attribute it to local Ruby variables
|
|
134
|
-
x =
|
|
132
|
+
x = ~R[:x]
|
|
135
133
|
|
|
136
134
|
# Converting to string (to_s) will print as an R vector would
|
|
137
135
|
expect(x[1].to_s).to eq ("[1] 1")
|
|
@@ -140,7 +138,7 @@ describe R do
|
|
|
140
138
|
|
|
141
139
|
it "should allow logical comparison using R::Objects" do
|
|
142
140
|
# retrieve x and hyp from R and attribute it to local Ruby variables
|
|
143
|
-
x =
|
|
141
|
+
x = ~R[:x]
|
|
144
142
|
|
|
145
143
|
expect(x[1].all__equal(1)).to eq true
|
|
146
144
|
expect(x[2].identical(1)).to eq false
|
data/specs/r_function.spec.rb
CHANGED
|
@@ -44,7 +44,7 @@ describe R do
|
|
|
44
44
|
context "Using Ruby Procs as parameters to R functions and expressions" do
|
|
45
45
|
|
|
46
46
|
before(:each) do
|
|
47
|
-
@x = @y = R.seq(
|
|
47
|
+
@x = @y = R.seq(-~R[:pi], ~R[:pi], length: 10)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "should accept a Proc as parameter" do
|