galaaz 2.1.7 → 2.1.9

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 (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -0
  3. data/Rakefile +20 -2
  4. data/bin/check_gemfile_lock_version +46 -0
  5. data/bin/release_bump +26 -0
  6. data/blogs/README.md +4 -0
  7. data/blogs/galaaz_2_0/galaaz_2_0.Rmd +385 -0
  8. data/blogs/galaaz_2_0/galaaz_2_0.md +409 -0
  9. data/blogs/galaaz_2_0/galaaz_2_0.tex +756 -0
  10. data/blogs/galaaz_2_0/images/galaaz-header.png +0 -0
  11. data/blogs/galaaz_2_0/images/galaaz-lockup-stacked.png +0 -0
  12. data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +76 -58
  13. data/blogs/galaaz_ggplot/galaaz_ggplot.md +188 -161
  14. data/blogs/galaaz_ggplot/galaaz_ggplot.tex +185 -117
  15. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/midwest_rb.png +0 -0
  16. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-html/scatter_plot_rb.png +0 -0
  17. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/midwest_rb.png +0 -0
  18. data/blogs/galaaz_ggplot/galaaz_ggplot_files/figure-markdown_github/scatter_plot_rb.png +0 -0
  19. data/blogs/galaaz_ggplot/images/galaaz-lockup-stacked.png +0 -0
  20. data/blogs/gknit/gknit.Rmd +48 -28
  21. data/blogs/gknit/gknit.md +60 -43
  22. data/blogs/gknit/gknit.tex +1409 -0
  23. data/blogs/gknit/gknit_files/figure-html/bubble-1.png +0 -0
  24. data/blogs/gknit/gknit_files/figure-html/diverging_bar.png +0 -0
  25. data/blogs/gknit/gknit_files/figure-latex/bubble-1.png +0 -0
  26. data/blogs/gknit/images/galaaz-lockup-stacked.png +0 -0
  27. data/blogs/manual/images/galaaz-lockup-stacked.png +0 -0
  28. data/blogs/manual/manual.Rmd +161 -71
  29. data/blogs/manual/manual.md +573 -482
  30. data/blogs/manual/manual.tex +1113 -517
  31. data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
  32. data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
  33. data/blogs/manual/manual_files/figure-markdown_github/bubble-1.png +0 -0
  34. data/blogs/manual/manual_files/figure-markdown_github/diverging_bar.png +0 -0
  35. data/blogs/nse_dplyr/images/galaaz-lockup-stacked.png +0 -0
  36. data/blogs/nse_dplyr/nse_dplyr.Rmd +42 -8
  37. data/blogs/nse_dplyr/nse_dplyr.md +69 -50
  38. data/blogs/nse_dplyr/nse_dplyr.tex +1626 -0
  39. data/blogs/oh_my/images/galaaz-lockup-stacked.png +0 -0
  40. data/blogs/oh_my/oh_my.Rmd +206 -55
  41. data/blogs/oh_my/oh_my.md +247 -96
  42. data/blogs/oh_my/oh_my.tex +2038 -93
  43. data/blogs/r_on_rails_ledger/images/00_portfolio_page.png +0 -0
  44. data/blogs/r_on_rails_ledger/images/01_results_panel.png +0 -0
  45. data/blogs/r_on_rails_ledger/images/02_density_tail_risk.png +0 -0
  46. data/blogs/r_on_rails_ledger/images/03_mc_cone.png +0 -0
  47. data/blogs/r_on_rails_ledger/images/04_rolling_var.png +0 -0
  48. data/blogs/r_on_rails_ledger/images/galaaz-lockup-stacked.png +0 -0
  49. data/blogs/r_on_rails_ledger/r_on_rails_ledger.Rmd +354 -0
  50. data/blogs/r_on_rails_ledger/r_on_rails_ledger.md +365 -0
  51. data/blogs/r_on_rails_ledger/r_on_rails_ledger.tex +670 -0
  52. data/blogs/ruby_plot/images/galaaz-lockup-stacked.png +0 -0
  53. data/blogs/ruby_plot/ruby_plot.Rmd +56 -35
  54. data/blogs/ruby_plot/ruby_plot.md +63 -47
  55. data/blogs/ruby_plot/ruby_plot.tex +194 -125
  56. data/blogs/ruby_plot/ruby_plot_files/figure-html/dose_len.png +0 -0
  57. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_delivery.png +0 -0
  58. data/blogs/ruby_plot/ruby_plot_files/figure-html/facet_by_dose.png +0 -0
  59. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color.png +0 -0
  60. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_by_delivery_color2.png +0 -0
  61. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_decorations.png +0 -0
  62. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
  63. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_points.png +0 -0
  64. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_box_plot.png +0 -0
  65. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
  66. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
  67. data/blogs/ruby_plot/ruby_plot_files/figure-latex/dose_len.png +0 -0
  68. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
  69. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
  70. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
  71. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
  72. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
  73. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
  74. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
  75. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
  76. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
  77. data/blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
  78. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/dose_len.png +0 -0
  79. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facet_by_delivery.png +0 -0
  80. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facet_by_dose.png +0 -0
  81. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_by_delivery_color.png +0 -0
  82. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_by_delivery_color2.png +0 -0
  83. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_decorations.png +0 -0
  84. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
  85. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_points.png +0 -0
  86. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/final_box_plot.png +0 -0
  87. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
  88. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
  89. data/lib/galaaz/cli.rb +98 -13
  90. data/logos/icon-font/README.md +27 -0
  91. data/logos/icon-font/build_font.py +130 -0
  92. data/logos/icon-font/galaaz-mark.svg +34 -0
  93. data/script/omarchy/README.md +9 -2
  94. data/script/omarchy/fonts/galaaz.ttf +0 -0
  95. data/script/omarchy/galaaz-guide.sh +1 -1
  96. data/script/omarchy/install-galaaz.sh +8 -1
  97. data/script/omarchy/omarchy-menu.jsonc +21 -9
  98. data/sty/galaaz-header.png +0 -0
  99. data/sty/galaaz-headers-from-p3.tex +4 -0
  100. data/sty/galaaz.sty +76 -23
  101. data/version.rb +1 -1
  102. metadata +46 -7
  103. data/blogs/galaaz_ggplot/galaaz_ggplot.log +0 -754
  104. data/blogs/manual/manual.log +0 -1786
  105. data/blogs/nse_dplyr/nse_dplyr.log +0 -928
  106. data/blogs/oh_my/oh_my.log +0 -804
  107. data/blogs/ruby_plot/ruby_plot.log +0 -885
data/blogs/oh_my/oh_my.md CHANGED
@@ -9,9 +9,17 @@ output:
9
9
  html_document:
10
10
  self_contained: true
11
11
  keep_md: true
12
+ toc: true
13
+ toc_float: true
14
+ toc_depth: 2
15
+ number_sections: true
16
+ includes:
17
+ before_body: _logo_before_body.html
12
18
  pdf_document:
13
19
  includes:
14
- in_header: "../../sty/galaaz.sty"
20
+ in_header:
21
+ - "../../sty/galaaz.sty"
22
+ - "../../sty/galaaz-headers-from-p3.tex"
15
23
  keep_tex: yes
16
24
  number_sections: yes
17
25
  toc: true
@@ -21,6 +29,8 @@ fontsize: 11pt
21
29
 
22
30
 
23
31
 
32
+
33
+
24
34
  # Introduction
25
35
 
26
36
  This paper introduces and compares Galaaz with R's S4. It is **modeled closely** on
@@ -77,6 +87,8 @@ keyword 'attr_reader' and a colom before the variables name:
77
87
 
78
88
 
79
89
 
90
+
91
+
80
92
  ``` ruby
81
93
  class Trajectories
82
94
  attr_reader :times
@@ -102,7 +114,7 @@ puts @traj
102
114
  ```
103
115
 
104
116
  ```
105
- ## #<RC::Trajectories:0x1e6bdce4>
117
+ ## #<RC::Trajectories:0x3cbcf7a0>
106
118
  ```
107
119
 
108
120
  To see the contents of an object, one needs to access its components using the '.' operator:
@@ -161,7 +173,8 @@ one uses the ':' operator after parameter's name as we can see below:
161
173
  @traj = Trajectories.new(times: R.c(1, 2, 3, 4))
162
174
 
163
175
  # Create a Trajectories with times and matrix
164
- @traj2 = Trajectories.new(times: R.c(1, 3), matrix: R.matrix((1..4), ncol: 2))
176
+ @traj2 = Trajectories.new(times: R.c(1, 3), matrix: R.matrix((1..4),
177
+ ncol: 2))
165
178
  ```
166
179
 
167
180
  # Access to Instance Variables (to reach a slot)
@@ -222,7 +235,8 @@ Cochin and Saint-Anne. We first show the code in R and the corresponding Galaaz
222
235
  + times=c(1: 10, (6: 16) *2),
223
236
  + traj=rbind(
224
237
  + matrix (seq (16,19, length=21), ncol=21, nrow=50, byrow=TRUE),
225
- + matrix (seq (15.8, 18, length=21), ncol=21, nrow=30, byrow=TRUE)
238
+ + matrix (seq (15.8, 18, length=21), ncol=21, nrow=30,
239
+ byrow=TRUE)
226
240
  + )+rnorm (21*80,0,0.2)
227
241
  + )
228
242
  ```
@@ -241,12 +255,16 @@ This same code in Galaaz becomes:
241
255
  R.c(15.7, 15.6, 15.8, 16)))
