galaaz 0.4.10 → 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 +3123 -882
- data/Rakefile +62 -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 +223 -6
- data/bin/gknit-draft +105 -0
- data/bin/gknit-draft.rb +28 -0
- data/bin/gknit_Rscript +127 -0
- data/bin/grun +27 -1
- data/bin/gstudio +49 -4
- data/bin/{gstudio.rb → gstudio_irb.rb} +0 -0
- data/bin/gstudio_pry.rb +7 -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 +364 -0
- 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 +52 -55
- data/blogs/gknit/gknit.md +94 -94
- 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 +1582 -196
- data/blogs/manual/manual.log +1786 -0
- data/blogs/manual/manual.md +3107 -890
- data/blogs/manual/manual.tex +3018 -1086
- 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 +41 -0
- data/blogs/nse_dplyr/nse_dplyr.Rmd +277 -151
- data/blogs/nse_dplyr/nse_dplyr.log +928 -0
- data/blogs/nse_dplyr/nse_dplyr.md +457 -293
- 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 +1808 -228
- 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 -103
- 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 +50 -0
- data/examples/Bibliography/stats.bib +72 -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/Makefile +16 -0
- data/examples/latex_templates/Test-acm_article/Test-acm_article.Rmd +65 -0
- data/examples/latex_templates/Test-acm_article/acm_proc_article-sp.cls +1670 -0
- data/examples/latex_templates/Test-acm_article/sensys-abstract.cls +703 -0
- data/examples/latex_templates/Test-acm_article/sigproc.bib +59 -0
- data/examples/latex_templates/Test-acs_article/Test-acs_article.Rmd +260 -0
- data/examples/latex_templates/Test-acs_article/acs-Test-acs_article.bib +11 -0
- data/examples/latex_templates/Test-acs_article/acs-my_output.bib +11 -0
- data/examples/latex_templates/Test-acs_article/acstest.bib +17 -0
- data/examples/latex_templates/Test-aea_article/AEA.cls +1414 -0
- data/{blogs/gknit/marshal.dump → examples/latex_templates/Test-aea_article/BibFile.bib} +0 -0
- data/examples/latex_templates/Test-aea_article/Test-aea_article.Rmd +108 -0
- data/examples/latex_templates/Test-aea_article/aea.bst +1269 -0
- data/examples/latex_templates/Test-aea_article/multicol.sty +853 -0
- data/examples/latex_templates/Test-aea_article/references.bib +0 -0
- data/examples/latex_templates/Test-aea_article/setspace.sty +546 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.Rmd +256 -0
- data/examples/latex_templates/Test-amq_article/Test-amq_article.pdfsync +3397 -0
- data/examples/latex_templates/Test-ams_article/Test-ams_article.Rmd +215 -0
- data/examples/latex_templates/Test-ams_article/amstest.bib +436 -0
- data/examples/latex_templates/Test-asa_article/Test-asa_article.Rmd +153 -0
- data/examples/latex_templates/Test-asa_article/agsm.bst +1353 -0
- data/examples/latex_templates/Test-asa_article/bibliography.bib +233 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.bst +2409 -0
- data/examples/latex_templates/Test-ieee_article/IEEEtran.cls +6346 -0
- data/examples/latex_templates/Test-ieee_article/Test-ieee_article.Rmd +175 -0
- data/examples/latex_templates/Test-ieee_article/mybibfile.bib +20 -0
- data/examples/latex_templates/Test-rjournal_article/RJournal.sty +335 -0
- data/examples/latex_templates/Test-rjournal_article/RJreferences.bib +18 -0
- data/examples/latex_templates/Test-rjournal_article/Test-rjournal_article.Rmd +52 -0
- data/examples/latex_templates/Test-springer_article/Test-springer_article.Rmd +65 -0
- data/examples/latex_templates/Test-springer_article/bibliography.bib +26 -0
- data/examples/latex_templates/Test-springer_article/spbasic.bst +1658 -0
- data/examples/latex_templates/Test-springer_article/spmpsci.bst +1512 -0
- data/examples/latex_templates/Test-springer_article/spphys.bst +1443 -0
- data/examples/latex_templates/Test-springer_article/svglov3.clo +113 -0
- data/examples/latex_templates/Test-springer_article/svjour3.cls +1431 -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 +73 -0
- data/examples/rmarkdown/svm-rmarkdown-article-example/svm-rmarkdown-article-example.Rmd +382 -0
- data/examples/rmarkdown/svm-rmarkdown-beamer-example/svm-rmarkdown-beamer-example.Rmd +164 -0
- data/examples/rmarkdown/svm-rmarkdown-cv/svm-rmarkdown-cv.Rmd +92 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/attend-grade-relationships.csv +482 -0
- data/examples/rmarkdown/svm-rmarkdown-syllabus-example/svm-rmarkdown-syllabus-example.Rmd +280 -0
- data/examples/rmarkdown/svm-xaringan-example/svm-xaringan-example.Rmd +386 -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 +4 -4
- data/lib/R_interface/r_methods.rb +13 -116
- 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 +1 -0
- data/lib/R_interface/rsupport.rb +610 -331
- 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 +111 -0
- data/lib/gknit/include_engine.rb +15 -7
- data/lib/gknit/knitr_engine.rb +223 -107
- data/lib/gknit/rb_engine.rb +3 -3
- data/lib/gknit/ruby_engine.rb +0 -0
- data/lib/gknit.rb +3 -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 -46
- 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 +41 -20
- 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 +239 -71
- data/blogs/galaaz_ggplot/galaaz_ggplot.aux +0 -41
- data/blogs/galaaz_ggplot/galaaz_ggplot.html +0 -705
- data/blogs/galaaz_ggplot/galaaz_ggplot.out +0 -10
- data/blogs/galaaz_ggplot/galaaz_ggplot.pdf +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/midwest_rb.pdf +0 -0
- data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-latex/scatter_plot_rb.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/gknit/gknit.tex +0 -1358
- data/blogs/manual/graph.rb +0 -29
- data/blogs/manual/manual.html +0 -2995
- 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 -960
- data/blogs/nse_dplyr/nse_dplyr.pdf +0 -0
- data/blogs/nse_dplyr/nse_dplyr.tex +0 -1373
- data/blogs/oh_my/oh_my.html +0 -680
- data/blogs/ruby_plot/ruby_plot.Rmd_external_figs +0 -662
- data/blogs/ruby_plot/ruby_plot.html +0 -729
- data/blogs/ruby_plot/ruby_plot.pdf +0 -0
- data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.svg +0 -57
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.svg +0 -106
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.svg +0 -110
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.svg +0 -174
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.svg +0 -236
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.svg +0 -296
- data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.svg +0 -236
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.svg +0 -218
- data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.svg +0 -128
- data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.svg +0 -150
- data/examples/paper/paper.rb +0 -36
- 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 -315
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'galaaz'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
describe 'Arrow semantics' do
|
|
7
|
+
before(:all) do
|
|
8
|
+
ok = R::Support.eval("requireNamespace('arrow', quietly=TRUE)")
|
|
9
|
+
skip 'R package arrow is not available' unless ok == true
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'creates an Arrow table from a data.frame via Ruby helper' do
|
|
13
|
+
df = R.data__frame(x: (1..3), y: (3..1))
|
|
14
|
+
tbl = R::Arrow.table_from(df)
|
|
15
|
+
expect(tbl.rclass.split(' ')).to include('Table')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'writes and reads Feather through namespaced Arrow helpers' do
|
|
19
|
+
path = File.join(Dir.tmpdir, 'galaaz_arrow_semantics.feather')
|
|
20
|
+
df1 = R.data__frame(x: (1..5), y: (~R[:letters])[(1..5)])
|
|
21
|
+
|
|
22
|
+
R::Arrow.write_feather(df1, path)
|
|
23
|
+
df2 = R::Arrow.read_feather(path)
|
|
24
|
+
|
|
25
|
+
expect(df2.names).to eq R.c('x', 'y')
|
|
26
|
+
expect(df2.nrow >> 0).to eq 5
|
|
27
|
+
expect(df2.rclass.split(' ')).to include('tbl_df').or include('data.frame')
|
|
28
|
+
expect(df2[[1]][1]).to eq 1
|
|
29
|
+
expect(df2[[1]][5]).to eq 5
|
|
30
|
+
expect(df2[[2]][1]).to eq 'a'
|
|
31
|
+
expect(df2[[2]][5]).to eq 'e'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'opens Parquet dataset and runs grouped aggregation with dplyr' do
|
|
35
|
+
path = File.join(Dir.tmpdir, 'galaaz_arrow_semantics.parquet')
|
|
36
|
+
R.install_and_loads('dplyr', 'arrow')
|
|
37
|
+
|
|
38
|
+
df = R.data__frame(group: R.c('a', 'a', 'b', 'b'), value: R.c(1, 2, 3, 4))
|
|
39
|
+
R::Arrow.write_parquet(df, path)
|
|
40
|
+
|
|
41
|
+
ds = R::Arrow.dataset(path)
|
|
42
|
+
grouped = R.dplyr___group_by(ds, :group)
|
|
43
|
+
summarised = R.dplyr___summarise(grouped, total: E.sum(:value))
|
|
44
|
+
collected = R.dplyr___collect(summarised)
|
|
45
|
+
|
|
46
|
+
expect(collected.rclass.split(' ')).to include('tbl_df').or include('data.frame')
|
|
47
|
+
expect(collected.nrow >> 0).to eq 2
|
|
48
|
+
|
|
49
|
+
groups = collected[['group']]
|
|
50
|
+
totals = collected[['total']]
|
|
51
|
+
rows = {}
|
|
52
|
+
(1..(groups.length >> 0)).each do |i|
|
|
53
|
+
grp = groups[i]
|
|
54
|
+
tot = totals[i]
|
|
55
|
+
grp = grp.to_ruby if grp.respond_to?(:to_ruby)
|
|
56
|
+
tot = tot.to_ruby if tot.respond_to?(:to_ruby)
|
|
57
|
+
grp = grp.first if grp.is_a?(Array)
|
|
58
|
+
tot = tot.first if tot.is_a?(Array)
|
|
59
|
+
rows[grp] = tot
|
|
60
|
+
end
|
|
61
|
+
expect(rows['a']).to eq 3
|
|
62
|
+
expect(rows['b']).to eq 7
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Phase 1: concurrent bridge spec. N threads × M rounds of eval_r_with_result;
|
|
3
|
+
# assert no exceptions, every result correct, and exactly N×M results (no loss/duplicates).
|
|
4
|
+
|
|
5
|
+
require 'galaaz'
|
|
6
|
+
|
|
7
|
+
describe "Bridge concurrent access (Phase 1)" do
|
|
8
|
+
|
|
9
|
+
it "serializes concurrent eval_r_with_result calls and returns correct results" do
|
|
10
|
+
bridge = R.bridge
|
|
11
|
+
n_threads = 5
|
|
12
|
+
rounds_per_thread = 10
|
|
13
|
+
results_mutex = Mutex.new
|
|
14
|
+
results = [] # [ { thread_id:, round:, value: }, ... ]
|
|
15
|
+
errors = []
|
|
16
|
+
|
|
17
|
+
threads = n_threads.times.map do |thread_id|
|
|
18
|
+
Thread.new do
|
|
19
|
+
rounds_per_thread.times do |round|
|
|
20
|
+
expected_value = thread_id * 1000 + round
|
|
21
|
+
assignment = "g2_v_t#{thread_id}_r#{round} <- #{expected_value}L"
|
|
22
|
+
env = bridge.eval_r_with_result(assignment)
|
|
23
|
+
results_mutex.synchronize do
|
|
24
|
+
if env && env[:type] == :scalar_integer && env[:value] == expected_value
|
|
25
|
+
results << { thread_id: thread_id, round: round, value: env[:value] }
|
|
26
|
+
else
|
|
27
|
+
errors << { thread_id: thread_id, round: round, env: env, expected: expected_value }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
threads.each(&:join)
|
|
35
|
+
|
|
36
|
+
expect(errors).to eq([])
|
|
37
|
+
expect(results.size).to eq(n_threads * rounds_per_thread)
|
|
38
|
+
seen = {}
|
|
39
|
+
results.each do |r|
|
|
40
|
+
key = [r[:thread_id], r[:round]]
|
|
41
|
+
expect(seen[key]).to be_nil
|
|
42
|
+
seen[key] = true
|
|
43
|
+
expect(r[:value]).to eq(r[:thread_id] * 1000 + r[:round])
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Phase 4: nested bridge spec. Callback invokes eval_r_with_result; assert inner and outer both get correct results (no cross-talk, no deadlock).
|
|
3
|
+
|
|
4
|
+
require 'galaaz'
|
|
5
|
+
|
|
6
|
+
describe "Bridge nested access (Phase 4)" do
|
|
7
|
+
|
|
8
|
+
it "allows nested eval_r_with_result from callback and returns correct inner and outer results" do
|
|
9
|
+
bridge = R.bridge
|
|
10
|
+
inner_envelope = nil
|
|
11
|
+
|
|
12
|
+
# Callback runs inside R's lapply; it calls eval_r_with_result (nested) and we capture the result
|
|
13
|
+
result = R.lapply(R.c(1), (proc do |_x|
|
|
14
|
+
inner_envelope = bridge.eval_r_with_result("g2_v_inner <- 200L")
|
|
15
|
+
33
|
|
16
|
+
end))
|
|
17
|
+
|
|
18
|
+
expect(inner_envelope).not_to be_nil
|
|
19
|
+
expect(inner_envelope[:type]).to eq(:scalar_integer)
|
|
20
|
+
expect(inner_envelope[:value]).to eq(200)
|
|
21
|
+
|
|
22
|
+
# Outer lapply returns a list (handle); we can at least treat it as an R object
|
|
23
|
+
expect(result).to be_a(R::Object)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'galaaz'
|
|
4
|
+
|
|
5
|
+
describe R::DataFrame do
|
|
6
|
+
context 'creation and basic access' do
|
|
7
|
+
it 'creates a data.frame from a shaped vector' do
|
|
8
|
+
vec = R.seq(6)
|
|
9
|
+
vec.dim = R.c(2, 3)
|
|
10
|
+
|
|
11
|
+
df = vec.as__data__frame
|
|
12
|
+
expect(df).to be_a(R::DataFrame)
|
|
13
|
+
expect(df[1, 'V1']).to eq 1
|
|
14
|
+
expect(df[1, 'V2']).to eq 3
|
|
15
|
+
expect(df[1, :all].as__numeric).to eq R.c(1.0, 3, 5)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
context "subsetting with '[' and '[['" do
|
|
20
|
+
before(:each) do
|
|
21
|
+
@mtcars = ~R[:mtcars]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'subsets a single column by index' do
|
|
25
|
+
slice = @mtcars[1]
|
|
26
|
+
expect(slice).to be_a(R::DataFrame)
|
|
27
|
+
expect(slice.length).to eq 1
|
|
28
|
+
expect(slice[[1]][1]).to eq 21.0
|
|
29
|
+
expect(slice[[1, 1]]).to eq 21.0
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'raises bridge process error for invalid column selection with []' do
|
|
33
|
+
slice = @mtcars[1]
|
|
34
|
+
expect { slice['Mazda RX4'] }.to raise_error(NewBridge::SessionClient::RProcessError)
|
|
35
|
+
expect(slice[['Mazda RX4']]).to eq nil
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'supports row+column by names and indices' do
|
|
39
|
+
expect(@mtcars[1, 1]).to eq 21.0
|
|
40
|
+
expect(@mtcars['Merc 450SL', 'drat']).to eq 3.07
|
|
41
|
+
expect(@mtcars[['Valiant', 'mpg']]).to eq 18.1
|
|
42
|
+
expect(@mtcars[[6, 5]]).to eq 2.76
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'supports drop parameter for row extraction' do
|
|
46
|
+
lst = @mtcars[1, :all, drop: true]
|
|
47
|
+
expect(lst).to be_a(R::List)
|
|
48
|
+
expect(lst[[1]]).to eq 21.0
|
|
49
|
+
expect(lst[1]).to eq R.list(mpg: 21.0)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context "assignment with '[<-'" do
|
|
54
|
+
before(:each) do
|
|
55
|
+
@mtcars = ~R[:mtcars]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'adds a column and updates cells by index' do
|
|
59
|
+
@mtcars['New Column'] = R.c((1..32))
|
|
60
|
+
expect(@mtcars[[1, 12]]).to eq 1
|
|
61
|
+
expect(@mtcars[['Mazda RX4', 'New Column']]).to eq 1
|
|
62
|
+
|
|
63
|
+
@mtcars[17, 6] = 1000
|
|
64
|
+
expect(@mtcars[[17, 6]]).to eq 1000.0
|
|
65
|
+
expect(@mtcars[['Chrysler Imperial', 'wt']]).to eq 1000.0
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
context 'iteration helpers' do
|
|
70
|
+
it 'iterates columns with each_column and exposes column names' do
|
|
71
|
+
mtcars = ~R[:mtcars]
|
|
72
|
+
seen = {}
|
|
73
|
+
|
|
74
|
+
mtcars.each_column do |col, col_name|
|
|
75
|
+
seen[col_name] = col[1] if %w[mpg cyl disp].include?(col_name)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
expect(seen['mpg']).to eq 21.0
|
|
79
|
+
expect(seen['cyl']).to eq 6.0
|
|
80
|
+
expect(seen['disp']).to eq 160.0
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'iterates rows with each_row and exposes row names' do
|
|
84
|
+
mtcars = ~R[:mtcars]
|
|
85
|
+
seen = {}
|
|
86
|
+
|
|
87
|
+
mtcars.each_row do |row, row_name|
|
|
88
|
+
if ['Mazda RX4', 'Merc 240D'].include?(row_name)
|
|
89
|
+
seen[row_name] = [row[['mpg']], row[['hp']]]
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
expect(seen['Mazda RX4']).to eq([21.0, 110.0])
|
|
94
|
+
expect(seen['Merc 240D']).to eq([24.4, 62.0])
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
context 'bootstrap-style row reordering' do
|
|
99
|
+
before(:each) do
|
|
100
|
+
@df = R.data__frame(
|
|
101
|
+
x: R.rep((1..3), each: 2),
|
|
102
|
+
y: (6..1),
|
|
103
|
+
z: R.factor((~R[:letters])[(1..6)])
|
|
104
|
+
)
|
|
105
|
+
R.set__seed(10)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it 'reorders rows using sampled integer indices' do
|
|
109
|
+
table = @df[R.sample(@df.nrow), :all]
|
|
110
|
+
expect(table.x[3]).to eq 1
|
|
111
|
+
expect(table.y[2]).to eq 6
|
|
112
|
+
expect(table.z.levels[table.z[4]]).to eq 'f'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it 'selects a sampled subset of rows' do
|
|
116
|
+
table = @df[R.sample(@df.nrow, 3), :all]
|
|
117
|
+
expect(table.x[3]).to eq 1
|
|
118
|
+
expect(table.y[1]).to eq 4
|
|
119
|
+
expect(table.z.levels[table.z[2]]).to eq 'a'
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'galaaz'
|
|
4
|
+
|
|
5
|
+
describe 'DataFrame single-index logical filtering' do
|
|
6
|
+
it 'treats df[logical_expression] as row filter with all columns' do
|
|
7
|
+
df = R.data__frame(
|
|
8
|
+
origin: R.c('JFK', 'LGA', 'JFK'),
|
|
9
|
+
month: R.c(6, 6, 7),
|
|
10
|
+
value: R.c(1, 2, 3)
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
out = df[(R[:origin].eq('JFK')) & (R[:month].eq(6))]
|
|
14
|
+
n = out.nrow >> 0
|
|
15
|
+
origins = out.origin >> nil
|
|
16
|
+
origins = [origins] unless origins.is_a?(Array)
|
|
17
|
+
|
|
18
|
+
expect(n).to eq(1)
|
|
19
|
+
expect(origins).to eq(['JFK'])
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'galaaz'
|
|
4
|
+
|
|
5
|
+
describe 'dispatch_probe per-handle cache (Phase 3)' do
|
|
6
|
+
it 'reuses cached probe for the same object and method name' do
|
|
7
|
+
df = R.data__frame(a: R.c(1, 2, 3))
|
|
8
|
+
bridge = R.bridge
|
|
9
|
+
calls = 0
|
|
10
|
+
allow(bridge).to receive(:dispatch_probe).and_wrap_original do |m, h, n|
|
|
11
|
+
calls += 1
|
|
12
|
+
m.call(h, n)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
R::Support.reset_dispatch_probe_cache_stats!
|
|
16
|
+
R::Support.clear_dispatch_probe_handle_cache!
|
|
17
|
+
|
|
18
|
+
x1 = df.a
|
|
19
|
+
x2 = df.a
|
|
20
|
+
expect(x1.unboxed_get(0)).to eq(1)
|
|
21
|
+
expect(x2.unboxed_get(0)).to eq(1)
|
|
22
|
+
expect(calls).to eq(1)
|
|
23
|
+
expect(R::Support.dispatch_probe_cache_hits).to be >= 1
|
|
24
|
+
expect(R::Support.dispatch_probe_cache_misses).to eq(1)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'does not use handle cache for R.foo module calls (no probe)' do
|
|
28
|
+
bridge = R.bridge
|
|
29
|
+
allow(bridge).to receive(:dispatch_probe).and_call_original
|
|
30
|
+
|
|
31
|
+
R::Support.reset_dispatch_probe_cache_stats!
|
|
32
|
+
R::Support.clear_dispatch_probe_handle_cache!
|
|
33
|
+
|
|
34
|
+
R.c(1, 2)
|
|
35
|
+
R.c(3, 4)
|
|
36
|
+
expect(bridge).not_to have_received(:dispatch_probe)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'galaaz'
|
|
4
|
+
|
|
5
|
+
describe 'dispatch_probe error-class fallback' do
|
|
6
|
+
it 'falls back when dispatch_probe raises bridge RProcessError' do
|
|
7
|
+
ok = R::Support.eval("requireNamespace('dplyr', quietly=TRUE)")
|
|
8
|
+
skip 'dplyr is not available' unless ok == true
|
|
9
|
+
R.library('dplyr')
|
|
10
|
+
|
|
11
|
+
bridge = R.bridge
|
|
12
|
+
allow(bridge).to receive(:dispatch_probe).and_raise(
|
|
13
|
+
NewBridge::SessionClient::RProcessError, 'invalid dispatch_probe params'
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
df = R.data__frame(g1: R.c('x', 'x', 'y'), a: R.c(1, 2, 3))
|
|
17
|
+
out = df.group_by(:g1).summarise(a: E.mean(:a))
|
|
18
|
+
expect(out.nrow >> 0).to eq(2)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'galaaz'
|
|
4
|
+
|
|
5
|
+
describe 'dispatch_probe fallback for method names' do
|
|
6
|
+
it 'falls back to function dispatch when dispatch_probe rejects params' do
|
|
7
|
+
ok = R::Support.eval("requireNamespace('dplyr', quietly=TRUE)")
|
|
8
|
+
skip 'dplyr is not available' unless ok == true
|
|
9
|
+
R.library('dplyr')
|
|
10
|
+
|
|
11
|
+
df = R.data__frame(g1: R.c('x', 'x', 'y'), a: R.c(1, 2, 3))
|
|
12
|
+
group_var = :g1
|
|
13
|
+
|
|
14
|
+
out = df.group_by(group_var).summarise(a: E.mean(:a))
|
|
15
|
+
n = out.nrow >> 0
|
|
16
|
+
expect(n).to eq(2)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'galaaz'
|
|
4
|
+
|
|
5
|
+
describe R::Environment do
|
|
6
|
+
def new_env
|
|
7
|
+
R::Support.eval('new.env(parent = emptyenv())')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
context 'creation and key/value operations' do
|
|
11
|
+
it 'creates an environment handle from new.env()' do
|
|
12
|
+
env = new_env
|
|
13
|
+
expect(env).to be_a(R::Environment)
|
|
14
|
+
expect(env.typeof).to eq R.c('environment')
|
|
15
|
+
expect(env.rclass).to eq R.c('environment')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'supports set/get and dot assignment accessors' do
|
|
19
|
+
env = new_env
|
|
20
|
+
|
|
21
|
+
env.set(:a, 25)
|
|
22
|
+
expect(env.get(:a)).to eq 25
|
|
23
|
+
|
|
24
|
+
env.b = 33
|
|
25
|
+
expect(env.b).to eq 33
|
|
26
|
+
|
|
27
|
+
env.vec = R.c(1, 2, 3, 4)
|
|
28
|
+
expect(env.vec).to eq R.c(1, 2, 3, 4)
|
|
29
|
+
expect(R.ls(envir: env).all__equal(R.c('a', 'b', 'vec'))).to eq true
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'supports env_names from environment object and R helper (legacy Galaaz)' do
|
|
33
|
+
env = new_env
|
|
34
|
+
expect(env.env_names.length).to eq 0
|
|
35
|
+
expect(R.env_names(env).length).to eq 0
|
|
36
|
+
|
|
37
|
+
env.a = 30
|
|
38
|
+
env.vec = R.c(1, 2, 3, 4)
|
|
39
|
+
expect(env.env_names.length).to eq 2
|
|
40
|
+
expect(R.env_names(env).all__equal(R.c('a', 'vec'))).to eq true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'supports element lookup with [[]] by name' do
|
|
44
|
+
env = new_env
|
|
45
|
+
env.a = 'This is a string'
|
|
46
|
+
expect(env[['a']]).to eq R.c('This is a string')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'allows multiple names to reference the same assigned object' do
|
|
50
|
+
env = new_env
|
|
51
|
+
env.d = R.c(1, 2, 3)
|
|
52
|
+
env.a = env.d
|
|
53
|
+
expect(env.a).to eq R.c(1, 2, 3)
|
|
54
|
+
expect(env.d).to eq R.c(1, 2, 3)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context 'remove and invalid subsetting semantics' do
|
|
59
|
+
it 'removes an environment binding with rm()' do
|
|
60
|
+
env = new_env
|
|
61
|
+
env.a = false
|
|
62
|
+
env.b = 'x'
|
|
63
|
+
expect(env.a).to eq false
|
|
64
|
+
|
|
65
|
+
R.rm('a', envir: env)
|
|
66
|
+
expect { env.a }.to raise_error(NoMethodError)
|
|
67
|
+
expect(R.ls(envir: env).all__equal(R.c('b'))).to eq true
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
it "raises bridge process error when using [] on environment" do
|
|
71
|
+
env = new_env
|
|
72
|
+
env.a = 1
|
|
73
|
+
expect { env['a'] }.to raise_error(NewBridge::SessionClient::RProcessError)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
context 'expression evaluation in environment context' do
|
|
78
|
+
it 'evaluates expression against environment bindings when parent has base operators' do
|
|
79
|
+
env = R::Support.eval('new.env(parent = baseenv())')
|
|
80
|
+
env.e1 = 10
|
|
81
|
+
env.e2 = 20
|
|
82
|
+
env.e3 = R.c(1, 2, 3, 4)
|
|
83
|
+
|
|
84
|
+
expr = R[:e1] + R[:e2] + R[:e3]
|
|
85
|
+
expect(expr.to_s).to eq('e1 + e2 + e3')
|
|
86
|
+
expect(expr.eval(env)).to eq R.c(31, 32, 33, 34)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Specs for field/component access: we use R's [[ (obj[["name"]]) instead of $
|
|
3
|
+
# so that atomic vectors don't trigger "$ operator is invalid for atomic vectors".
|
|
4
|
+
# Run with: bin/run_rspec specs/field_access_spec.rb
|
|
5
|
+
|
|
6
|
+
require 'galaaz'
|
|
7
|
+
|
|
8
|
+
describe "Field access (obj.name → R [[, not $)" do
|
|
9
|
+
|
|
10
|
+
context "list with named elements" do
|
|
11
|
+
it "returns element when accessed by method (list.fig__ext)" do
|
|
12
|
+
lst = R.list(a: 1, b: 2, fig__ext: "png")
|
|
13
|
+
expect(lst.fig__ext).to be_a(R::Object)
|
|
14
|
+
expect(lst.fig__ext >> 0).to eq "png"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "returns element for other names (list.a, list.b)" do
|
|
18
|
+
lst = R.list(a: 10, b: 20)
|
|
19
|
+
expect(lst.a >> 0).to eq 10
|
|
20
|
+
expect(lst.b >> 0).to eq 20
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context "data frame column access" do
|
|
25
|
+
it "returns column when accessed by method (df.mpg)" do
|
|
26
|
+
df = ~R[:mtcars]
|
|
27
|
+
expect(df.mpg).to be_a(R::Vector)
|
|
28
|
+
expect(df.mpg.length >> 0).to be >= 1
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/specs/figures/bg.jpeg
CHANGED
|
Binary file
|
data/specs/figures/bg.png
CHANGED
|
Binary file
|