242
256
 
243
257
  @trajStAnne =
244
- Trajectories.new(times: R.c((1..10), R.c(6..16) * 2),
245
- matrix: (R.rbind(
246
- R.matrix(R.seq(16, 19, length: 21), ncol: 21,
247
- nrow: 50, byrow: true),
248
- R.matrix(R.seq(15.8, 18, length: 21), ncol: 21,
249
- nrow: 30, byrow: true)) + R.rnorm(21*80, 0, 0.2)))
258
+ Trajectories.new(
259
+ times: R.c((1..10), R.c(6..16) * 2),
260
+ matrix: (
261
+ R.rbind(
262
+ R.matrix(R.seq(16, 19, length: 21),
263
+ ncol: 21, nrow: 50, byrow: true),
264
+ R.matrix(R.seq(15.8, 18, length: 21),
265
+ ncol: 21, nrow: 30, byrow: true)
266
+ ) + R.rnorm(21 * 80, 0, 0.2)
267
+ ))
250
268
  ```
251
269
 
252
270
  Let's check that the 'times' and 'matrix' instance variables were correctly set:
@@ -264,10 +282,10 @@ puts @trajStAnne.times
264
282
  ## [1] 1 3 4 5
265
283
  ##
266
284
  ## [,1] [,2] [,3] [,4]
267
- ## g2_v662 15.0 15.1 15.2 15.2
268
- ## g2_v663 16.0 15.9 16.0 16.4
269
- ## g2_v664 15.2 NA 15.3 15.3
270
- ## g2_v665 15.7 15.6 15.8 16.0
285
+ ## g2_v729 15.0 15.1 15.2 15.2
286
+ ## g2_v730 16.0 15.9 16.0 16.4
287
+ ## g2_v731 15.2 NA 15.3 15.3
288
+ ## g2_v732 15.7 15.6 15.8 16.0
271
289
  ##
272
290
  ## [1] 1 2 3 4 5 6 7 8 9 10 12 14 16 18 20 22 24 26 28 30 32
273
291
  ```
@@ -466,10 +484,10 @@ end
466
484
  ## 5
467
485
  ## traj =
468
486
  ## [,1] [,2] [,3] [,4]
469
- ## g2_v662 15.0 15.1 15.2 15.2
470
- ## g2_v663 16.0 15.9 16.0 16.4
471
- ## g2_v664 15.2 NA 15.3 15.3
472
- ## g2_v665 15.7 15.6 15.8 16.0
487
+ ## g2_v729 15.0 15.1 15.2 15.2
488
+ ## g2_v730 16.0 15.9 16.0 16.4
489
+ ## g2_v731 15.2 NA 15.3 15.3
490
+ ## g2_v732 15.7 15.6 15.8 16.0
473
491
  ## ******* End Print (trajectories) *******
474
492
  ```
475
493
 
@@ -541,7 +559,8 @@ class Trajectories
541
559
  nrow_show = [10, @matrix.nrow >> 0].min
542
560
  ncol_show = R.min(10, @matrix.ncol) >> 0
543
561
  puts("* Traj (limited to a matrix 10x10) = ")
544
- puts @matrix[(1..nrow_show), (1..ncol_show)].format(digits: 2, nsmall: 2)
562
+ puts @matrix[(1..nrow_show), (1..ncol_show)].format(digits: 2,
563
+ nsmall: 2)
545
564
  puts("******* End Show (trajectories) ******* ")
546
565
  end
547
566
 
@@ -577,28 +596,28 @@ end
577
596
  ## 30
578
597
  ## 32
579
598
  ## * Traj (limited to a matrix 10x10) =
580
- ## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
581
- ## [1,] "15.95" "16.15" "16.25" "16.62" "16.86" "16.77" "16.80" "16.94" "17.26"
582
- ## [2,] "16.20" "16.11" "16.37" "16.50" "16.70" "16.71" "17.12" "16.89" "17.37"
583
- ## [3,] "15.94" "16.20" "16.51" "16.41" "16.86" "16.83" "16.99" "16.86" "17.22"
584
- ## [4,] "15.64" "16.25" "16.31" "16.36" "16.69" "16.47" "17.06" "16.86" "17.22"
585
- ## [5,] "16.44" "16.01" "16.08" "16.48" "16.39" "16.43" "17.06" "17.28" "17.40"
586
- ## [6,] "16.10" "15.78" "16.26" "16.31" "16.71" "16.81" "16.81" "16.84" "17.04"
587
- ## [7,] "15.98" "15.94" "16.44" "16.96" "16.40" "17.10" "17.06" "17.45" "16.89"
588
- ## [8,] "16.29" "16.00" "16.28" "16.29" "16.49" "16.73" "16.72" "17.26" "17.48"
589
- ## [9,] "16.12" "16.36" "16.53" "16.52" "16.68" "16.75" "16.89" "17.05" "16.98"
590
- ## [10,] "15.92" "16.32" "16.39" "16.28" "16.61" "17.05" "17.09" "17.39" "17.33"
591
- ## [,10]
592
- ## [1,] "17.80"
593
- ## [2,] "17.37"
594
- ## [3,] "17.54"
595
- ## [4,] "17.79"
596
- ## [5,] "17.75"
597
- ## [6,] "17.62"
598
- ## [7,] "16.97"
599
- ## [8,] "17.33"
600
- ## [9,] "17.50"
601
- ## [10,] "17.33"
599
+ ## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
600
+ ## [1,] "15.85" "16.10" "16.34" "16.33" "16.58" "16.91" "16.89" "16.99"
601
+ ## [2,] "15.67" "16.28" "16.37" "16.34" "16.31" "16.39" "17.19" "16.84"
602
+ ## [3,] "16.02" "16.03" "16.40" "16.52" "16.68" "16.99" "16.87" "17.26"
603
+ ## [4,] "15.99" "16.24" "16.30" "16.38" "16.76" "16.84" "16.60" "16.96"
604
+ ## [5,] "15.89" "15.96" "16.43" "16.68" "16.48" "16.68" "16.87" "16.59"
605
+ ## [6,] "16.35" "15.97" "16.04" "16.65" "16.66" "16.58" "16.95" "17.01"
606
+ ## [7,] "16.17" "16.22" "16.37" "16.34" "16.53" "16.34" "16.93" "16.96"
607
+ ## [8,] "15.98" "15.97" "16.08" "16.49" "16.91" "16.97" "16.91" "17.43"
608
+ ## [9,] "16.49" "16.26" "16.08" "16.44" "16.57" "16.92" "17.14" "17.46"
609
+ ## [10,] "16.10" "15.95" "16.19" "16.16" "16.66" "16.99" "17.03" "17.12"
610
+ ## [,9] [,10]
611
+ ## [1,] "17.38" "17.30"
612
+ ## [2,] "17.00" "17.47"
613
+ ## [3,] "17.02" "17.28"
614
+ ## [4,] "17.06" "17.28"
615
+ ## [5,] "17.01" "17.14"
616
+ ## [6,] "16.95" "17.14"
617
+ ## [7,] "17.02" "17.08"
618
+ ## [8,] "17.15" "17.67"
619
+ ## [9,] "17.06" "17.43"
620
+ ## [10,] "17.10" "17.57"
602
621
  ## ******* End Show (trajectories) *******
603
622
  ```
604
623
 
@@ -612,10 +631,20 @@ we try to 'show' it, it will generate an error. Let's see it:
612
631
 
613
632
 
614
633
  ``` ruby
615
- @empty_traj.show
634
+ begin
635
+ @empty_traj.show
636
+ rescue => e
637
+ # Short message only — full backtraces overflow PDF boxes.
638
+ puts e.class.to_s
639
+ # Wrap long messages for PDF code-box width.
640
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
641
+ end
616
642
  ```
617
643
 
618
644
  ```
645
+ ## *** Class Trajectories, method Show ***
646
+ ## times =
647
+ ## NoMethodError
619
648
  ## undefined method 'nrow' for nil
620
649
  ```
621
650
 
@@ -644,7 +673,8 @@ class Trajectories
644
673
  nrow_show = [10, @matrix.nrow >> 0].min
645
674
  ncol_show = R.min(10, @matrix.ncol) >> 0
646
675
  puts("* Traj (limited to a matrix 10x10) = ")
647
- puts @matrix[(1..nrow_show), (1..ncol_show)].format(digits: 2, nsmall: 2)
676
+ puts @matrix[(1..nrow_show), (1..ncol_show)].format(digits: 2,
677
+ nsmall: 2)
648
678
  puts("******* End Show (trajectories) ******* ")
649
679
  end
650
680
 
@@ -769,7 +799,8 @@ Here we show the R code for this validation:
769
799
  + validity=function(object){
770
800
  + cat("~~~ Trajectories: inspector ~~~ \\n")
771
801
  + if(length(object@times)!=ncol(object@traj)){
772
- + stop ("[Trajectories: validation] the number of temporal measurements does not correspond
802
+ + stop ("[Trajectories: validation] the number of temporal
803
+ + measurements does not correspond
773
804
  + }else{}
774
805
  + return(TRUE)
775
806
  + }
@@ -786,10 +817,14 @@ class Trajectories
786
817
  @times = times
787
818
  @matrix = matrix
788
819
 
789
- # validate the input, to make sure that size of @times and the number of columns in
790
- # @matrix are the same
820
+ # Validate: length(@times) must equal ncol(@matrix)
791
821
  puts ("~~~ Trajectories: inspector ~~~ ")
792
- raise "[Trajectories: validation] the number of temporal measurements does not correspond with the number of columns in the matrix" if ((@times.length >> 0) != (@matrix.ncol >> 0))
822
+ if ((@times.length >> 0) != (@matrix.ncol >> 0))
823
+ raise(
824
+ "[Trajectories: validation] the number of temporal " +
825
+ "measurements does not correspond with the number of " +
826
+ "columns in the matrix")
827
+ end
793
828
 
794
829
  # show the object just created
795
830
  show
@@ -805,7 +840,8 @@ validation was done and then print the object.
805
840
 
806
841
 
807
842
  ``` ruby
808
- ok = Trajectories.new(times: R.c(1..2), matrix: R.matrix((1..2), ncol: 2))
843
+ ok = Trajectories.new(times: R.c(1..2), matrix: R.matrix((1..2),
844
+ ncol: 2))
809
845
  ```
810
846
 
811
847
  ```
@@ -827,11 +863,22 @@ on exceptions on the web.
827
863
 
828
864
 
829
865
  ``` ruby
830
- error = Trajectories.new(times: R.c(1..3), matrix: R.matrix((1..2), ncol: 2))
866
+ begin
867
+ error = Trajectories.new(times: R.c(1..3), matrix: R.matrix((1..2),
868
+ ncol: 2))
869
+ rescue => e
870
+ # Short message only — full backtraces overflow PDF boxes.
871
+ puts e.class.to_s
872
+ # Wrap long messages for PDF code-box width.
873
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
874
+ end
831
875
  ```
832
876
 
833
877
  ```
834
- ## [Trajectories: validation] the number of temporal measurements does not correspond with the number of columns in the matrix
878
+ ## ~~~ Trajectories: inspector ~~~
879
+ ## RuntimeError
880
+ ## [Trajectories: validation] the number of temporal measurements does
881
+ ## not correspond with the number of columns in the matrix
835
882
  ```
836
883
 
837
884
  The validation above does not consider the case when an empty object is created. Here we will
@@ -863,12 +910,18 @@ class Trajectories
863
910
  def validate
864
911
 
865
912
  # Let's first check that we do not have an empty object
866
- raise "Neither times nor matrix can be an empty object" if (@times.nil? || @matrix.nil?)
913
+ if (@times.nil? || @matrix.nil?)
914
+ raise "Neither times nor matrix can be an empty object"
915
+ end
867
916
 
868
- # validate the input, to make sure that size of @times and the number of columns in
869
- # @matrix are the same
917
+ # Validate: length(@times) must equal ncol(@matrix)
870
918
  puts ("~~~ Trajectories: inspector ~~~ ")
871
- raise "[Trajectories: validation] the number of temporal measurements does not correspond with the number of columns in the matrix" if ((@times.length >> 0) != (@matrix.ncol >> 0))
919
+ if ((@times.length >> 0) != (@matrix.ncol >> 0))
920
+ raise(
921
+ "[Trajectories: validation] the number of temporal " +
922
+ "measurements does not correspond with the number of " +
923
+ "columns in the matrix")
924
+ end
872
925
 
873
926
  end
874
927
 
@@ -885,10 +938,18 @@ Let's try then creating an empty object:
885
938
 
886
939
 
887
940
  ``` ruby
888
- error = Trajectories.new
941
+ begin
942
+ error = Trajectories.new
943
+ rescue => e
944
+ # Short message only — full backtraces overflow PDF boxes.
945
+ puts e.class.to_s
946
+ # Wrap long messages for PDF code-box width.
947
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
948
+ end
889
949
  ```
890
950
 
891
951
  ```
952
+ ## RuntimeError
892
953
  ## Neither times nor matrix can be an empty object
893
954
  ```
894
955
 
@@ -896,10 +957,18 @@ Another example:
896
957
 
897
958
 
898
959
  ``` ruby
899
- error = Trajectories.new(times: 1)
960
+ begin
961
+ error = Trajectories.new(times: 1)
962
+ rescue => e
963
+ # Short message only — full backtraces overflow PDF boxes.
964
+ puts e.class.to_s
965
+ # Wrap long messages for PDF code-box width.
966
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
967
+ end
900
968
  ```
901
969
 
902
970
  ```
971
+ ## RuntimeError
903
972
  ## Neither times nor matrix can be an empty object
904
973
  ```
905
974
 
@@ -908,7 +977,8 @@ input:
908
977
 
909
978
 
910
979
  ``` ruby
911
- ok = Trajectories.new(times: R.c(1, 2), matrix: R.matrix((1..2), ncol: 2))
980
+ ok = Trajectories.new(times: R.c(1, 2), matrix: R.matrix((1..2),
981
+ ncol: 2))
912
982
  ```
913
983
 
914
984
  ```
@@ -962,13 +1032,19 @@ class Trajectories
962
1032
  def validate
963
1033
 
964
1034
  # Let's first check that we do not have an empty object
965
- raise "Neither times nor matrix can be an empty object" if (@times.nil? || @matrix.nil?)
1035
+ if (@times.nil? || @matrix.nil?)
1036
+ raise "Neither times nor matrix can be an empty object"
1037
+ end
966
1038
 
967
- # validate the input, to make sure that size of @times and the number of columns in
968
- # @matrix are the same
1039
+ # Validate: length(@times) must equal ncol(@matrix)
969
1040
  puts ("~~~ Trajectories: inspector ~~~ ")
970
1041
  tl = @times.length >> 0; mc = @matrix.ncol >> 0
971
- raise "[Trajectories: validation] the number of temporal measurements #{tl} does not correspond with the number of columns in the matrix #{mc}" if (tl != mc)
1042
+ if (tl != mc)
1043
+ raise(
1044
+ "[Trajectories: validation] the number of temporal " +
1045
+ "measurements #{tl} does not correspond with the number " +
1046
+ "of columns in the matrix #{mc}")
1047
+ end
972
1048
 
973
1049
  end
974
1050
 
@@ -1062,7 +1138,8 @@ end
1062
1138
 
1063
1139
 
1064
1140
  ``` ruby
1065
- @traj = Trajectories.new(times: R.c(1,2,4,8), matrix: R.matrix((1..8), nrow: 2))
1141
+ @traj = Trajectories.new(times: R.c(1,2,4,8), matrix: R.matrix((1..8),
1142
+ nrow: 2))
1066
1143
  ```
1067
1144
 
1068
1145
  ```
@@ -1085,11 +1162,22 @@ Trajectories or one in which the sizes are wrong:
1085
1162
 
1086
1163
 
1087
1164
  ``` ruby
1088
- error = Trajectories.new(times: R.c(1, 2, 48), matrix: R.matrix((1..8), nrow: 2))
1165
+ begin
1166
+ error = Trajectories.new(times: R.c(1, 2, 48), matrix: R.matrix((1..8),
1167
+ nrow: 2))
1168
+ rescue => e
1169
+ # Short message only — full backtraces overflow PDF boxes.
1170
+ puts e.class.to_s
1171
+ # Wrap long messages for PDF code-box width.
1172
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
1173
+ end
1089
1174
  ```
1090
1175
 
1091
1176
  ```
1092
- ## [Trajectories: validation] the number of temporal measurements 3 does not correspond with the number of columns in the matrix 4
1177
+ ## ~~~ Trajectories: inspector ~~~
1178
+ ## RuntimeError
1179
+ ## [Trajectories: validation] the number of temporal measurements 3 doe
1180
+ ## s not correspond with the number of columns in the matrix 4
1093
1181
  ```
1094
1182
 
1095
1183
  A constructor does not necessarily take the instance variable of the object as argument. For
@@ -1104,7 +1192,8 @@ First the code in R, we skip the definition of class TrajectoriesBis:
1104
1192
  > setMethod ("initialize",
1105
1193
  + "TrajectoriesBis",
1106
1194
  + function(.Object,nbWeek,BMIinit){
1107
- + traj <- outer(BMIinit,1:nbWeek,function(init,week){return(init+0.1*week)})
1195
+ + traj <- outer(BMIinit, 1:nbWeek,
1196
+ + function(init, week) { return(init + 0.1 * week) })
1108
1197
  + colnames(traj) <- paste("T",1:nbWeek,sep="")
1109
1198
  + rownames(traj) <- paste("I",1:nrow(traj),sep="")
1110
1199
  + .Object@times <- 1:nbWeek
@@ -1137,7 +1226,8 @@ class TrajectoriesBis
1137
1226
 
1138
1227
  def initialize(number_weeks, bmi_init)
1139
1228
  @matrix = bmi_init.outer((1..number_weeks),
1140
- R.eval("function(init, week) {return(init + 0.1 * week)}"))
1229
+ R.eval("function(init,
1230
+ week) {return(init + 0.1 * week)}"))
1141
1231
  @times = R.c((1..number_weeks))
1142
1232
  end
1143
1233
 
@@ -1170,7 +1260,9 @@ class TrajectoriesBis
1170
1260
 
1171
1261
  def initialize(number_weeks, bmi_init, increment)
1172
1262
  @matrix = bmi_init.outer((1..number_weeks),
1173
- R.eval("function(init, week) {return(init + #{increment} * week)}"))
1263
+ R.eval("function(init,
1264
+ week) {return(init +
1265
+ #{increment} * week)}"))
1174
1266
  @times = R.c((1..number_weeks))
1175
1267
  end
1176
1268
 
@@ -1206,7 +1298,8 @@ week, let's define a regular trajectory without having to define a TrajectoriesB
1206
1298
 
1207
1299
  ```
1208
1300
  > regularTrajectories <- function(nbWeek,BMIinit) {
1209
- + traj <- outer(BMIinit,1:nbWeek,function(init,week){return(init+0.1*week)})
1301
+ + traj <- outer(BMIinit, 1:nbWeek,
1302
+ + function(init, week) { return(init + 0.1 * week) })
1210
1303
  + times <- 1: nbWeek
1211
1304
  + return(new(Class="Trajectories",times=times,traj=traj))
1212
1305
  + }
@@ -1226,7 +1319,8 @@ class Trajectories
1226
1319
 
1227
1320
  def self.regular(number_weeks: nil, bmi_init: nil)
1228
1321
  matrix = bmi_init.outer((1..number_weeks),
1229
- R.eval("function(init, week) {return(init + 0.1 * week)}"))
1322
+ R.eval("function(init,
1323
+ week) {return(init + 0.1 * week)}"))
1230
1324
  times = R.c((1..number_weeks))
1231
1325
  Trajectories.new(times: times, matrix: matrix)
1232
1326
  end
@@ -1236,7 +1330,8 @@ end
1236
1330
 
1237
1331
 
1238
1332
  ``` ruby
1239
- @regular = Trajectories.regular(bmi_init: R.c(14, 15, 16), number_weeks: 3)
1333
+ @regular = Trajectories.regular(bmi_init: R.c(14, 15, 16),
1334
+ number_weeks: 3)
1240
1335
  ```
1241
1336
 
1242
1337
  ```
@@ -1425,7 +1520,12 @@ class Trajectories
1425
1520
  def times=(times)
1426
1521
  times = as_r(times)
1427
1522
  tl = times.length >> 0; mc = @matrix.ncol >> 0
1428
- raise "[Trajectories: validation] the number of temporal measurements #{tl} does not correspond with the number of columns in the matrix #{mc}" if (tl != mc)
1523
+ if (tl != mc)
1524
+ raise(
1525
+ "[Trajectories: validation] the number of temporal " +
1526
+ "measurements #{tl} does not correspond with the number " +
1527
+ "of columns in the matrix #{mc}")
1528
+ end
1429
1529
  @times = times
1430
1530
  end
1431
1531
 
@@ -1434,11 +1534,20 @@ end
1434
1534
 
1435
1535
 
1436
1536
  ``` ruby
1437
- @trajCochin.times = (1..5)
1537
+ begin
1538
+ @trajCochin.times = (1..5)
1539
+ rescue => e
1540
+ # Short message only — full backtraces overflow PDF boxes.
1541
+ puts e.class.to_s
1542
+ # Wrap long messages for PDF code-box width.
1543
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
1544
+ end
1438
1545
  ```
1439
1546
 
1440
1547
  ```
1441
- ## [Trajectories: validation] the number of temporal measurements 5 does not correspond with the number of columns in the matrix 4
1548
+ ## RuntimeError
1549
+ ## [Trajectories: validation] the number of temporal measurements 5 doe
1550
+ ## s not correspond with the number of columns in the matrix 4
1442
1551
  ```
1443
1552
 
1444
1553
  We now set the value appropriately and will not get any errors:
@@ -1587,9 +1696,9 @@ puts @partStAnne.part
1587
1696
  ```
1588
1697
 
1589
1698
  ```
1590
- ## [1] A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
1591
- ## [39] A A A A A A A A A A A A B B B B B B B B B B B B B B B B B B B B B B B B B B
1592
- ## [77] B B B B
1699
+ ## [1] A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
1700
+ ## [34] A A A A A A A A A A A A A A A A A B B B B B B B B B B B B B B B B
1701
+ ## [67] B B B B B B B B B B B B B B
1593
1702
  ## Levels: A B
1594
1703
  ```
1595
1704
 
@@ -1627,10 +1736,18 @@ both times and matrix to be non null.
1627
1736
 
1628
1737
 
1629
1738
  ``` ruby
1630
- @tdPitie = TrajPartitioned.new
1739
+ begin
1740
+ @tdPitie = TrajPartitioned.new
1741
+ rescue => e
1742
+ # Short message only — full backtraces overflow PDF boxes.
1743
+ puts e.class.to_s
1744
+ # Wrap long messages for PDF code-box width.
1745
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
1746
+ end
1631
1747
  ```
1632
1748
 
1633
1749
  ```
1750
+ ## RuntimeError
1634
1751
  ## Neither times nor matrix can be an empty object
1635
1752
  ```
1636
1753
 
@@ -1646,11 +1763,21 @@ And now let's create the TrajPartitioned:
1646
1763
 
1647
1764
 
1648
1765
  ``` ruby
1649
- @tdCochin = TrajPartitioned.new(times: R.c(1,3,4,5), matrix: @trajCochin.matrix,
1650
- list_partitions: R.list(@partCochin, @partCochin2))
1766
+ begin
1767
+ @tdCochin = TrajPartitioned.new(times: R.c(1,3,4,5),
1768
+ matrix: @trajCochin.matrix,
1769
+ list_partitions: R.list(@partCochin,
1770
+ @partCochin2))
1771
+ rescue => e
1772
+ # Short message only — full backtraces overflow PDF boxes.
1773
+ puts e.class.to_s
1774
+ # Wrap long messages for PDF code-box width.
1775
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
1776
+ end
1651
1777
  ```
1652
1778
 
1653
1779
  ```
1780
+ ## ArgumentError
1654
1781
  ## unknown keyword: :list_partitions
1655
1782
  ```
1656
1783
 
@@ -1662,11 +1789,21 @@ solution:
1662
1789
 
1663
1790
 
1664
1791
  ``` ruby
1665
- @tdCochin = TrajPartitioned.new(times: R.c(1,3,4,5), matrix: @trajCochin.matrix,
1666
- list_partitions: [@partCochin, @partCochin2])
1792
+ begin
1793
+ @tdCochin = TrajPartitioned.new(times: R.c(1,3,4,5),
1794
+ matrix: @trajCochin.matrix,
1795
+ list_partitions: [@partCochin,
1796
+ @partCochin2])
1797
+ rescue => e
1798
+ # Short message only — full backtraces overflow PDF boxes.
1799
+ puts e.class.to_s
1800
+ # Wrap long messages for PDF code-box width.
1801
+ e.message.to_s.scan(/.{1,68}/).each { |line| puts line }
1802
+ end
1667
1803
  ```
1668
1804
 
1669
1805
  ```
1806
+ ## ArgumentError
1670
1807
  ## unknown keyword: :list_partitions
1671
1808
  ```
1672
1809
 
@@ -1701,8 +1838,10 @@ Let's try our example again:
1701
1838
 
1702
1839
 
1703
1840
  ``` ruby
1704
- @tdCochin = TrajPartitioned.new(times: R.c(1,3,4,5), matrix: @trajCochin.matrix,
1705
- list_partitions: [@partCochin, @partCochin2])
1841
+ @tdCochin = TrajPartitioned.new(times: R.c(1,3,4,5),
1842
+ matrix: @trajCochin.matrix,
1843
+ list_partitions: [@partCochin,
1844
+ @partCochin2])
1706
1845
  ```
1707
1846
 
1708
1847
  ```
@@ -1739,7 +1878,9 @@ class TrajPartitioned
1739
1878
 
1740
1879
  def print
1741
1880
  super
1742
- puts ("the object also contains #{@list_partitions.length} partition")
1881
+ puts(
1882
+ "the object also contains " +
1883
+ "#{@list_partitions.length} partition")
1743
1884
  puts ("***** Fine of print (TrajPartitioned) *****")
1744
1885
  end
1745
1886
 
@@ -1906,15 +2047,18 @@ However, we will implement those classes in order to show Ruby's inheritance:
1906
2047
 
1907
2048
 
1908
2049
  ``` ruby
1909
- # Parent class. Differently from SS4, both 'nb_groups' and 'part' are defined in the
2050
+ # Parent class. Differently from SS4, both 'nb_groups' and 'part' are
2051
+ # defined in the
1910
2052
  # parent class.
1911
2053
  class PartitionFather
1912
2054
 
1913
2055
  attr_reader :nb_groups
1914
2056
  attr_reader :part
1915
2057
 
1916
- # initialize class PartitionFather with the number of groups and parts. Note that we
1917
- # use R.c for nb_groups in order to convert the number of groups into an R vector.
2058
+ # initialize class PartitionFather with the number of groups and
2059
+ # parts. Note that we
2060
+ # use R.c for nb_groups in order to convert the number of groups into
2061
+ # an R vector.
1918
2062
  def initialize(nb_groups: 0, part: nil)
1919
2063
  @nb_groups = R.c(nb_groups)
1920
2064
  @part = part
@@ -1925,7 +2069,8 @@ class PartitionFather
1925
2069
  @nb_groups * 2
1926
2070
  end
1927
2071
 
1928
- # method 'to_s' is called whenever we try to print a Ruby object. This method emulates
2072
+ # method 'to_s' is called whenever we try to print a Ruby object.
2073
+ # This method emulates
1929
2074
  # R 'print' method that prints all the slots.
1930
2075
  def to_s
1931
2076
  puts ("Variable 'nb_groups':")
@@ -1938,8 +2083,10 @@ class PartitionFather
1938
2083
 
1939
2084
  end
1940
2085
 
1941
- # Class PartitionSimple is a subclass of PartitionFather. To make a subclass of a
1942
- # class we use the operator '<'. Since the whole logic is in the parent class
2086
+ # Class PartitionSimple is a subclass of PartitionFather. To make a
2087
+ # subclass of a
2088
+ # class we use the operator '<'. Since the whole logic is in the parent
2089
+ # class
1943
2090
  # PartitionSimple is just an empty class
1944
2091
  class PartitionSimple < PartitionFather
1945
2092
 
@@ -1953,7 +2100,9 @@ end
1953
2100
 
1954
2101
 
1955
2102
  ``` ruby
1956
- @a = PartitionSimple.new(nb_groups: 3, part: ((~R[:LETTERS])[R.c(1, 2, 3, 2, 2, 1)].factor))
2103
+ @a = PartitionSimple.new(
2104
+ nb_groups: 3,
2105
+ part: ((~R[:LETTERS])[R.c(1, 2, 3, 2, 2, 1)].factor))
1957
2106
  puts @a
1958
2107
  ```
1959
2108
 
@@ -1965,7 +2114,7 @@ puts @a
1965
2114
  ## [1] A B C B B A
1966
2115
  ## Levels: A B C
1967
2116
  ##
1968
- ## #<RC::PartitionSimple:0x27371ac4>
2117
+ ## #<RC::PartitionSimple:0x5520a83a>
1969
2118
  ```
1970
2119
 
1971
2120
 
@@ -1979,7 +2128,9 @@ puts @a.nb_mult_two
1979
2128
 
1980
2129
 
1981
2130
  ``` ruby
1982
- @b = PartitionEval.new(nb_groups: 5, part: (~R[:LETTERS])[R.c(1, 5, 3, 4, 2, 4)].ordered)
2131
+ @b = PartitionEval.new(
2132
+ nb_groups: 5,
2133
+ part: (~R[:LETTERS])[R.c(1, 5, 3, 4, 2, 4)].ordered)
1983
2134
  puts @b
1984
2135
  ```
1985
2136
 
@@ -1991,7 +2142,7 @@ puts @b
1991
2142
  ## [1] A E C D B D
1992
2143
  ## Levels: A < B < C < D < E
1993
2144
  ##
1994
- ## #<RC::PartitionEval:0xe36882f>
2145
+ ## #<RC::PartitionEval:0x6b85a357>
1995
2146
  ```
1996
2147
 
1997
2148
 
@@ -2033,7 +2184,7 @@ puts @a
2033
2184
  ## [1] A B C B B A
2034
2185
  ## Levels: A B C
2035
2186
  ##
2036
- ## #<RC::PartitionSimple:0x27371ac4>
2187
+ ## #<RC::PartitionSimple:0x5520a83a>
2037
2188
  ```
2038
2189
 
2039
2190
  As can be seen, 'puts @a' now calls method 'to_s' defined in class PartitionSimple. This
@@ -2056,7 +2207,7 @@ puts @b
2056
2207
  ## [1] A E C D B D
2057
2208
  ## Levels: A < B < C < D < E
2058
2209
  ##
2059
- ## #<RC::PartitionEval:0xe36882f>
2210
+ ## #<RC::PartitionEval:0x6b85a357>
2060
2211
  ```
2061
2212
 
2062
2213
  # Internal Modification of an Object