0s autopkgtest [09:52:17]: starting date and time: 2024-05-24 09:52:17+0000 0s autopkgtest [09:52:17]: git checkout: 699e7f9f ssh-setup/nova: explicitely set 'fqdn' in cloud-init 0s autopkgtest [09:52:17]: host juju-7f2275-prod-proposed-migration-environment-3; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.ivc16gw1/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:r-cran-ggplot2 --apt-upgrade r-cran-matrixstats --timeout-short=300 --timeout-copy=20000 --timeout-build=20000 --env=ADT_TEST_TRIGGERS=r-cran-ggplot2/3.5.1+dfsg-1 -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor autopkgtest --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-3@bos01-s390x-2.secgroup --name adt-oracular-s390x-r-cran-matrixstats-20240524-095217-juju-7f2275-prod-proposed-migration-environment-3-a099fe50-f611-4cce-b3d8-efc19362545e --image adt/ubuntu-oracular-s390x-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-3 --net-id=net_prod-proposed-migration -e TERM=linux -e ''"'"'http_proxy=http://squid.internal:3128'"'"'' -e ''"'"'https_proxy=http://squid.internal:3128'"'"'' -e ''"'"'no_proxy=127.0.0.1,127.0.1.1,login.ubuntu.com,localhost,localdomain,novalocal,internal,archive.ubuntu.com,ports.ubuntu.com,security.ubuntu.com,ddebs.ubuntu.com,changelogs.ubuntu.com,keyserver.ubuntu.com,launchpadlibrarian.net,launchpadcontent.net,launchpad.net,10.24.0.0/24,keystone.ps5.canonical.com,objectstorage.prodstack5.canonical.com'"'"'' --mirror=http://us.ports.ubuntu.com/ubuntu-ports/ 455s autopkgtest [09:59:52]: testbed dpkg architecture: s390x 455s autopkgtest [09:59:52]: testbed apt version: 2.9.3 455s autopkgtest [09:59:52]: @@@@@@@@@@@@@@@@@@@@ test bed setup 456s Get:1 http://ftpmaster.internal/ubuntu oracular-proposed InRelease [73.9 kB] 457s Get:2 http://ftpmaster.internal/ubuntu oracular-proposed/restricted Sources [1964 B] 457s Get:3 http://ftpmaster.internal/ubuntu oracular-proposed/universe Sources [507 kB] 458s Get:4 http://ftpmaster.internal/ubuntu oracular-proposed/main Sources [57.4 kB] 458s Get:5 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse Sources [3388 B] 458s Get:6 http://ftpmaster.internal/ubuntu oracular-proposed/main s390x Packages [155 kB] 459s Get:7 http://ftpmaster.internal/ubuntu oracular-proposed/universe s390x Packages [456 kB] 460s Get:8 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse s390x Packages [1968 B] 460s Fetched 1257 kB in 4s (320 kB/s) 460s Reading package lists... 463s Reading package lists... 464s Building dependency tree... 464s Reading state information... 464s Calculating upgrade... 464s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 464s Reading package lists... 465s Building dependency tree... 465s Reading state information... 465s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 465s Get:1 http://ftpmaster.internal/ubuntu oracular InRelease [73.9 kB] 466s Hit:2 http://ftpmaster.internal/ubuntu oracular-updates InRelease 466s Hit:3 http://ftpmaster.internal/ubuntu oracular-security InRelease 466s Hit:4 http://ftpmaster.internal/ubuntu oracular-proposed InRelease 466s Get:5 http://ftpmaster.internal/ubuntu oracular/main Sources [1376 kB] 468s Get:6 http://ftpmaster.internal/ubuntu oracular/universe Sources [20.0 MB] 472s Get:7 http://ftpmaster.internal/ubuntu oracular/multiverse Sources [299 kB] 472s Get:8 http://ftpmaster.internal/ubuntu oracular/main s390x Packages [1328 kB] 472s Get:9 http://ftpmaster.internal/ubuntu oracular/universe s390x Packages [14.5 MB] 472s Get:10 http://ftpmaster.internal/ubuntu oracular/multiverse s390x Packages [168 kB] 479s Fetched 37.7 MB in 14s (2776 kB/s) 480s Reading package lists... 480s Reading package lists... 481s Building dependency tree... 481s Reading state information... 481s Calculating upgrade... 481s The following packages will be upgraded: 481s curl dracut-install gir1.2-glib-2.0 klibc-utils libclang-cpp18 libclang1-18 481s libcurl3t64-gnutls libcurl4t64 libglib2.0-0t64 libglib2.0-data libklibc 481s libllvm18 libuv1t64 481s 13 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 481s Need to get 61.3 MB of archives. 481s After this operation, 3163 kB disk space will be freed. 481s Get:1 http://ftpmaster.internal/ubuntu oracular/main s390x gir1.2-glib-2.0 s390x 2.80.2-1ubuntu1 [180 kB] 482s Get:2 http://ftpmaster.internal/ubuntu oracular/main s390x libglib2.0-0t64 s390x 2.80.2-1ubuntu1 [1558 kB] 482s Get:3 http://ftpmaster.internal/ubuntu oracular/main s390x libglib2.0-data all 2.80.2-1ubuntu1 [49.3 kB] 482s Get:4 http://ftpmaster.internal/ubuntu oracular/main s390x libuv1t64 s390x 1.48.0-4 [100 kB] 482s Get:5 http://ftpmaster.internal/ubuntu oracular/main s390x curl s390x 8.5.0-2ubuntu10.1 [227 kB] 483s Get:6 http://ftpmaster.internal/ubuntu oracular/main s390x libcurl4t64 s390x 8.5.0-2ubuntu10.1 [364 kB] 483s Get:7 http://ftpmaster.internal/ubuntu oracular/main s390x dracut-install s390x 060+5-8ubuntu1 [32.6 kB] 483s Get:8 http://ftpmaster.internal/ubuntu oracular/main s390x klibc-utils s390x 2.0.13-4ubuntu1 [114 kB] 483s Get:9 http://ftpmaster.internal/ubuntu oracular/main s390x libklibc s390x 2.0.13-4ubuntu1 [55.0 kB] 483s Get:10 http://ftpmaster.internal/ubuntu oracular/main s390x libclang-cpp18 s390x 1:18.1.6-1 [15.9 MB] 489s Get:11 http://ftpmaster.internal/ubuntu oracular/main s390x libllvm18 s390x 1:18.1.6-1 [33.1 MB] 500s Get:12 http://ftpmaster.internal/ubuntu oracular/main s390x libclang1-18 s390x 1:18.1.6-1 [9290 kB] 503s Get:13 http://ftpmaster.internal/ubuntu oracular/main s390x libcurl3t64-gnutls s390x 8.5.0-2ubuntu10.1 [356 kB] 503s Fetched 61.3 MB in 21s (2861 kB/s) 503s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 54977 files and directories currently installed.) 503s Preparing to unpack .../00-gir1.2-glib-2.0_2.80.2-1ubuntu1_s390x.deb ... 503s Unpacking gir1.2-glib-2.0:s390x (2.80.2-1ubuntu1) over (2.80.1-0ubuntu2) ... 503s Preparing to unpack .../01-libglib2.0-0t64_2.80.2-1ubuntu1_s390x.deb ... 503s Unpacking libglib2.0-0t64:s390x (2.80.2-1ubuntu1) over (2.80.1-0ubuntu2) ... 503s Preparing to unpack .../02-libglib2.0-data_2.80.2-1ubuntu1_all.deb ... 503s Unpacking libglib2.0-data (2.80.2-1ubuntu1) over (2.80.1-0ubuntu2) ... 503s Preparing to unpack .../03-libuv1t64_1.48.0-4_s390x.deb ... 503s Unpacking libuv1t64:s390x (1.48.0-4) over (1.48.0-1.1build1) ... 504s Preparing to unpack .../04-curl_8.5.0-2ubuntu10.1_s390x.deb ... 504s Unpacking curl (8.5.0-2ubuntu10.1) over (8.5.0-2ubuntu10) ... 504s Preparing to unpack .../05-libcurl4t64_8.5.0-2ubuntu10.1_s390x.deb ... 504s Unpacking libcurl4t64:s390x (8.5.0-2ubuntu10.1) over (8.5.0-2ubuntu10) ... 504s Preparing to unpack .../06-dracut-install_060+5-8ubuntu1_s390x.deb ... 504s Unpacking dracut-install (060+5-8ubuntu1) over (060+5-1ubuntu3) ... 504s Preparing to unpack .../07-klibc-utils_2.0.13-4ubuntu1_s390x.deb ... 504s Unpacking klibc-utils (2.0.13-4ubuntu1) over (2.0.13-4) ... 504s Preparing to unpack .../08-libklibc_2.0.13-4ubuntu1_s390x.deb ... 504s Unpacking libklibc:s390x (2.0.13-4ubuntu1) over (2.0.13-4) ... 504s Preparing to unpack .../09-libclang-cpp18_1%3a18.1.6-1_s390x.deb ... 504s Unpacking libclang-cpp18 (1:18.1.6-1) over (1:18.1.3-1) ... 505s Preparing to unpack .../10-libllvm18_1%3a18.1.6-1_s390x.deb ... 505s Unpacking libllvm18:s390x (1:18.1.6-1) over (1:18.1.3-1) ... 506s Preparing to unpack .../11-libclang1-18_1%3a18.1.6-1_s390x.deb ... 506s Unpacking libclang1-18 (1:18.1.6-1) over (1:18.1.3-1) ... 507s Preparing to unpack .../12-libcurl3t64-gnutls_8.5.0-2ubuntu10.1_s390x.deb ... 507s Unpacking libcurl3t64-gnutls:s390x (8.5.0-2ubuntu10.1) over (8.5.0-2ubuntu10) ... 507s Setting up libcurl4t64:s390x (8.5.0-2ubuntu10.1) ... 507s Setting up libuv1t64:s390x (1.48.0-4) ... 507s Setting up libcurl3t64-gnutls:s390x (8.5.0-2ubuntu10.1) ... 507s Setting up libklibc:s390x (2.0.13-4ubuntu1) ... 507s Setting up libglib2.0-0t64:s390x (2.80.2-1ubuntu1) ... 507s No schema files found: doing nothing. 507s Setting up libglib2.0-data (2.80.2-1ubuntu1) ... 507s Setting up gir1.2-glib-2.0:s390x (2.80.2-1ubuntu1) ... 507s Setting up dracut-install (060+5-8ubuntu1) ... 507s Setting up curl (8.5.0-2ubuntu10.1) ... 507s Setting up klibc-utils (2.0.13-4ubuntu1) ... 507s Setting up libllvm18:s390x (1:18.1.6-1) ... 507s Setting up libclang1-18 (1:18.1.6-1) ... 507s Setting up libclang-cpp18 (1:18.1.6-1) ... 507s Processing triggers for libc-bin (2.39-0ubuntu8.1) ... 507s Processing triggers for man-db (2.12.1-1) ... 508s Processing triggers for initramfs-tools (0.142ubuntu27) ... 508s update-initramfs: Generating /boot/initrd.img-6.8.0-31-generic 508s W: No lz4 in /usr/bin:/sbin:/bin, using gzip 512s Using config file '/etc/zipl.conf' 513s Building bootmap in '/boot' 513s Adding IPL section 'ubuntu' (default) 513s Preparing boot device for LD-IPL: sda. 513s Done. 513s Reading package lists... 513s Building dependency tree... 513s Reading state information... 514s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 514s autopkgtest [10:00:51]: rebooting testbed after setup commands that affected boot 518s autopkgtest-virt-ssh: WARNING: ssh connection failed. Retrying in 3 seconds... 549s autopkgtest-virt-ssh: WARNING: ssh connection failed. Retrying in 3 seconds... 556s autopkgtest-virt-ssh: WARNING: ssh connection failed. Retrying in 3 seconds... 567s autopkgtest [10:01:44]: testbed running kernel: Linux 6.8.0-31-generic #31-Ubuntu SMP Sat Apr 20 00:14:26 UTC 2024 571s autopkgtest [10:01:48]: @@@@@@@@@@@@@@@@@@@@ apt-source r-cran-matrixstats 573s Get:1 http://ftpmaster.internal/ubuntu oracular/universe r-cran-matrixstats 1.2.0-1 (dsc) [2230 B] 573s Get:2 http://ftpmaster.internal/ubuntu oracular/universe r-cran-matrixstats 1.2.0-1 (tar) [211 kB] 573s Get:3 http://ftpmaster.internal/ubuntu oracular/universe r-cran-matrixstats 1.2.0-1 (diff) [4752 B] 573s gpgv: Signature made Mon Jan 8 21:38:59 2024 UTC 573s gpgv: using RSA key F1F007320A035541F0A663CA578A0494D1C646D1 573s gpgv: issuer "tille@debian.org" 573s gpgv: Can't check signature: No public key 573s dpkg-source: warning: cannot verify inline signature for ./r-cran-matrixstats_1.2.0-1.dsc: no acceptable signature found 573s autopkgtest [10:01:50]: testing package r-cran-matrixstats version 1.2.0-1 574s autopkgtest [10:01:51]: build not needed 583s autopkgtest [10:02:00]: test run-unit-test: preparing testbed 585s Reading package lists... 585s Building dependency tree... 585s Reading state information... 585s Starting pkgProblemResolver with broken count: 0 585s Starting 2 pkgProblemResolver with broken count: 0 585s Done 586s The following additional packages will be installed: 586s fontconfig fonts-glyphicons-halflings fonts-mathjax libblas3 libcairo2 586s libdatrie1 libgfortran5 libgomp1 libgraphite2-3 libharfbuzz0b libice6 586s libjs-bootstrap libjs-highlight.js libjs-jquery libjs-jquery-datatables 586s libjs-mathjax liblapack3 libpango-1.0-0 libpangocairo-1.0-0 586s libpangoft2-1.0-0 libpaper-utils libpaper1 libpixman-1-0 libsm6 libtcl8.6 586s libthai-data libthai0 libtk8.6 libxcb-render0 libxcb-shm0 libxft2 586s libxrender1 libxss1 libxt6t64 node-normalize.css r-base-core 586s r-cran-base64enc r-cran-cli r-cran-colorspace r-cran-commonmark 586s r-cran-digest r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 586s r-cran-glue r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr 586s r-cran-labeling r-cran-lattice r-cran-lifecycle r-cran-magrittr 586s r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats r-cran-mgcv 586s r-cran-munsell r-cran-nlme r-cran-pillar r-cran-pkgconfig r-cran-r.cache 586s r-cran-r.devices r-cran-r.methodss3 r-cran-r.oo r-cran-r.rsp r-cran-r.utils 586s r-cran-r6 r-cran-rcolorbrewer r-cran-rlang r-cran-scales r-cran-tibble 586s r-cran-utf8 r-cran-vctrs r-cran-viridislite r-cran-withr r-cran-xfun 586s r-cran-yaml tcl tcl8.6 unzip x11-common xdg-utils zip 586s Suggested packages: 586s fonts-mathjax-extras fonts-stix libjs-mathjax-doc tk8.6 libjs-html5shiv 586s elpa-ess r-doc-info | r-doc-pdf r-mathlib r-base-html r-cran-kernsmooth 586s r-cran-kernlab r-cran-mvtnorm r-cran-vcd r-cran-shiny r-cran-shinyjs 586s r-cran-dplyr r-cran-png r-cran-jpeg r-cran-rmarkdown r-cran-viridis 586s r-cran-covr r-cran-magick r-cran-sf r-cran-bit64 r-cran-dbi 586s r-cran-formattable r-cran-nanotime r-cran-palmerpenguins r-cran-stringi 586s r-cran-survival r-cran-units r-cran-vdiffr r-cran-testthat r-cran-cairo 586s r-cran-codetools r-cran-bench r-cran-blob r-cran-brio r-cran-callr 586s r-cran-crayon r-cran-here r-cran-hms r-cran-htmltools r-cran-pkgbuild 586s r-cran-pkgload r-cran-purrr r-cran-tidyr tcl-tclreadline 586s Recommended packages: 586s javascript-common r-recommended r-base-dev r-doc-html r-cran-callr 586s r-cran-covr r-cran-crayon r-cran-htmltools r-cran-htmlwidgets r-cran-mockery 586s r-cran-processx r-cran-ps r-cran-rmarkdown r-cran-rprojroot 586s r-cran-rstudioapi r-cran-testthat r-cran-whoami r-cran-curl r-cran-xml2 586s r-cran-unitizer r-cran-dplyr r-cran-hexbin r-cran-hmisc r-cran-mapproj 586s r-cran-maps r-cran-multcomp r-cran-profvis r-cran-quantreg r-cran-ragg 586s r-cran-rpart r-cran-sf r-cran-svglite r-cran-vdiffr r-cran-dbi 586s r-cran-rsqlite r-cran-waldo r-cran-testit r-cran-bslib r-cran-codetools 586s r-cran-formatr r-cran-gridsvg r-cran-jpeg r-cran-magick r-cran-png 586s r-cran-reticulate r-cran-rgl r-cran-sass r-cran-tikzdevice r-cran-tinytex 586s r-cran-webshot node-highlight.js r-cran-lintr r-cran-tidyverse r-cran-rcurl 586s r-cran-lubridate libjs-remark-slide r-cran-fs r-cran-usethis r-cran-bit64 586s r-cran-dichromat r-cran-hms r-cran-stringi r-cran-data.table r-cran-mockr 586s r-cran-formattable r-cran-generics r-cran-pkgdown r-cran-zeallot r-cran-mime 586s r-cran-remotes r-cran-renv r-cran-jsonlite r-cran-runit 586s libfile-mimeinfo-perl libnet-dbus-perl libx11-protocol-perl x11-utils 586s x11-xserver-utils 586s The following NEW packages will be installed: 586s autopkgtest-satdep fontconfig fonts-glyphicons-halflings fonts-mathjax 586s libblas3 libcairo2 libdatrie1 libgfortran5 libgomp1 libgraphite2-3 586s libharfbuzz0b libice6 libjs-bootstrap libjs-highlight.js libjs-jquery 586s libjs-jquery-datatables libjs-mathjax liblapack3 libpango-1.0-0 586s libpangocairo-1.0-0 libpangoft2-1.0-0 libpaper-utils libpaper1 libpixman-1-0 586s libsm6 libtcl8.6 libthai-data libthai0 libtk8.6 libxcb-render0 libxcb-shm0 586s libxft2 libxrender1 libxss1 libxt6t64 node-normalize.css r-base-core 586s r-cran-base64enc r-cran-cli r-cran-colorspace r-cran-commonmark 586s r-cran-digest r-cran-evaluate r-cran-fansi r-cran-farver r-cran-ggplot2 586s r-cran-glue r-cran-gtable r-cran-highr r-cran-isoband r-cran-knitr 586s r-cran-labeling r-cran-lattice r-cran-lifecycle r-cran-magrittr 586s r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats r-cran-mgcv 586s r-cran-munsell r-cran-nlme r-cran-pillar r-cran-pkgconfig r-cran-r.cache 586s r-cran-r.devices r-cran-r.methodss3 r-cran-r.oo r-cran-r.rsp r-cran-r.utils 586s r-cran-r6 r-cran-rcolorbrewer r-cran-rlang r-cran-scales r-cran-tibble 586s r-cran-utf8 r-cran-vctrs r-cran-viridislite r-cran-withr r-cran-xfun 586s r-cran-yaml tcl tcl8.6 unzip x11-common xdg-utils zip 586s 0 upgraded, 87 newly installed, 0 to remove and 0 not upgraded. 586s Need to get 82.9 MB/82.9 MB of archives. 586s After this operation, 183 MB of additional disk space will be used. 586s Get:1 /tmp/autopkgtest.HmO1t4/1-autopkgtest-satdep.deb autopkgtest-satdep s390x 0 [756 B] 586s Get:2 http://ftpmaster.internal/ubuntu oracular/main s390x fontconfig s390x 2.15.0-1.1ubuntu2 [191 kB] 586s Get:3 http://ftpmaster.internal/ubuntu oracular/universe s390x fonts-glyphicons-halflings all 1.009~3.4.1+dfsg-3 [118 kB] 586s Get:4 http://ftpmaster.internal/ubuntu oracular/main s390x fonts-mathjax all 2.7.9+dfsg-1 [2208 kB] 587s Get:5 http://ftpmaster.internal/ubuntu oracular/main s390x libblas3 s390x 3.12.0-3build1 [245 kB] 587s Get:6 http://ftpmaster.internal/ubuntu oracular/main s390x libpixman-1-0 s390x 0.42.2-1build1 [206 kB] 587s Get:7 http://ftpmaster.internal/ubuntu oracular/main s390x libxcb-render0 s390x 1.17.0-2 [17.0 kB] 587s Get:8 http://ftpmaster.internal/ubuntu oracular/main s390x libxcb-shm0 s390x 1.17.0-2 [5862 B] 587s Get:9 http://ftpmaster.internal/ubuntu oracular/main s390x libxrender1 s390x 1:0.9.10-1.1build1 [20.4 kB] 587s Get:10 http://ftpmaster.internal/ubuntu oracular/main s390x libcairo2 s390x 1.18.0-3build1 [589 kB] 587s Get:11 http://ftpmaster.internal/ubuntu oracular/main s390x libdatrie1 s390x 0.2.13-3build1 [20.6 kB] 587s Get:12 http://ftpmaster.internal/ubuntu oracular/main s390x libgfortran5 s390x 14.1.0-1ubuntu1 [600 kB] 588s Get:13 http://ftpmaster.internal/ubuntu oracular/main s390x libgomp1 s390x 14.1.0-1ubuntu1 [151 kB] 588s Get:14 http://ftpmaster.internal/ubuntu oracular/main s390x libgraphite2-3 s390x 1.3.14-2build1 [80.0 kB] 588s Get:15 http://ftpmaster.internal/ubuntu oracular/main s390x libharfbuzz0b s390x 8.3.0-2build2 [515 kB] 588s Get:16 http://ftpmaster.internal/ubuntu oracular/main s390x x11-common all 1:7.7+23ubuntu3 [21.7 kB] 588s Get:17 http://ftpmaster.internal/ubuntu oracular/main s390x libice6 s390x 2:1.0.10-1build3 [44.8 kB] 588s Get:18 http://ftpmaster.internal/ubuntu oracular/universe s390x libjs-bootstrap all 3.4.1+dfsg-3 [129 kB] 588s Get:19 http://ftpmaster.internal/ubuntu oracular/universe s390x libjs-highlight.js all 9.18.5+dfsg1-2 [385 kB] 588s Get:20 http://ftpmaster.internal/ubuntu oracular/main s390x libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 588s Get:21 http://ftpmaster.internal/ubuntu oracular/universe s390x libjs-jquery-datatables all 1.11.5+dfsg-2 [146 kB] 588s Get:22 http://ftpmaster.internal/ubuntu oracular/main s390x liblapack3 s390x 3.12.0-3build1 [2976 kB] 589s Get:23 http://ftpmaster.internal/ubuntu oracular/main s390x libthai-data all 0.1.29-2build1 [158 kB] 589s Get:24 http://ftpmaster.internal/ubuntu oracular/main s390x libthai0 s390x 0.1.29-2build1 [20.7 kB] 589s Get:25 http://ftpmaster.internal/ubuntu oracular/main s390x libpango-1.0-0 s390x 1.52.2+ds-1 [242 kB] 589s Get:26 http://ftpmaster.internal/ubuntu oracular/main s390x libpangoft2-1.0-0 s390x 1.52.2+ds-1 [43.4 kB] 589s Get:27 http://ftpmaster.internal/ubuntu oracular/main s390x libpangocairo-1.0-0 s390x 1.52.2+ds-1 [28.2 kB] 589s Get:28 http://ftpmaster.internal/ubuntu oracular/main s390x libpaper1 s390x 1.1.29build1 [13.4 kB] 589s Get:29 http://ftpmaster.internal/ubuntu oracular/main s390x libpaper-utils s390x 1.1.29build1 [8442 B] 589s Get:30 http://ftpmaster.internal/ubuntu oracular/main s390x libsm6 s390x 2:1.2.3-1build3 [17.7 kB] 589s Get:31 http://ftpmaster.internal/ubuntu oracular/main s390x libtcl8.6 s390x 8.6.14+dfsg-1build1 [1038 kB] 589s Get:32 http://ftpmaster.internal/ubuntu oracular/main s390x libxft2 s390x 2.3.6-1build1 [49.6 kB] 589s Get:33 http://ftpmaster.internal/ubuntu oracular/main s390x libxss1 s390x 1:1.2.3-1build3 [7396 B] 589s Get:34 http://ftpmaster.internal/ubuntu oracular/main s390x libtk8.6 s390x 8.6.14-1build1 [833 kB] 589s Get:35 http://ftpmaster.internal/ubuntu oracular/main s390x libxt6t64 s390x 1:1.2.1-1.2build1 [184 kB] 589s Get:36 http://ftpmaster.internal/ubuntu oracular/universe s390x node-normalize.css all 8.0.1-5 [10.8 kB] 589s Get:37 http://ftpmaster.internal/ubuntu oracular/main s390x zip s390x 3.0-13build1 [189 kB] 589s Get:38 http://ftpmaster.internal/ubuntu oracular/main s390x unzip s390x 6.0-28ubuntu4 [180 kB] 589s Get:39 http://ftpmaster.internal/ubuntu oracular/main s390x xdg-utils all 1.1.3-4.1ubuntu3 [62.0 kB] 589s Get:40 http://ftpmaster.internal/ubuntu oracular/universe s390x r-base-core s390x 4.4.0-2 [28.5 MB] 596s Get:41 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-base64enc s390x 0.1-3-3 [28.0 kB] 596s Get:42 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-cli s390x 3.6.2-1 [1382 kB] 597s Get:43 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-colorspace s390x 2.1-0+dfsg-1 [1540 kB] 597s Get:44 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-commonmark s390x 1.9.1-1 [142 kB] 597s Get:45 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-digest s390x 0.6.35-1 [201 kB] 597s Get:46 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-evaluate all 0.23-1 [90.2 kB] 597s Get:47 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-fansi s390x 1.0.5-1 [615 kB] 597s Get:48 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-farver s390x 2.1.1-2 [1351 kB] 598s Get:49 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-glue s390x 1.7.0-1 [154 kB] 598s Get:50 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-rlang s390x 1.1.3-1 [1672 kB] 598s Get:51 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-lifecycle all 1.0.4+dfsg-1 [110 kB] 598s Get:52 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-gtable all 0.3.4+dfsg-1 [191 kB] 598s Get:53 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-isoband s390x 0.2.7-1 [1481 kB] 599s Get:54 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-mass s390x 7.3-60.2-1 [1112 kB] 599s Get:55 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-lattice s390x 0.22-6-1 [1340 kB] 599s Get:56 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-nlme s390x 3.1.164-1build1 [2270 kB] 600s Get:57 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-matrix s390x 1.6-5-1 [3983 kB] 601s Get:58 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-mgcv s390x 1.9-1-1 [3348 kB] 602s Get:59 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-labeling all 0.4.3-1 [62.1 kB] 602s Get:60 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-munsell all 0.5.0-2build1 [208 kB] 602s Get:61 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-r6 all 2.5.1-1 [99.0 kB] 602s Get:62 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-rcolorbrewer all 1.1-3-1build1 [55.4 kB] 602s Get:63 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-viridislite all 0.4.2-2 [1088 kB] 602s Get:64 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-scales all 1.3.0-1 [603 kB] 603s Get:65 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-magrittr s390x 2.0.3-1 [154 kB] 603s Get:66 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-utf8 s390x 1.2.4-1 [143 kB] 603s Get:67 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-vctrs s390x 0.6.5-1 [1448 kB] 603s Get:68 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-pillar all 1.9.0+dfsg-1 [464 kB] 603s Get:69 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-pkgconfig all 2.0.3-2build1 [19.7 kB] 603s Get:70 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-tibble s390x 3.2.1+dfsg-2 [415 kB] 603s Get:71 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-withr all 2.5.0-1 [225 kB] 603s Get:72 http://ftpmaster.internal/ubuntu oracular-proposed/universe s390x r-cran-ggplot2 all 3.5.1+dfsg-1 [3940 kB] 604s Get:73 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-xfun s390x 0.44+dfsg-1 [517 kB] 604s Get:74 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-highr all 0.10+dfsg-2 [38.5 kB] 604s Get:75 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-yaml s390x 2.3.8-2 [112 kB] 604s Get:76 http://ftpmaster.internal/ubuntu oracular/main s390x libjs-mathjax all 2.7.9+dfsg-1 [5665 kB] 605s Get:77 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-knitr all 1.46+dfsg-1 [911 kB] 605s Get:78 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-markdown all 1.12+dfsg-2 [179 kB] 605s Get:79 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-matrixstats s390x 1.2.0-1 [513 kB] 605s Get:80 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-r.methodss3 all 1.8.2-1 [84.0 kB] 605s Get:81 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-r.oo all 1.26.0-1 [955 kB] 605s Get:82 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-r.utils all 2.12.3-1 [1386 kB] 605s Get:83 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-r.cache all 0.16.0-1 [113 kB] 606s Get:84 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-r.devices all 2.17.2+ds-1 [398 kB] 606s Get:85 http://ftpmaster.internal/ubuntu oracular/main s390x tcl8.6 s390x 8.6.14+dfsg-1build1 [14.7 kB] 606s Get:86 http://ftpmaster.internal/ubuntu oracular/main s390x tcl s390x 8.6.14build1 [4124 B] 606s Get:87 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-r.rsp all 0.46.0+ds-1 [1412 kB] 606s Preconfiguring packages ... 606s Fetched 82.9 MB in 20s (4177 kB/s) 606s Selecting previously unselected package fontconfig. 607s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 54978 files and directories currently installed.) 607s Preparing to unpack .../00-fontconfig_2.15.0-1.1ubuntu2_s390x.deb ... 607s Unpacking fontconfig (2.15.0-1.1ubuntu2) ... 607s Selecting previously unselected package fonts-glyphicons-halflings. 607s Preparing to unpack .../01-fonts-glyphicons-halflings_1.009~3.4.1+dfsg-3_all.deb ... 607s Unpacking fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 607s Selecting previously unselected package fonts-mathjax. 607s Preparing to unpack .../02-fonts-mathjax_2.7.9+dfsg-1_all.deb ... 607s Unpacking fonts-mathjax (2.7.9+dfsg-1) ... 607s Selecting previously unselected package libblas3:s390x. 607s Preparing to unpack .../03-libblas3_3.12.0-3build1_s390x.deb ... 607s Unpacking libblas3:s390x (3.12.0-3build1) ... 607s Selecting previously unselected package libpixman-1-0:s390x. 607s Preparing to unpack .../04-libpixman-1-0_0.42.2-1build1_s390x.deb ... 607s Unpacking libpixman-1-0:s390x (0.42.2-1build1) ... 607s Selecting previously unselected package libxcb-render0:s390x. 607s Preparing to unpack .../05-libxcb-render0_1.17.0-2_s390x.deb ... 607s Unpacking libxcb-render0:s390x (1.17.0-2) ... 607s Selecting previously unselected package libxcb-shm0:s390x. 607s Preparing to unpack .../06-libxcb-shm0_1.17.0-2_s390x.deb ... 607s Unpacking libxcb-shm0:s390x (1.17.0-2) ... 607s Selecting previously unselected package libxrender1:s390x. 607s Preparing to unpack .../07-libxrender1_1%3a0.9.10-1.1build1_s390x.deb ... 607s Unpacking libxrender1:s390x (1:0.9.10-1.1build1) ... 607s Selecting previously unselected package libcairo2:s390x. 607s Preparing to unpack .../08-libcairo2_1.18.0-3build1_s390x.deb ... 607s Unpacking libcairo2:s390x (1.18.0-3build1) ... 607s Selecting previously unselected package libdatrie1:s390x. 607s Preparing to unpack .../09-libdatrie1_0.2.13-3build1_s390x.deb ... 607s Unpacking libdatrie1:s390x (0.2.13-3build1) ... 607s Selecting previously unselected package libgfortran5:s390x. 607s Preparing to unpack .../10-libgfortran5_14.1.0-1ubuntu1_s390x.deb ... 607s Unpacking libgfortran5:s390x (14.1.0-1ubuntu1) ... 607s Selecting previously unselected package libgomp1:s390x. 607s Preparing to unpack .../11-libgomp1_14.1.0-1ubuntu1_s390x.deb ... 607s Unpacking libgomp1:s390x (14.1.0-1ubuntu1) ... 607s Selecting previously unselected package libgraphite2-3:s390x. 607s Preparing to unpack .../12-libgraphite2-3_1.3.14-2build1_s390x.deb ... 607s Unpacking libgraphite2-3:s390x (1.3.14-2build1) ... 607s Selecting previously unselected package libharfbuzz0b:s390x. 607s Preparing to unpack .../13-libharfbuzz0b_8.3.0-2build2_s390x.deb ... 607s Unpacking libharfbuzz0b:s390x (8.3.0-2build2) ... 607s Selecting previously unselected package x11-common. 607s Preparing to unpack .../14-x11-common_1%3a7.7+23ubuntu3_all.deb ... 607s Unpacking x11-common (1:7.7+23ubuntu3) ... 607s Selecting previously unselected package libice6:s390x. 607s Preparing to unpack .../15-libice6_2%3a1.0.10-1build3_s390x.deb ... 607s Unpacking libice6:s390x (2:1.0.10-1build3) ... 607s Selecting previously unselected package libjs-bootstrap. 607s Preparing to unpack .../16-libjs-bootstrap_3.4.1+dfsg-3_all.deb ... 607s Unpacking libjs-bootstrap (3.4.1+dfsg-3) ... 607s Selecting previously unselected package libjs-highlight.js. 607s Preparing to unpack .../17-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ... 607s Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ... 607s Selecting previously unselected package libjs-jquery. 607s Preparing to unpack .../18-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 607s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 608s Selecting previously unselected package libjs-jquery-datatables. 608s Preparing to unpack .../19-libjs-jquery-datatables_1.11.5+dfsg-2_all.deb ... 608s Unpacking libjs-jquery-datatables (1.11.5+dfsg-2) ... 608s Selecting previously unselected package liblapack3:s390x. 608s Preparing to unpack .../20-liblapack3_3.12.0-3build1_s390x.deb ... 608s Unpacking liblapack3:s390x (3.12.0-3build1) ... 608s Selecting previously unselected package libthai-data. 608s Preparing to unpack .../21-libthai-data_0.1.29-2build1_all.deb ... 608s Unpacking libthai-data (0.1.29-2build1) ... 608s Selecting previously unselected package libthai0:s390x. 608s Preparing to unpack .../22-libthai0_0.1.29-2build1_s390x.deb ... 608s Unpacking libthai0:s390x (0.1.29-2build1) ... 608s Selecting previously unselected package libpango-1.0-0:s390x. 608s Preparing to unpack .../23-libpango-1.0-0_1.52.2+ds-1_s390x.deb ... 608s Unpacking libpango-1.0-0:s390x (1.52.2+ds-1) ... 608s Selecting previously unselected package libpangoft2-1.0-0:s390x. 608s Preparing to unpack .../24-libpangoft2-1.0-0_1.52.2+ds-1_s390x.deb ... 608s Unpacking libpangoft2-1.0-0:s390x (1.52.2+ds-1) ... 608s Selecting previously unselected package libpangocairo-1.0-0:s390x. 608s Preparing to unpack .../25-libpangocairo-1.0-0_1.52.2+ds-1_s390x.deb ... 608s Unpacking libpangocairo-1.0-0:s390x (1.52.2+ds-1) ... 608s Selecting previously unselected package libpaper1:s390x. 608s Preparing to unpack .../26-libpaper1_1.1.29build1_s390x.deb ... 608s Unpacking libpaper1:s390x (1.1.29build1) ... 608s Selecting previously unselected package libpaper-utils. 608s Preparing to unpack .../27-libpaper-utils_1.1.29build1_s390x.deb ... 608s Unpacking libpaper-utils (1.1.29build1) ... 608s Selecting previously unselected package libsm6:s390x. 608s Preparing to unpack .../28-libsm6_2%3a1.2.3-1build3_s390x.deb ... 608s Unpacking libsm6:s390x (2:1.2.3-1build3) ... 608s Selecting previously unselected package libtcl8.6:s390x. 608s Preparing to unpack .../29-libtcl8.6_8.6.14+dfsg-1build1_s390x.deb ... 608s Unpacking libtcl8.6:s390x (8.6.14+dfsg-1build1) ... 608s Selecting previously unselected package libxft2:s390x. 608s Preparing to unpack .../30-libxft2_2.3.6-1build1_s390x.deb ... 608s Unpacking libxft2:s390x (2.3.6-1build1) ... 608s Selecting previously unselected package libxss1:s390x. 608s Preparing to unpack .../31-libxss1_1%3a1.2.3-1build3_s390x.deb ... 608s Unpacking libxss1:s390x (1:1.2.3-1build3) ... 608s Selecting previously unselected package libtk8.6:s390x. 608s Preparing to unpack .../32-libtk8.6_8.6.14-1build1_s390x.deb ... 608s Unpacking libtk8.6:s390x (8.6.14-1build1) ... 608s Selecting previously unselected package libxt6t64:s390x. 608s Preparing to unpack .../33-libxt6t64_1%3a1.2.1-1.2build1_s390x.deb ... 608s Unpacking libxt6t64:s390x (1:1.2.1-1.2build1) ... 608s Selecting previously unselected package node-normalize.css. 608s Preparing to unpack .../34-node-normalize.css_8.0.1-5_all.deb ... 608s Unpacking node-normalize.css (8.0.1-5) ... 608s Selecting previously unselected package zip. 608s Preparing to unpack .../35-zip_3.0-13build1_s390x.deb ... 608s Unpacking zip (3.0-13build1) ... 608s Selecting previously unselected package unzip. 608s Preparing to unpack .../36-unzip_6.0-28ubuntu4_s390x.deb ... 608s Unpacking unzip (6.0-28ubuntu4) ... 608s Selecting previously unselected package xdg-utils. 608s Preparing to unpack .../37-xdg-utils_1.1.3-4.1ubuntu3_all.deb ... 608s Unpacking xdg-utils (1.1.3-4.1ubuntu3) ... 608s Selecting previously unselected package r-base-core. 608s Preparing to unpack .../38-r-base-core_4.4.0-2_s390x.deb ... 608s Unpacking r-base-core (4.4.0-2) ... 609s Selecting previously unselected package r-cran-base64enc. 609s Preparing to unpack .../39-r-cran-base64enc_0.1-3-3_s390x.deb ... 609s Unpacking r-cran-base64enc (0.1-3-3) ... 609s Selecting previously unselected package r-cran-cli. 609s Preparing to unpack .../40-r-cran-cli_3.6.2-1_s390x.deb ... 609s Unpacking r-cran-cli (3.6.2-1) ... 609s Selecting previously unselected package r-cran-colorspace. 609s Preparing to unpack .../41-r-cran-colorspace_2.1-0+dfsg-1_s390x.deb ... 609s Unpacking r-cran-colorspace (2.1-0+dfsg-1) ... 609s Selecting previously unselected package r-cran-commonmark. 609s Preparing to unpack .../42-r-cran-commonmark_1.9.1-1_s390x.deb ... 609s Unpacking r-cran-commonmark (1.9.1-1) ... 609s Selecting previously unselected package r-cran-digest. 609s Preparing to unpack .../43-r-cran-digest_0.6.35-1_s390x.deb ... 609s Unpacking r-cran-digest (0.6.35-1) ... 609s Selecting previously unselected package r-cran-evaluate. 609s Preparing to unpack .../44-r-cran-evaluate_0.23-1_all.deb ... 609s Unpacking r-cran-evaluate (0.23-1) ... 609s Selecting previously unselected package r-cran-fansi. 609s Preparing to unpack .../45-r-cran-fansi_1.0.5-1_s390x.deb ... 609s Unpacking r-cran-fansi (1.0.5-1) ... 609s Selecting previously unselected package r-cran-farver. 609s Preparing to unpack .../46-r-cran-farver_2.1.1-2_s390x.deb ... 609s Unpacking r-cran-farver (2.1.1-2) ... 609s Selecting previously unselected package r-cran-glue. 609s Preparing to unpack .../47-r-cran-glue_1.7.0-1_s390x.deb ... 609s Unpacking r-cran-glue (1.7.0-1) ... 609s Selecting previously unselected package r-cran-rlang. 609s Preparing to unpack .../48-r-cran-rlang_1.1.3-1_s390x.deb ... 609s Unpacking r-cran-rlang (1.1.3-1) ... 609s Selecting previously unselected package r-cran-lifecycle. 609s Preparing to unpack .../49-r-cran-lifecycle_1.0.4+dfsg-1_all.deb ... 609s Unpacking r-cran-lifecycle (1.0.4+dfsg-1) ... 609s Selecting previously unselected package r-cran-gtable. 609s Preparing to unpack .../50-r-cran-gtable_0.3.4+dfsg-1_all.deb ... 609s Unpacking r-cran-gtable (0.3.4+dfsg-1) ... 609s Selecting previously unselected package r-cran-isoband. 609s Preparing to unpack .../51-r-cran-isoband_0.2.7-1_s390x.deb ... 609s Unpacking r-cran-isoband (0.2.7-1) ... 609s Selecting previously unselected package r-cran-mass. 609s Preparing to unpack .../52-r-cran-mass_7.3-60.2-1_s390x.deb ... 609s Unpacking r-cran-mass (7.3-60.2-1) ... 609s Selecting previously unselected package r-cran-lattice. 609s Preparing to unpack .../53-r-cran-lattice_0.22-6-1_s390x.deb ... 609s Unpacking r-cran-lattice (0.22-6-1) ... 609s Selecting previously unselected package r-cran-nlme. 609s Preparing to unpack .../54-r-cran-nlme_3.1.164-1build1_s390x.deb ... 609s Unpacking r-cran-nlme (3.1.164-1build1) ... 609s Selecting previously unselected package r-cran-matrix. 609s Preparing to unpack .../55-r-cran-matrix_1.6-5-1_s390x.deb ... 609s Unpacking r-cran-matrix (1.6-5-1) ... 609s Selecting previously unselected package r-cran-mgcv. 609s Preparing to unpack .../56-r-cran-mgcv_1.9-1-1_s390x.deb ... 609s Unpacking r-cran-mgcv (1.9-1-1) ... 610s Selecting previously unselected package r-cran-labeling. 610s Preparing to unpack .../57-r-cran-labeling_0.4.3-1_all.deb ... 610s Unpacking r-cran-labeling (0.4.3-1) ... 610s Selecting previously unselected package r-cran-munsell. 610s Preparing to unpack .../58-r-cran-munsell_0.5.0-2build1_all.deb ... 610s Unpacking r-cran-munsell (0.5.0-2build1) ... 610s Selecting previously unselected package r-cran-r6. 610s Preparing to unpack .../59-r-cran-r6_2.5.1-1_all.deb ... 610s Unpacking r-cran-r6 (2.5.1-1) ... 610s Selecting previously unselected package r-cran-rcolorbrewer. 610s Preparing to unpack .../60-r-cran-rcolorbrewer_1.1-3-1build1_all.deb ... 610s Unpacking r-cran-rcolorbrewer (1.1-3-1build1) ... 610s Selecting previously unselected package r-cran-viridislite. 610s Preparing to unpack .../61-r-cran-viridislite_0.4.2-2_all.deb ... 610s Unpacking r-cran-viridislite (0.4.2-2) ... 610s Selecting previously unselected package r-cran-scales. 610s Preparing to unpack .../62-r-cran-scales_1.3.0-1_all.deb ... 610s Unpacking r-cran-scales (1.3.0-1) ... 610s Selecting previously unselected package r-cran-magrittr. 610s Preparing to unpack .../63-r-cran-magrittr_2.0.3-1_s390x.deb ... 610s Unpacking r-cran-magrittr (2.0.3-1) ... 610s Selecting previously unselected package r-cran-utf8. 610s Preparing to unpack .../64-r-cran-utf8_1.2.4-1_s390x.deb ... 610s Unpacking r-cran-utf8 (1.2.4-1) ... 610s Selecting previously unselected package r-cran-vctrs. 610s Preparing to unpack .../65-r-cran-vctrs_0.6.5-1_s390x.deb ... 610s Unpacking r-cran-vctrs (0.6.5-1) ... 610s Selecting previously unselected package r-cran-pillar. 610s Preparing to unpack .../66-r-cran-pillar_1.9.0+dfsg-1_all.deb ... 610s Unpacking r-cran-pillar (1.9.0+dfsg-1) ... 610s Selecting previously unselected package r-cran-pkgconfig. 610s Preparing to unpack .../67-r-cran-pkgconfig_2.0.3-2build1_all.deb ... 610s Unpacking r-cran-pkgconfig (2.0.3-2build1) ... 610s Selecting previously unselected package r-cran-tibble. 610s Preparing to unpack .../68-r-cran-tibble_3.2.1+dfsg-2_s390x.deb ... 610s Unpacking r-cran-tibble (3.2.1+dfsg-2) ... 610s Selecting previously unselected package r-cran-withr. 610s Preparing to unpack .../69-r-cran-withr_2.5.0-1_all.deb ... 610s Unpacking r-cran-withr (2.5.0-1) ... 610s Selecting previously unselected package r-cran-ggplot2. 610s Preparing to unpack .../70-r-cran-ggplot2_3.5.1+dfsg-1_all.deb ... 610s Unpacking r-cran-ggplot2 (3.5.1+dfsg-1) ... 610s Selecting previously unselected package r-cran-xfun. 610s Preparing to unpack .../71-r-cran-xfun_0.44+dfsg-1_s390x.deb ... 610s Unpacking r-cran-xfun (0.44+dfsg-1) ... 610s Selecting previously unselected package r-cran-highr. 610s Preparing to unpack .../72-r-cran-highr_0.10+dfsg-2_all.deb ... 610s Unpacking r-cran-highr (0.10+dfsg-2) ... 610s Selecting previously unselected package r-cran-yaml. 610s Preparing to unpack .../73-r-cran-yaml_2.3.8-2_s390x.deb ... 610s Unpacking r-cran-yaml (2.3.8-2) ... 610s Selecting previously unselected package libjs-mathjax. 610s Preparing to unpack .../74-libjs-mathjax_2.7.9+dfsg-1_all.deb ... 610s Unpacking libjs-mathjax (2.7.9+dfsg-1) ... 612s Selecting previously unselected package r-cran-knitr. 612s Preparing to unpack .../75-r-cran-knitr_1.46+dfsg-1_all.deb ... 612s Unpacking r-cran-knitr (1.46+dfsg-1) ... 612s Selecting previously unselected package r-cran-markdown. 612s Preparing to unpack .../76-r-cran-markdown_1.12+dfsg-2_all.deb ... 612s Unpacking r-cran-markdown (1.12+dfsg-2) ... 612s Selecting previously unselected package r-cran-matrixstats. 612s Preparing to unpack .../77-r-cran-matrixstats_1.2.0-1_s390x.deb ... 612s Unpacking r-cran-matrixstats (1.2.0-1) ... 612s Selecting previously unselected package r-cran-r.methodss3. 612s Preparing to unpack .../78-r-cran-r.methodss3_1.8.2-1_all.deb ... 612s Unpacking r-cran-r.methodss3 (1.8.2-1) ... 612s Selecting previously unselected package r-cran-r.oo. 612s Preparing to unpack .../79-r-cran-r.oo_1.26.0-1_all.deb ... 612s Unpacking r-cran-r.oo (1.26.0-1) ... 612s Selecting previously unselected package r-cran-r.utils. 612s Preparing to unpack .../80-r-cran-r.utils_2.12.3-1_all.deb ... 612s Unpacking r-cran-r.utils (2.12.3-1) ... 612s Selecting previously unselected package r-cran-r.cache. 612s Preparing to unpack .../81-r-cran-r.cache_0.16.0-1_all.deb ... 612s Unpacking r-cran-r.cache (0.16.0-1) ... 612s Selecting previously unselected package r-cran-r.devices. 612s Preparing to unpack .../82-r-cran-r.devices_2.17.2+ds-1_all.deb ... 612s Unpacking r-cran-r.devices (2.17.2+ds-1) ... 612s Selecting previously unselected package tcl8.6. 612s Preparing to unpack .../83-tcl8.6_8.6.14+dfsg-1build1_s390x.deb ... 612s Unpacking tcl8.6 (8.6.14+dfsg-1build1) ... 612s Selecting previously unselected package tcl. 612s Preparing to unpack .../84-tcl_8.6.14build1_s390x.deb ... 613s Unpacking tcl (8.6.14build1) ... 613s Selecting previously unselected package r-cran-r.rsp. 613s Preparing to unpack .../85-r-cran-r.rsp_0.46.0+ds-1_all.deb ... 613s Unpacking r-cran-r.rsp (0.46.0+ds-1) ... 613s Selecting previously unselected package autopkgtest-satdep. 613s Preparing to unpack .../86-1-autopkgtest-satdep.deb ... 613s Unpacking autopkgtest-satdep (0) ... 613s Setting up libgraphite2-3:s390x (1.3.14-2build1) ... 613s Setting up libpixman-1-0:s390x (0.42.2-1build1) ... 613s Setting up libpaper1:s390x (1.1.29build1) ... 613s 613s Creating config file /etc/papersize with new version 613s Setting up fontconfig (2.15.0-1.1ubuntu2) ... 615s Regenerating fonts cache... done. 615s Setting up fonts-mathjax (2.7.9+dfsg-1) ... 615s Setting up libjs-mathjax (2.7.9+dfsg-1) ... 615s Setting up libxrender1:s390x (1:0.9.10-1.1build1) ... 615s Setting up libdatrie1:s390x (0.2.13-3build1) ... 615s Setting up libxcb-render0:s390x (1.17.0-2) ... 615s Setting up fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 615s Setting up unzip (6.0-28ubuntu4) ... 615s Setting up x11-common (1:7.7+23ubuntu3) ... 616s Setting up libxcb-shm0:s390x (1.17.0-2) ... 616s Setting up libpaper-utils (1.1.29build1) ... 616s Setting up libgomp1:s390x (14.1.0-1ubuntu1) ... 616s Setting up libcairo2:s390x (1.18.0-3build1) ... 616s Setting up zip (3.0-13build1) ... 616s Setting up libblas3:s390x (3.12.0-3build1) ... 616s update-alternatives: using /usr/lib/s390x-linux-gnu/blas/libblas.so.3 to provide /usr/lib/s390x-linux-gnu/libblas.so.3 (libblas.so.3-s390x-linux-gnu) in auto mode 616s Setting up libtcl8.6:s390x (8.6.14+dfsg-1build1) ... 616s Setting up libgfortran5:s390x (14.1.0-1ubuntu1) ... 616s Setting up libjs-highlight.js (9.18.5+dfsg1-2) ... 616s Setting up libharfbuzz0b:s390x (8.3.0-2build2) ... 616s Setting up libthai-data (0.1.29-2build1) ... 616s Setting up libxss1:s390x (1:1.2.3-1build3) ... 616s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 616s Setting up node-normalize.css (8.0.1-5) ... 616s Setting up xdg-utils (1.1.3-4.1ubuntu3) ... 616s update-alternatives: using /usr/bin/xdg-open to provide /usr/bin/open (open) in auto mode 616s Setting up libjs-bootstrap (3.4.1+dfsg-3) ... 616s Setting up libice6:s390x (2:1.0.10-1build3) ... 616s Setting up tcl8.6 (8.6.14+dfsg-1build1) ... 616s Setting up liblapack3:s390x (3.12.0-3build1) ... 616s update-alternatives: using /usr/lib/s390x-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/s390x-linux-gnu/liblapack.so.3 (liblapack.so.3-s390x-linux-gnu) in auto mode 616s Setting up libxft2:s390x (2.3.6-1build1) ... 616s Setting up libtk8.6:s390x (8.6.14-1build1) ... 616s Setting up libjs-jquery-datatables (1.11.5+dfsg-2) ... 616s Setting up libthai0:s390x (0.1.29-2build1) ... 616s Setting up tcl (8.6.14build1) ... 616s Setting up libsm6:s390x (2:1.2.3-1build3) ... 616s Setting up libpango-1.0-0:s390x (1.52.2+ds-1) ... 616s Setting up libxt6t64:s390x (1:1.2.1-1.2build1) ... 616s Setting up libpangoft2-1.0-0:s390x (1.52.2+ds-1) ... 616s Setting up libpangocairo-1.0-0:s390x (1.52.2+ds-1) ... 616s Setting up r-base-core (4.4.0-2) ... 616s 616s Creating config file /etc/R/Renviron with new version 616s Setting up r-cran-labeling (0.4.3-1) ... 616s Setting up r-cran-lattice (0.22-6-1) ... 616s Setting up r-cran-nlme (3.1.164-1build1) ... 616s Setting up r-cran-farver (2.1.1-2) ... 616s Setting up r-cran-viridislite (0.4.2-2) ... 616s Setting up r-cran-commonmark (1.9.1-1) ... 616s Setting up r-cran-r6 (2.5.1-1) ... 616s Setting up r-cran-magrittr (2.0.3-1) ... 616s Setting up r-cran-rlang (1.1.3-1) ... 616s Setting up r-cran-matrixstats (1.2.0-1) ... 616s Setting up r-cran-xfun (0.44+dfsg-1) ... 616s Setting up r-cran-withr (2.5.0-1) ... 616s Setting up r-cran-base64enc (0.1-3-3) ... 616s Setting up r-cran-digest (0.6.35-1) ... 616s Setting up r-cran-yaml (2.3.8-2) ... 616s Setting up r-cran-evaluate (0.23-1) ... 616s Setting up r-cran-highr (0.10+dfsg-2) ... 616s Setting up r-cran-fansi (1.0.5-1) ... 616s Setting up r-cran-mass (7.3-60.2-1) ... 616s Setting up r-cran-glue (1.7.0-1) ... 616s Setting up r-cran-cli (3.6.2-1) ... 616s Setting up r-cran-lifecycle (1.0.4+dfsg-1) ... 616s Setting up r-cran-r.methodss3 (1.8.2-1) ... 616s Setting up r-cran-pkgconfig (2.0.3-2build1) ... 616s Setting up r-cran-utf8 (1.2.4-1) ... 616s Setting up r-cran-colorspace (2.1-0+dfsg-1) ... 616s Setting up r-cran-markdown (1.12+dfsg-2) ... 616s Setting up r-cran-rcolorbrewer (1.1-3-1build1) ... 616s Setting up r-cran-isoband (0.2.7-1) ... 616s Setting up r-cran-gtable (0.3.4+dfsg-1) ... 616s Setting up r-cran-matrix (1.6-5-1) ... 616s Setting up r-cran-knitr (1.46+dfsg-1) ... 616s Setting up r-cran-mgcv (1.9-1-1) ... 616s Setting up r-cran-vctrs (0.6.5-1) ... 616s Setting up r-cran-pillar (1.9.0+dfsg-1) ... 616s Setting up r-cran-munsell (0.5.0-2build1) ... 616s Setting up r-cran-tibble (3.2.1+dfsg-2) ... 616s Setting up r-cran-r.oo (1.26.0-1) ... 616s Setting up r-cran-scales (1.3.0-1) ... 616s Setting up r-cran-r.utils (2.12.3-1) ... 616s Setting up r-cran-ggplot2 (3.5.1+dfsg-1) ... 616s Setting up r-cran-r.devices (2.17.2+ds-1) ... 616s Setting up r-cran-r.cache (0.16.0-1) ... 616s Setting up r-cran-r.rsp (0.46.0+ds-1) ... 616s Setting up autopkgtest-satdep (0) ... 616s Processing triggers for man-db (2.12.1-1) ... 617s Processing triggers for install-info (7.1-3build2) ... 617s Processing triggers for libc-bin (2.39-0ubuntu8.1) ... 764s (Reading database ... 66030 files and directories currently installed.) 764s Removing autopkgtest-satdep (0) ... 897s autopkgtest [10:05:45]: test run-unit-test: [----------------------- 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > allocArray_R <- function(nrow, ncol, value = NA) { 897s + array(data = value, dim = dim) 897s + } 897s > 897s > values <- list( 897s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 897s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 897s + .Machine$double.xmin, .Machine$double.xmax, 897s + .Machine$double.eps, .Machine$double.neg.eps, 897s + FALSE, TRUE, NA 897s + ) 897s > 897s > dim <- c(2L, 4L, 3L) 897s > for (value in values) { 897s + x0 <- allocArray_R(dim, value = value) 897s + x <- allocArray(dim, value = value) 897s + if (!identical(x, x0)) { 897s + str(list(dim = dim, value = value, x = x, x0 = x0)) 897s + stopifnot(identical(x, x0)) 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > allocMatrix_R <- function(nrow, ncol, value = NA) { 897s + matrix(data = value, nrow = nrow, ncol = ncol) 897s + } 897s > 897s > values <- list( 897s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 897s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 897s + .Machine$double.xmin, .Machine$double.xmax, 897s + .Machine$double.eps, .Machine$double.neg.eps, 897s + FALSE, TRUE, NA 897s + ) 897s > 897s > nrow <- 2L 897s > ncol <- 3L 897s > for (value in values) { 897s + x0 <- allocMatrix_R(nrow, ncol, value = value) 897s + x <- allocMatrix(nrow, ncol, value = value) 897s + if (!identical(x, x0)) { 897s + str(list(nrow = nrow, ncol = ncol, value = value, x = x, x0 = x0)) 897s + stopifnot(identical(x, x0)) 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > allocVector_R <- function(length, value = NA) { 897s + x <- vector(mode = typeof(value), length = length) 897s + if (!is.finite(value) || value != 0) x[] <- value 897s + x 897s + } 897s > 897s > values <- list( 897s + -1L, 0L, +1L, NA_integer_, .Machine$integer.max, 897s + -1, 0, +1, NA_real_, NaN, -Inf, +Inf, 897s + .Machine$double.xmin, .Machine$double.xmax, 897s + .Machine$double.eps, .Machine$double.neg.eps, 897s + FALSE, TRUE, NA 897s + ) 897s > 897s > n <- 10L 897s > for (value in values) { 897s + x0 <- allocVector_R(n, value = value) 897s + x <- allocVector(n, value = value) 897s + if (!identical(x, x0)) { 897s + str(list(n = n, value = value, x = x, x0 = x0)) 897s + stopifnot(identical(x, x0)) 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Setup 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > data <- data.frame( 897s + logical = c(TRUE, FALSE, TRUE), 897s + integer = 1:3, 897s + double = seq(from = 1.0, to = 3.0, by = 1.0), 897s + complex = seq(from = 1.0, to = 3.0, by = 1.0) + 1.0i, 897s + character = letters[1:3], 897s + stringsAsFactors = FALSE 897s + ) 897s > 897s > modes <- names(data) 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Special cases 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > cat("NULL...\n") 897s NULL... 897s > stopifnot(identical(anyMissing(NULL), FALSE)) 897s > cat("NULL...done\n") 897s NULL...done 897s > 897s > cat("raw...\n") 897s raw... 897s > stopifnot(identical(anyMissing(as.raw(0:2)), FALSE)) 897s > cat("raw...done\n") 897s raw...done 897s > 897s > cat("list(NULL)...\n") 897s list(NULL)... 897s > stopifnot(identical(anyMissing(list(NULL)), FALSE)) 897s > cat("list(NULL)...done\n") 897s list(NULL)...done 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Scalars, vectors, and matrices of various modes 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > for (mode in modes) { 897s + cat(sprintf("Mode: %s...\n", mode)) 897s + values <- data[[mode]] 897s + 897s + # Scalars 897s + cat(" scalar\n") 897s + x <- values[1L] 897s + print(x) 897s + stopifnot(identical(anyMissing(x), FALSE)) 897s + is.na(x) <- TRUE 897s + print(x) 897s + stopifnot(identical(anyMissing(x), TRUE)) 897s + 897s + # Vectors 897s + cat(" vector\n") 897s + x <- values 897s + print(x) 897s + stopifnot(identical(anyMissing(x), FALSE)) 897s + is.na(x)[2L] <- TRUE 897s + print(x) 897s + stopifnot(identical(anyMissing(x), TRUE)) 897s + 897s + # Matrices 897s + cat(" matrix\n") 897s + x <- matrix(c(values, values), ncol = 2L) 897s + print(x) 897s + stopifnot(identical(anyMissing(x), FALSE)) 897s + is.na(x)[2L] <- TRUE 897s + print(x) 897s + stopifnot(identical(anyMissing(x), TRUE)) 897s + 897s + cat(sprintf("Mode: %s...done\n", mode)) 897s + } # for (mode ...) 897s Mode: logical... 897s scalar 897s [1] TRUE 897s [1] NA 897s vector 897s [1] TRUE FALSE TRUE 897s [1] TRUE NA TRUE 897s matrix 897s [,1] [,2] 897s [1,] TRUE TRUE 897s [2,] FALSE FALSE 897s [3,] TRUE TRUE 897s [,1] [,2] 897s [1,] TRUE TRUE 897s [2,] NA FALSE 897s [3,] TRUE TRUE 897s Mode: logical...done 897s Mode: integer... 897s scalar 897s [1] 1 897s [1] NA 897s vector 897s [1] 1 2 3 897s [1] 1 NA 3 897s matrix 897s [,1] [,2] 897s [1,] 1 1 897s [2,] 2 2 897s [3,] 3 3 897s [,1] [,2] 897s [1,] 1 1 897s [2,] NA 2 897s [3,] 3 3 897s Mode: integer...done 897s Mode: double... 897s scalar 897s [1] 1 897s [1] NA 897s vector 897s [1] 1 2 3 897s [1] 1 NA 3 897s matrix 897s [,1] [,2] 897s [1,] 1 1 897s [2,] 2 2 897s [3,] 3 3 897s [,1] [,2] 897s [1,] 1 1 897s [2,] NA 2 897s [3,] 3 3 897s Mode: double...done 897s Mode: complex... 897s scalar 897s [1] 1+1i 897s [1] NA 897s vector 897s [1] 1+1i 2+1i 3+1i 897s [1] 1+1i NA 3+1i 897s matrix 897s [,1] [,2] 897s [1,] 1+1i 1+1i 897s [2,] 2+1i 2+1i 897s [3,] 3+1i 3+1i 897s [,1] [,2] 897s [1,] 1+1i 1+1i 897s [2,] NA 2+1i 897s [3,] 3+1i 3+1i 897s Mode: complex...done 897s Mode: character... 897s scalar 897s [1] "a" 897s [1] NA 897s vector 897s [1] "a" "b" "c" 897s [1] "a" NA "c" 897s matrix 897s [,1] [,2] 897s [1,] "a" "a" 897s [2,] "b" "b" 897s [3,] "c" "c" 897s [,1] [,2] 897s [1,] "a" "a" 897s [2,] NA "b" 897s [3,] "c" "c" 897s Mode: character...done 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Data frames 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > cat("data.frame...\n") 897s data.frame... 897s > x <- data 897s > stopifnot(identical(anyMissing(x), FALSE)) 897s > for (mode in modes) { 897s + x <- data 897s + is.na(x[[mode]])[2L] <- TRUE 897s + print(x) 897s + stopifnot(identical(anyMissing(x), TRUE)) 897s + } # for (mode ...) 897s logical integer double complex character 897s 1 TRUE 1 1 1+1i a 897s 2 NA 2 2 2+1i b 897s 3 TRUE 3 3 3+1i c 897s logical integer double complex character 897s 1 TRUE 1 1 1+1i a 897s 2 FALSE NA 2 2+1i b 897s 3 TRUE 3 3 3+1i c 897s logical integer double complex character 897s 1 TRUE 1 1 1+1i a 897s 2 FALSE 2 NA 2+1i b 897s 3 TRUE 3 3 3+1i c 897s logical integer double complex character 897s 1 TRUE 1 1 1+1i a 897s 2 FALSE 2 2 NA b 897s 3 TRUE 3 3 3+1i c 897s logical integer double complex character 897s 1 TRUE 1 1 1+1i a 897s 2 FALSE 2 2 2+1i 897s 3 TRUE 3 3 3+1i c 897s > cat("data.frame...done\n") 897s data.frame...done 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Lists 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > cat("list...\n") 897s list... 897s > x <- as.list(data) 897s > stopifnot(identical(anyMissing(x), FALSE)) 897s > for (mode in modes) { 897s + x <- as.list(data) 897s + is.na(x[[mode]])[2L] <- TRUE 897s + print(x) 897s + stopifnot(identical(anyMissing(x), TRUE)) 897s + } # for (mode ...) 897s $logical 897s [1] TRUE NA TRUE 897s 897s $integer 897s [1] 1 2 3 897s 897s $double 897s [1] 1 2 3 897s 897s $complex 897s [1] 1+1i 2+1i 3+1i 897s 897s $character 897s [1] "a" "b" "c" 897s 897s $logical 897s [1] TRUE FALSE TRUE 897s 897s $integer 897s [1] 1 NA 3 897s 897s $double 897s [1] 1 2 3 897s 897s $complex 897s [1] 1+1i 2+1i 3+1i 897s 897s $character 897s [1] "a" "b" "c" 897s 897s $logical 897s [1] TRUE FALSE TRUE 897s 897s $integer 897s [1] 1 2 3 897s 897s $double 897s [1] 1 NA 3 897s 897s $complex 897s [1] 1+1i 2+1i 3+1i 897s 897s $character 897s [1] "a" "b" "c" 897s 897s $logical 897s [1] TRUE FALSE TRUE 897s 897s $integer 897s [1] 1 2 3 897s 897s $double 897s [1] 1 2 3 897s 897s $complex 897s [1] 1+1i NA 3+1i 897s 897s $character 897s [1] "a" "b" "c" 897s 897s $logical 897s [1] TRUE FALSE TRUE 897s 897s $integer 897s [1] 1 2 3 897s 897s $double 897s [1] 1 2 3 897s 897s $complex 897s [1] 1+1i 2+1i 3+1i 897s 897s $character 897s [1] "a" NA "c" 897s 897s > cat("list...done\n") 897s list...done 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > x <- runif(4, min = -3, max = 3) 897s > x[2] <- NA 897s > for (mode in c("integer", "numeric")) { 897s + storage.mode(x) <- mode 897s + for (idxs in index_cases) { 897s + validateIndicesTestVector(x, idxs, 897s + ftest = anyMissing, fsure = function(x, ...) { 897s + anyValue(x, value = NA) 897s + }) 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > ## 1. Don't test with valgrind 897s > ## 2. Test only R (>= 3.0.2) because of that's what knitr requires 897s > if (getRversion() >= "3.0.2" && Sys.getenv("_R_CHECK_USE_VALGRIND_") == "") { 897s + 897s + ## 3. Make sure all suggested packages are installed / can be loaded 897s + pkgs <- c("base64enc", "ggplot2", "knitr", "markdown", "microbenchmark", 897s + "R.devices", "R.rsp") 897s + if (all(unlist(lapply(pkgs, FUN = requireNamespace)))) { 897s + html <- matrixStats:::benchmark("binCounts") 897s + print(html) 897s + } 897s + 897s + rm(list = "pkgs") 897s + 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > library("stats") 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Local functions 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > binCounts_hist <- function(x, bx, right = FALSE, ...) { 897s + n0 <- graphics::hist(x, breaks = bx, right = right, 897s + include.lowest = TRUE, plot = FALSE)$counts 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Non-sorted and sorted positions 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > nx <- 1000L # Number of data points 897s > nb <- 200L # Number of bins 897s > 897s > # Uniformely distributed bins 897s > bx <- seq(from = 0, to = 1, length.out = nb + 1L) 897s > bx <- c(-1, bx, 2) 897s > 897s > # Sample data points 897s > set.seed(0xBEEF) 897s > x <- runif(nx, min = 0, max = 1) 897s > 897s > for (kk in 1:2) { 897s + n0 <- binCounts_hist(x, bx = bx) 897s + n1 <- binCounts(x, bx = bx) 897s + # Sanity check 897s + stopifnot(identical(n1, n0)) 897s + 897s + # Check reversed 897s + n1r <- rev(binCounts(-x, bx = rev(-bx), right = TRUE)) 897s + stopifnot(identical(n1r, n1)) 897s + 897s + # Retry with a sorted vector 897s + x <- sort(x) 897s + } # for (kk in 1:2) 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Missing values 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- 1:40 897s > x[20] <- NA_integer_ 897s > nx <- length(x) 897s > 897s > # Bins 897s > bx <- c(0.5, 50.5, 100.5, 150.5, 200.5) 897s > 897s > y_smooth0 <- binCounts_hist(x, bx = bx) 897s > y_smooth <- binCounts(x, bx = bx) 897s > # Sanity check 897s > stopifnot(all.equal(y_smooth, y_smooth0)) 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Border cases 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- 1:10 897s > bx <- min(x) - c(10, 1) 897s > y_smooth <- binCounts(x, bx = bx) 897s > stopifnot(all.equal(y_smooth, 0L)) 897s > bx <- range(x) 897s > y_smooth <- binCounts(x, bx = bx) 897s > stopifnot(all.equal(y_smooth, length(x) - 1L)) 897s > bx <- max(x) + c(1, 10) 897s > y_smooth <- binCounts(x, bx = bx) 897s > stopifnot(all.equal(y_smooth, 0L)) 897s > 897s > # Every second empty 897s > x <- 1:10 897s > bx <- rep(x, each = 2L) 897s > y_smooth <- binCounts(x, bx = bx) 897s > stopifnot(all.equal(y_smooth, rep(c(0L, 1L), length.out = length(bx) - 1L))) 897s > ## NOTE: binCounts_hist() does not give the same last bin count 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Exception handling 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Zero bin bounderies (invalid bin definition) 897s > bx <- double(0L) 897s > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE) 897s > stopifnot(inherits(res, "try-error")) 897s > 897s > # One bin boundery (invalid bin definition) 897s > bx <- double(1L) 897s > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE) 897s > stopifnot(inherits(res, "try-error")) 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Local functions 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > binCounts_hist <- function(x, bx, right = FALSE, ...) { 897s + n0 <- graphics::hist(x, breaks = bx, right = right, 897s + include.lowest = TRUE, plot = FALSE)$counts 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > x <- runif(6, min = -6, max = 6) 897s > storage.mode(x) <- "integer" 897s > bx <- c(-6, 0, 3, 4, 10) 897s > for (idxs in index_cases) { 897s + validateIndicesTestVector(x, idxs, 897s + ftest = binCounts, fsure = binCounts_hist, 897s + bx = bx, right = FALSE) 897s + validateIndicesTestVector(x, idxs, 897s + ftest = binCounts, fsure = binCounts_hist, 897s + bx = bx, right = TRUE) 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > library("stats") 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Naive R implementation of binMeans() 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > binMeans0 <- function(y, x, bx, na.rm = TRUE, count = TRUE, right = FALSE) { 897s + n_smooth <- length(bx) - 1L 897s + res <- double(n_smooth) 897s + counts <- rep(NaN, times = n_smooth) 897s + 897s + if (na.rm) { 897s + keep <- !is.na(x) & !is.na(y) 897s + x <- x[keep] 897s + y <- y[keep] 897s + } 897s + 897s + # For each bin... 897s + for (kk in seq_len(n_smooth)) { 897s + if (right) { 897s + idxs <- which(bx[kk] < x & x <= bx[kk + 1L]) 897s + } else { 897s + idxs <- which(bx[kk] <= x & x < bx[kk + 1L]) 897s + } 897s + y_kk <- y[idxs] 897s + res[kk] <- mean(y_kk) 897s + counts[kk] <- length(idxs) 897s + } # for (kk ...) 897s + 897s + if (count) attr(res, "count") <- counts 897s + res 897s + } 897s > 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Case #1 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- 1:100 897s > nx <- length(x) 897s > y <- double(nx) 897s > y[1:25] <- 5 897s > y[51:75] <- -5 897s > y <- y + rnorm(nx) 897s > 897s > # Bins 897s > bx <- c(0.5, 25.5, 50.5, 75.5, 100.5) 897s > 897s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 897s > y_smooth <- binMeans(y, x = x, bx = bx) 897s > n_smooth <- binCounts(x, bx = bx) 897s > # Sanity check 897s > stopifnot(all.equal(y_smooth, y_smooth0)) 897s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 897s > 897s > y_smooth0r <- rev(binMeans0(y, x = -x, bx = rev(-bx), 897s + count = FALSE, right = TRUE)) 897s > y_smoothr <- rev(binMeans(y, x = -x, bx = rev(-bx), 897s + count = FALSE, right = TRUE)) 897s > # Sanity check 897s > stopifnot(all.equal(y_smooth0r, y_smooth0, check.attributes = FALSE)) 897s > stopifnot(all.equal(y_smoothr, y_smooth0r)) 897s > 897s > 897s > # Integer input 897s > y <- as.integer(y) 897s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 897s > y_smooth <- binMeans(y, x = x, bx = bx) 897s > n_smooth <- binCounts(x, bx = bx) 897s > # Sanity check 897s > stopifnot(is.integer(y), 897s + all.equal(y_smooth, y_smooth0), 897s + all.equal(attr(y_smooth, "count"), n_smooth)) 897s > 897s > # Logical input 897s > y <- as.logical(y) 897s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 897s > y_smooth <- binMeans(y, x = x, bx = bx) 897s > n_smooth <- binCounts(x, bx = bx) 897s > # Sanity check 897s > stopifnot(is.logical(y), 897s + all.equal(y_smooth, y_smooth0), 897s + all.equal(attr(y_smooth, "count"), n_smooth)) 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Case #2 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > nx <- 1e3 897s > x <- runif(nx) 897s > y <- runif(nx) 897s > 897s > nb <- 10 897s > bx <- do.call(seq, c(as.list(range(x)), length.out = nb)) 897s > bx1 <- c(bx[-1], bx[nb] + 1) 897s > 897s > y_smooth0 <- binMeans0(y, x = x, bx = bx1) 897s > y_smooth <- binMeans(y, x = x, bx = bx1) 897s > n_smooth <- binCounts(x, bx = bx1) 897s > y_smoothr <- rev(binMeans(y, x = -x, bx = rev(-bx1), right = TRUE)) 897s > 897s > # Sanity check 897s > stopifnot(all.equal(y_smooth, y_smooth0)) 897s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 897s > stopifnot(all.equal(y_smoothr, y_smooth, check.attributes = FALSE)) 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Empty bins 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- c(6:8, 16:19) 897s > nx <- length(x) 897s > y <- runif(nx) 897s > bx <- c(0, 5, 10, 15, 20, 25) 897s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 897s > y_smooth <- binMeans(y, x = x, bx = bx) 897s > n_smooth <- binCounts(x, bx = bx) 897s > stopifnot(all.equal(attr(y_smooth, "count"), n_smooth)) 897s > stopifnot(all.equal(y_smooth, y_smooth0)) 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Missing values 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- 1:100 897s > x[50] <- NA_integer_ 897s > nx <- length(x) 897s > y <- double(nx) 897s > y[1:25] <- 5 897s > y[51:75] <- -5 897s > y[82:92] <- NA_real_ 897s > y <- y + rnorm(nx) 897s > 897s > # Bins 897s > bx <- c(0.5, 25.5, 75.5, 82.5, 100.5) 897s > 897s > y_smooth0 <- binMeans0(y, x = x, bx = bx) 897s > y_smooth <- binMeans(y, x = x, bx = bx) 897s > # Sanity check 897s > stopifnot(all.equal(y_smooth, y_smooth0)) 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Exception handling 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Zero bin bounderies (invalid bin definition) 897s > bx <- double(0L) 897s > res <- try(y_smooth <- binMeans(x = 1:5, y = 1:5, bx = bx), silent = TRUE) 897s > stopifnot(inherits(res, "try-error")) 897s > 897s > # One bin boundery (invalid bin definition) 897s > bx <- double(1L) 897s > res <- try(y_smooth <- binMeans(x = 1:5, y = 1:5, bx = bx), silent = TRUE) 897s > stopifnot(inherits(res, "try-error")) 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Naive R implementation of binMeans() 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > binMeans0 <- function(y, x, bx, na.rm = TRUE, count = TRUE, right = FALSE) { 897s + n_smooth <- length(bx) - 1L 897s + res <- double(n_smooth) 897s + counts <- rep(NaN, times = n_smooth) 897s + 897s + if (na.rm) { 897s + keep <- !is.na(x) & !is.na(y) 897s + x <- x[keep] 897s + y <- y[keep] 897s + } 897s + 897s + # For each bin... 897s + for (kk in seq_len(n_smooth)) { 897s + if (right) { 897s + idxs <- which(bx[kk] < x & x <= bx[kk + 1L]) 897s + } else { 897s + idxs <- which(bx[kk] <= x & x < bx[kk + 1L]) 897s + } 897s + y_kk <- y[idxs] 897s + res[kk] <- mean(y_kk) 897s + counts[kk] <- length(idxs) 897s + } # for (kk ...) 897s + 897s + if (count) attr(res, "count") <- counts 897s + res 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > y <- runif(6, min = -6, max = 6) 897s > x <- runif(6, min = -6, max = 6) 897s > storage.mode(x) <- "integer" 897s > bx <- c(-6, 0, 3, 4, 10) 897s > for (idxs in index_cases) { 897s + for (na.rm in c(TRUE, FALSE)) { 897s + validateIndicesTestVector_w(y, x, idxs, 897s + ftest = binMeans, fsure = binMeans0, 897s + bx = bx, na.rm = na.rm, 897s + count = TRUE, right = FALSE) 897s + validateIndicesTestVector_w(y, x, idxs, 897s + ftest = binMeans, fsure = binMeans0, 897s + bx = bx, na.rm = na.rm, 897s + count = TRUE, right = TRUE) 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 897s + if (is.na(value)) { 897s + counts <- sum(is.na(x)) 897s + } else { 897s + counts <- sum(x == value, na.rm = na.rm) 897s + } 897s + as.integer(counts) 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Data type: integer and numeric 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > for (mode in c("integer", "double")) { 897s + x <- runif(20 * 5, min = -3, max = 3) 897s + x[sample.int(length(x), size = 7)] <- 0 897s + storage.mode(x) <- mode 897s + 897s + for (na.rm in c(FALSE, TRUE)) { 897s + # Count zeros 897s + n0 <- count_R(x, value = 0, na.rm = na.rm) 897s + n1 <- count(x, value = 0, na.rm = na.rm) 897s + stopifnot(identical(n1, n0)) 897s + all <- allValue(x, value = 0, na.rm = na.rm) 897s + any <- anyValue(x, value = 0, na.rm = na.rm) 897s + 897s + # Count NAs 897s + n0 <- count_R(x, value = NA, na.rm = na.rm) 897s + n1 <- count(x, value = NA, na.rm = na.rm) 897s + stopifnot(identical(n1, n0)) 897s + all <- allValue(x, value = NA, na.rm = na.rm) 897s + any <- anyValue(x, value = NA, na.rm = na.rm) 897s + 897s + if (mode == "integer") { 897s + ux <- unique(as.vector(x)) 897s + n0 <- n1 <- integer(length(x)) 897s + for (value in ux) { 897s + n0 <- n0 + count_R(x, value = value, na.rm = na.rm) 897s + n1 <- n1 + count(x, value = value, na.rm = na.rm) 897s + stopifnot(identical(n1, n0)) 897s + } 897s + stopifnot(all(n0 == ncol(x))) 897s + } # if (mode == "integer") 897s + 897s + } # for (na.rm ...) 897s + } # for (mode ...) 897s > 897s > # All NAs 897s > na_list <- list(NA_integer_, NA_real_, NaN) 897s > for (na_value in na_list) { 897s + x <- rep(na_value, times = 10L) 897s + for (na.rm in c(FALSE, TRUE)) { 897s + n0 <- count_R(x, na.rm = na.rm) 897s + n1 <- count(x, na.rm = na.rm) 897s + stopifnot(identical(n1, n0)) 897s + 897s + # Count NAs 897s + n0 <- count_R(x, value = NA, na.rm = na.rm) 897s + n1 <- count(x, value = NA, na.rm = na.rm) 897s + stopifnot(identical(n1, n0)) 897s + any <- anyValue(x, value = NA, na.rm = na.rm) 897s + all <- allValue(x, value = NA, na.rm = na.rm) 897s + stopifnot(any) 897s + stopifnot(all) 897s + } 897s + } # for (na_value ...) 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Data type: logical 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- logical(length = 10L) 897s > x[3:7] <- TRUE 897s > 897s > # Row/column counts 897s > for (na.rm in c(FALSE, TRUE)) { 897s + n0 <- count_R(x, na.rm = na.rm) 897s + n1 <- count(x, na.rm = na.rm) 897s + stopifnot(identical(n1, n0)) 897s + 897s + n_true <- count(x, value = TRUE, na.rm = na.rm) 897s + n_false <- count(x, value = FALSE, na.rm = na.rm) 897s + stopifnot(n_true + n_false == ncol(x)) 897s + 897s + # Count NAs 897s + n0 <- count_R(x, value = NA, na.rm = na.rm) 897s + n1 <- count(x, value = NA, na.rm = na.rm) 897s + stopifnot(identical(n1, n0)) 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 897s + if (is.na(value)) { 897s + counts <- sum(is.na(x)) 897s + } else { 897s + counts <- sum(x == value, na.rm = na.rm) 897s + } 897s + as.integer(counts) 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > x <- runif(6, min = -3, max = 3) 897s > storage.mode(x) <- "integer" 897s > for (idxs in index_cases) { 897s + validateIndicesTestVector(x, idxs, 897s + ftest = count, fsure = count_R, 897s + value = 0, na.rm = TRUE) 897s + validateIndicesTestVector(x, idxs, 897s + ftest = count, fsure = count_R, 897s + value = 0, na.rm = FALSE) 897s + validateIndicesTestVector(x, idxs, 897s + ftest = count, fsure = count_R, 897s + value = NA_integer_) 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > diff2_R <- function(..., useNames = NA){ 897s + res <- diff(...) 897s + if (is.na(useNames) || !useNames) names(res) <- NULL 897s + res 897s + } 897s > 897s > set.seed(0x42) 897s > 897s > for (mode in c("integer", "double")) { 897s + x <- rnorm(10, sd = 5) 897s + storage.mode(x) <- mode 897s + str(x) 897s + 897s + for (has_na in c(FALSE, TRUE)) { 897s + for (setNames in c(TRUE, FALSE)) { 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + if (has_na) { 897s + x[sample(1:10, size = 3)] <- NA 897s + } 897s + if (setNames) { 897s + names(x) <- LETTERS[1:10] 897s + } 897s + for (l in 1:3) { 897s + for (d in 1:4) { 897s + cat(sprintf("%s: NAs = %s, lag = %d, differences = %d, setNames = %d, useNames = %d\n", 897s + mode, has_na, l, d, setNames, useNames)) 897s + y0 <- diff2_R(x, lag = l, differences = d, useNames = useNames) 897s + str(y0) 897s + y1 <- diff2(x, lag = l, differences = d, useNames = useNames) 897s + str(y1) 897s + stopifnot(identical(y1, y0)) 897s + } 897s + } 897s + } 897s + } 897s + } # for (has_na ...) 897s + } 897s int [1:10] 11 1 2 0 -1 -3 -3 6 0 0 897s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1 897s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1 897s Named int [1:8] 11 -3 1 -1 2 9 -15 6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named int [1:8] 11 -3 1 -1 2 9 -15 6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1 897s Named int [1:7] -14 4 -2 3 7 -24 21 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named int [1:7] -14 4 -2 3 7 -24 21 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1 897s Named int [1:6] 18 -6 5 4 -31 45 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named int [1:6] 18 -6 5 4 -31 45 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1 897s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1 897s Named int [1:6] 6 -2 1 12 5 -15 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named int [1:6] 6 -2 1 12 5 -15 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1 897s Named int [1:4] -5 14 4 -27 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named int [1:4] -5 14 4 -27 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1 897s Named int [1:2] 9 -41 897s - attr(*, "names")= chr [1:2] "I" "J" 897s Named int [1:2] 9 -41 897s - attr(*, "names")= chr [1:2] "I" "J" 897s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1 897s Named int [1:7] -11 -2 -5 -3 7 3 3 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named int [1:7] -11 -2 -5 -3 7 3 3 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1 897s Named int [1:4] 8 9 8 6 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named int [1:4] 8 9 8 6 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1 897s Named int -2 897s - attr(*, "names")= chr "J" 897s Named int -2 897s - attr(*, "names")= chr "J" 897s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1 897s Named int(0) 897s - attr(*, "names")= chr(0) 897s Named int(0) 897s - attr(*, "names")= chr(0) 897s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0 897s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 897s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 897s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0 897s int [1:8] 11 -3 1 -1 2 9 -15 6 897s int [1:8] 11 -3 1 -1 2 9 -15 6 897s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0 897s int [1:7] -14 4 -2 3 7 -24 21 897s int [1:7] -14 4 -2 3 7 -24 21 897s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0 897s int [1:6] 18 -6 5 4 -31 45 897s int [1:6] 18 -6 5 4 -31 45 897s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0 897s int [1:8] -9 -1 -3 -3 -2 9 3 -6 897s int [1:8] -9 -1 -3 -3 -2 9 3 -6 897s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0 897s int [1:6] 6 -2 1 12 5 -15 897s int [1:6] 6 -2 1 12 5 -15 897s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0 897s int [1:4] -5 14 4 -27 897s int [1:4] -5 14 4 -27 897s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0 897s int [1:2] 9 -41 897s int [1:2] 9 -41 897s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0 897s int [1:7] -11 -2 -5 -3 7 3 3 897s int [1:7] -11 -2 -5 -3 7 3 3 897s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0 897s int [1:4] 8 9 8 6 897s int [1:4] 8 9 8 6 897s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0 897s int -2 897s int -2 897s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0 897s int(0) 897s int(0) 897s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1 897s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1 897s Named int [1:8] 11 -3 1 -1 2 9 -15 6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named int [1:8] 11 -3 1 -1 2 9 -15 6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1 897s Named int [1:7] -14 4 -2 3 7 -24 21 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named int [1:7] -14 4 -2 3 7 -24 21 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1 897s Named int [1:6] 18 -6 5 4 -31 45 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named int [1:6] 18 -6 5 4 -31 45 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1 897s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named int [1:8] -9 -1 -3 -3 -2 9 3 -6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1 897s Named int [1:6] 6 -2 1 12 5 -15 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named int [1:6] 6 -2 1 12 5 -15 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1 897s Named int [1:4] -5 14 4 -27 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named int [1:4] -5 14 4 -27 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1 897s Named int [1:2] 9 -41 897s - attr(*, "names")= chr [1:2] "I" "J" 897s Named int [1:2] 9 -41 897s - attr(*, "names")= chr [1:2] "I" "J" 897s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1 897s Named int [1:7] -11 -2 -5 -3 7 3 3 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named int [1:7] -11 -2 -5 -3 7 3 3 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1 897s Named int [1:4] 8 9 8 6 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named int [1:4] 8 9 8 6 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1 897s Named int -2 897s - attr(*, "names")= chr "J" 897s Named int -2 897s - attr(*, "names")= chr "J" 897s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1 897s Named int(0) 897s - attr(*, "names")= chr(0) 897s Named int(0) 897s - attr(*, "names")= chr(0) 897s integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0 897s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 897s int [1:9] -10 1 -2 -1 -2 0 9 -6 0 897s integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0 897s int [1:8] 11 -3 1 -1 2 9 -15 6 897s int [1:8] 11 -3 1 -1 2 9 -15 6 897s integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0 897s int [1:7] -14 4 -2 3 7 -24 21 897s int [1:7] -14 4 -2 3 7 -24 21 897s integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0 897s int [1:6] 18 -6 5 4 -31 45 897s int [1:6] 18 -6 5 4 -31 45 897s integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0 897s int [1:8] -9 -1 -3 -3 -2 9 3 -6 897s int [1:8] -9 -1 -3 -3 -2 9 3 -6 897s integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0 897s int [1:6] 6 -2 1 12 5 -15 897s int [1:6] 6 -2 1 12 5 -15 897s integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0 897s int [1:4] -5 14 4 -27 897s int [1:4] -5 14 4 -27 897s integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0 897s int [1:2] 9 -41 897s int [1:2] 9 -41 897s integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0 897s int [1:7] -11 -2 -5 -3 7 3 3 897s int [1:7] -11 -2 -5 -3 7 3 3 897s integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0 897s int [1:4] 8 9 8 6 897s int [1:4] 8 9 8 6 897s integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0 897s int -2 897s int -2 897s integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0 897s int(0) 897s int(0) 897s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1 897s Named int [1:9] NA NA NA NA NA 0 9 -6 0 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s Named int [1:9] NA NA NA NA NA 0 9 -6 0 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1 897s Named int [1:8] NA NA NA NA NA 9 -15 6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named int [1:8] NA NA NA NA NA 9 -15 6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1 897s Named int [1:7] NA NA NA NA NA -24 21 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named int [1:7] NA NA NA NA NA -24 21 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1 897s Named int [1:6] NA NA NA NA NA 45 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named int [1:6] NA NA NA NA NA 45 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1 897s Named int [1:8] -9 NA NA NA NA 9 3 -6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named int [1:8] -9 NA NA NA NA 9 3 -6 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1 897s Named int [1:6] NA NA NA NA NA -15 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named int [1:6] NA NA NA NA NA -15 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1 897s Named int [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named int [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1 897s Named int [1:2] NA NA 897s - attr(*, "names")= chr [1:2] "I" "J" 897s Named int [1:2] NA NA 897s - attr(*, "names")= chr [1:2] "I" "J" 897s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1 897s Named int [1:7] NA NA -5 NA NA 3 3 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named int [1:7] NA NA -5 NA NA 3 3 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1 897s Named int [1:4] NA NA 8 NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named int [1:4] NA NA 8 NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1 897s Named int NA 897s - attr(*, "names")= chr "J" 897s Named int NA 897s - attr(*, "names")= chr "J" 897s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1 897s Named int(0) 897s - attr(*, "names")= chr(0) 897s Named int(0) 897s - attr(*, "names")= chr(0) 897s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0 897s int [1:9] NA NA NA NA NA 0 9 NA NA 897s int [1:9] NA NA NA NA NA 0 9 NA NA 897s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0 897s int [1:8] NA NA NA NA NA 9 NA NA 897s int [1:8] NA NA NA NA NA 9 NA NA 897s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0 897s int [1:7] NA NA NA NA NA NA NA 897s int [1:7] NA NA NA NA NA NA NA 897s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0 897s int [1:6] NA NA NA NA NA NA 897s int [1:6] NA NA NA NA NA NA 897s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0 897s int [1:8] NA NA NA NA NA 9 NA -6 897s int [1:8] NA NA NA NA NA 9 NA -6 897s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0 897s int [1:6] NA NA NA NA NA -15 897s int [1:6] NA NA NA NA NA -15 897s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0 897s int [1:4] NA NA NA NA 897s int [1:4] NA NA NA NA 897s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0 897s int [1:2] NA NA 897s int [1:2] NA NA 897s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0 897s int [1:7] NA NA NA NA NA NA 3 897s int [1:7] NA NA NA NA NA NA 3 897s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0 897s int [1:4] NA NA NA NA 897s int [1:4] NA NA NA NA 897s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0 897s int NA 897s int NA 897s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0 897s int(0) 897s int(0) 897s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1 897s Named int [1:9] NA NA NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s Named int [1:9] NA NA NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1 897s Named int [1:8] NA NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named int [1:8] NA NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1 897s Named int [1:7] NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named int [1:7] NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1 897s Named int [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named int [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1 897s Named int [1:8] NA NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named int [1:8] NA NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1 897s Named int [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named int [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1 897s Named int [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named int [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1 897s Named int [1:2] NA NA 897s - attr(*, "names")= chr [1:2] "I" "J" 897s Named int [1:2] NA NA 897s - attr(*, "names")= chr [1:2] "I" "J" 897s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1 897s Named int [1:7] NA NA NA NA NA NA 3 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named int [1:7] NA NA NA NA NA NA 3 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1 897s Named int [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named int [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1 897s Named int NA 897s - attr(*, "names")= chr "J" 897s Named int NA 897s - attr(*, "names")= chr "J" 897s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1 897s Named int(0) 897s - attr(*, "names")= chr(0) 897s Named int(0) 897s - attr(*, "names")= chr(0) 897s integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0 897s int [1:9] NA NA NA NA NA NA NA NA NA 897s int [1:9] NA NA NA NA NA NA NA NA NA 897s integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0 897s int [1:8] NA NA NA NA NA NA NA NA 897s int [1:8] NA NA NA NA NA NA NA NA 897s integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0 897s int [1:7] NA NA NA NA NA NA NA 897s int [1:7] NA NA NA NA NA NA NA 897s integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0 897s int [1:6] NA NA NA NA NA NA 897s int [1:6] NA NA NA NA NA NA 897s integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0 897s int [1:8] NA NA NA NA NA NA NA NA 897s int [1:8] NA NA NA NA NA NA NA NA 897s integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0 897s int [1:6] NA NA NA NA NA NA 897s int [1:6] NA NA NA NA NA NA 897s integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0 897s int [1:4] NA NA NA NA 897s int [1:4] NA NA NA NA 897s integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0 897s int [1:2] NA NA 897s int [1:2] NA NA 897s integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0 897s int [1:7] NA NA NA NA NA NA 3 897s int [1:7] NA NA NA NA NA NA 3 897s integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0 897s int [1:4] NA NA NA NA 897s int [1:4] NA NA NA NA 897s integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0 897s int NA 897s int NA 897s integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0 897s int(0) 897s int(0) 897s num [1:10] 2.586 -0.344 0.33 9.155 -3.254 ... 897s double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1 897s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1 897s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1 897s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1 897s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1 897s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1 897s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1 897s Named num [1:4] 0.368 42.988 15.396 -29.313 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named num [1:4] 0.368 42.988 15.396 -29.313 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1 897s Named num [1:2] 15 -72.3 897s - attr(*, "names")= chr [1:2] "I" "J" 897s Named num [1:2] 15 -72.3 897s - attr(*, "names")= chr [1:2] "I" "J" 897s double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1 897s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1 897s Named num [1:4] -23.52 7.92 11.38 23.27 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named num [1:4] -23.52 7.92 11.38 23.27 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1 897s Named num 46.8 897s - attr(*, "names")= chr "J" 897s Named num 46.8 897s - attr(*, "names")= chr "J" 897s double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1 897s Named num(0) 897s - attr(*, "names")= chr(0) 897s Named num(0) 897s - attr(*, "names")= chr(0) 897s double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0 897s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 897s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 897s double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0 897s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 897s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 897s double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0 897s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 897s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 897s double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0 897s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 897s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 897s double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0 897s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 897s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 897s double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0 897s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 897s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 897s double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0 897s num [1:4] 0.368 42.988 15.396 -29.313 897s num [1:4] 0.368 42.988 15.396 -29.313 897s double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0 897s num [1:2] 15 -72.3 897s num [1:2] 15 -72.3 897s double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0 897s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 897s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 897s double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0 897s num [1:4] -23.52 7.92 11.38 23.27 897s num [1:4] -23.52 7.92 11.38 23.27 897s double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0 897s num 46.8 897s num 46.8 897s double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0 897s num(0) 897s num(0) 897s double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1 897s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1 897s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1 897s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1 897s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1 897s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1 897s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1 897s Named num [1:4] 0.368 42.988 15.396 -29.313 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named num [1:4] 0.368 42.988 15.396 -29.313 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1 897s Named num [1:2] 15 -72.3 897s - attr(*, "names")= chr [1:2] "I" "J" 897s Named num [1:2] 15 -72.3 897s - attr(*, "names")= chr [1:2] "I" "J" 897s double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1 897s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1 897s Named num [1:4] -23.52 7.92 11.38 23.27 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named num [1:4] -23.52 7.92 11.38 23.27 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1 897s Named num 46.8 897s - attr(*, "names")= chr "J" 897s Named num 46.8 897s - attr(*, "names")= chr "J" 897s double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1 897s Named num(0) 897s - attr(*, "names")= chr(0) 897s Named num(0) 897s - attr(*, "names")= chr(0) 897s double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0 897s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 897s num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ... 897s double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0 897s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 897s num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ... 897s double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0 897s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 897s num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ... 897s double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0 897s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 897s num [1:6] -33.9 61.8 -45.7 28.3 -37 ... 897s double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0 897s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 897s num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ... 897s double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0 897s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 897s num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ... 897s double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0 897s num [1:4] 0.368 42.988 15.396 -29.313 897s num [1:4] 0.368 42.988 15.396 -29.313 897s double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0 897s Loading required namespace: base64enc 897s Loading required namespace: ggplot2 897s Loading required namespace: knitr 897s Loading required namespace: markdown 897s Loading required namespace: microbenchmark 897s Failed with error: ‘there is no package called ‘microbenchmark’’ 897s Loading required namespace: R.devices 897s Loading required namespace: R.rsp 897s num [1:2] 15 -72.3 897s num [1:2] 15 -72.3 897s double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0 897s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 897s num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ... 897s double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0 897s num [1:4] -23.52 7.92 11.38 23.27 897s num [1:4] -23.52 7.92 11.38 23.27 897s double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0 897s num 46.8 897s num 46.8 897s double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0 897s num(0) 897s num(0) 897s double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1 897s Named num [1:9] -2.929 0.673 8.826 NA NA ... 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s Named num [1:9] -2.929 0.673 8.826 NA NA ... 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1 897s Named num [1:8] 3.6 8.15 NA NA NA ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named num [1:8] 3.6 8.15 NA NA NA ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1 897s Named num [1:7] 4.55 NA NA NA NA ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named num [1:7] 4.55 NA NA NA NA ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1 897s Named num [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named num [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1 897s Named num [1:8] -2.26 9.5 NA NA NA ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named num [1:8] -2.26 9.5 NA NA NA ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1 897s Named num [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named num [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1 897s Named num [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named num [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1 897s Named num [1:2] NA NA 897s - attr(*, "names")= chr [1:2] "I" "J" 897s Named num [1:2] NA NA 897s - attr(*, "names")= chr [1:2] "I" "J" 897s double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1 897s Named num [1:7] 6.57 NA NA -16.95 NA ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named num [1:7] 6.57 NA NA -16.95 NA ... 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1 897s Named num [1:4] -23.5 NA NA 23.3 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named num [1:4] -23.5 NA NA 23.3 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1 897s Named num 46.8 897s - attr(*, "names")= chr "J" 897s Named num 46.8 897s - attr(*, "names")= chr "J" 897s double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1 897s Named num(0) 897s - attr(*, "names")= chr(0) 897s Named num(0) 897s - attr(*, "names")= chr(0) 897s double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0 897s num [1:9] NA 0.673 8.826 NA NA ... 897s num [1:9] NA 0.673 8.826 NA NA ... 897s double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0 897s num [1:8] NA 8.15 NA NA NA ... 897s num [1:8] NA 8.15 NA NA NA ... 897s double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0 897s num [1:7] NA NA NA NA NA NA NA 897s num [1:7] NA NA NA NA NA NA NA 897s double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0 897s num [1:6] NA NA NA NA NA NA 897s num [1:6] NA NA NA NA NA NA 897s double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0 897s num [1:8] NA 9.5 NA NA NA ... 897s num [1:8] NA 9.5 NA NA NA ... 897s double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0 897s num [1:6] NA NA NA NA NA NA 897s num [1:6] NA NA NA NA NA NA 897s double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0 897s num [1:4] NA NA NA NA 897s num [1:4] NA NA NA NA 897s double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0 897s num [1:2] NA NA 897s num [1:2] NA NA 897s double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0 897s num [1:7] NA NA NA NA NA NA NA 897s num [1:7] NA NA NA NA NA NA NA 897s double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0 897s num [1:4] NA NA NA NA 897s num [1:4] NA NA NA NA 897s double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0 897s num NA 897s num NA 897s double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0 897s num(0) 897s num(0) 897s double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1 897s Named num [1:9] NA 0.673 8.826 NA NA ... 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s Named num [1:9] NA 0.673 8.826 NA NA ... 897s - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ... 897s double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1 897s Named num [1:8] NA 8.15 NA NA NA ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named num [1:8] NA 8.15 NA NA NA ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1 897s Named num [1:7] NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named num [1:7] NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1 897s Named num [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named num [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1 897s Named num [1:8] NA 9.5 NA NA NA ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s Named num [1:8] NA 9.5 NA NA NA ... 897s - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ... 897s double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1 897s Named num [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s Named num [1:6] NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ... 897s double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1 897s Named num [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named num [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1 897s Named num [1:2] NA NA 897s - attr(*, "names")= chr [1:2] "I" "J" 897s Named num [1:2] NA NA 897s - attr(*, "names")= chr [1:2] "I" "J" 897s double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1 897s Named num [1:7] NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s Named num [1:7] NA NA NA NA NA NA NA 897s - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ... 897s double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1 897s Named num [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s Named num [1:4] NA NA NA NA 897s - attr(*, "names")= chr [1:4] "G" "H" "I" "J" 897s double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1 897s Named num NA 897s - attr(*, "names")= chr "J" 897s Named num NA 897s - attr(*, "names")= chr "J" 897s double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1 897s Named num(0) 897s - attr(*, "names")= chr(0) 897s Named num(0) 897s - attr(*, "names")= chr(0) 897s double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0 897s num [1:9] NA 0.673 8.826 NA NA ... 897s num [1:9] NA 0.673 8.826 NA NA ... 897s double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0 897s num [1:8] NA 8.15 NA NA NA ... 897s num [1:8] NA 8.15 NA NA NA ... 897s double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0 897s num [1:7] NA NA NA NA NA NA NA 897s num [1:7] NA NA NA NA NA NA NA 897s double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0 897s num [1:6] NA NA NA NA NA NA 897s num [1:6] NA NA NA NA NA NA 897s double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0 897s num [1:8] NA 9.5 NA NA NA ... 897s num [1:8] NA 9.5 NA NA NA ... 897s double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0 897s num [1:6] NA NA NA NA NA NA 897s num [1:6] NA NA NA NA NA NA 897s double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0 897s num [1:4] NA NA NA NA 897s num [1:4] NA NA NA NA 897s double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0 897s num [1:2] NA NA 897s num [1:2] NA NA 897s double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0 897s num [1:7] NA NA NA NA NA NA NA 897s num [1:7] NA NA NA NA NA NA NA 897s double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0 897s num [1:4] NA NA NA NA 897s num [1:4] NA NA NA NA 897s double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0 897s num NA 897s num NA 897s double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0 897s num(0) 897s num(0) 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > diff2_R <- function(..., useNames=NA){ 897s + res <- diff(...) 897s + if (is.na(useNames) || !useNames) names(res) <- NULL 897s + res 897s + } 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > x <- runif(6, min = -6, max = 6) 897s > for (setNames in c(TRUE, FALSE)) { 897s + if (setNames) names(x) <- LETTERS[1:6] 897s + else names(x) <- NULL 897s + for (l in 1:2) { 897s + for (d in 1:2) { 897s + for (idxs in index_cases) { 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + validateIndicesTestVector(x, idxs, 897s + ftest = diff2, fsure = diff2_R, 897s + lag = l, differences = d, useNames = useNames) 897s + } 897s + } 897s + } 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > indexByRow_R1 <- function(dim, idxs = NULL, ...) { 897s + n <- prod(dim) 897s + x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE) 897s + if (!is.null(idxs)) 897s + x <- x[idxs] 897s + as.vector(x) 897s + } 897s > 897s > 897s > indexByRow_R2 <- function(dim, idxs = NULL, ...) { 897s + n <- prod(dim) 897s + if (is.null(idxs)) { 897s + x <- matrix(seq_len(n), nrow = dim[2L], ncol = dim[1L], byrow = TRUE) 897s + as.vector(x) 897s + } else { 897s + idxs <- idxs - 1L 897s + cols <- idxs %/% dim[2L] 897s + rows <- idxs %% dim[2L] 897s + cols + dim[1L] * rows + 1L 897s + } 897s + } 897s > 897s > 897s > dim <- c(5L, 4L) 897s > x <- matrix(NA_integer_, nrow = dim[1L], ncol = dim[2L]) 897s > y <- t(x) 897s > idxs_by_cols <- seq_along(x) 897s > 897s > # Assign by columns 897s > x[idxs_by_cols] <- idxs_by_cols 897s > print(x) 897s [,1] [,2] [,3] [,4] 897s [1,] 1 6 11 16 897s [2,] 2 7 12 17 897s [3,] 3 8 13 18 897s [4,] 4 9 14 19 897s [5,] 5 10 15 20 897s > 897s > # Truth 897s > y0 <- t(x) 897s > idxs_by_rows <- as.vector(y0) 897s > 897s > # Assert 897s > idxs <- indexByRow(dim) 897s > stopifnot(all.equal(idxs, idxs_by_rows)) 897s > y <- x 897s > y[idxs_by_rows] <- idxs 897s > print(y) 897s [,1] [,2] [,3] [,4] 897s [1,] 1 6 11 16 897s [2,] 2 7 12 17 897s [3,] 3 8 13 18 897s [4,] 4 9 14 19 897s [5,] 5 10 15 20 897s > stopifnot(all(as.vector(y) == as.vector(x))) 897s > 897s > idxs_R1 <- indexByRow_R1(dim) 897s > stopifnot(all.equal(idxs_R1, idxs_by_rows)) 897s > 897s > idxs_R2 <- indexByRow_R2(dim) 897s > stopifnot(all.equal(idxs_R2, idxs_by_rows)) 897s > 897s > # Assert 897s > idxs_by_cols <- seq(from = 1, to = length(x), by = 3L) 897s > idxs_by_rows <- as.vector(t(x)[idxs_by_cols]) 897s > 897s > idxs <- indexByRow(dim, idxs = idxs_by_cols) 897s > stopifnot(all(idxs == idxs_by_rows)) 897s > 897s > idxs_R1 <- indexByRow_R1(dim, idxs = idxs_by_cols) 897s > stopifnot(all(idxs_R1 == idxs_by_rows)) 897s > 897s > idxs_R2 <- indexByRow_R2(dim, idxs = idxs_by_cols) 897s > stopifnot(all(idxs_R2 == idxs_by_rows)) 897s > 897s > 897s > ## DEFUNCT: Backward compatibility 897s > res <- tryCatch({ 897s + idxs1 <- indexByRow(x) 897s + }, error = identity) 897s > stopifnot(inherits(res, "error")) 897s > 897s > 897s > ## Exceptions: 897s > ## Too large matrices are not supported, which happens 897s > ## when prod(dim) > .Machine$integer.max 897s > dim_too_large <- c(.Machine$integer.max, 2L) 897s > res <- tryCatch({ 897s + idxs <- indexByRow(dim_too_large, idxs = 1L) 897s + }, error = identity) 897s > stopifnot(inherits(res, "error")) 897s > 897s > ## Non-positive indices are not supported 897s > res <- tryCatch({ 897s + idxs <- indexByRow(c(1,1), idxs = 0L) 897s + }, error = identity) 897s > stopifnot(inherits(res, "error")) 897s > 897s > res <- tryCatch({ 897s + idxs <- indexByRow(c(1,1), idxs = -1L) 897s + }, error = identity) 897s > stopifnot(inherits(res, "error")) 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > library("stats") 897s > 897s > logSumExp_R <- function(lx, na.rm = FALSE) { 897s + log(sum(exp(lx), na.rm = na.rm)) 897s + } 897s > 897s > ## R-help thread \emph{'[R] Beyond double-precision?'} on May 9, 2009. 897s > 897s > for (mode in c("integer", "double")) { 897s + cat("mode: ", mode, "\n", sep = "") 897s + 897s + set.seed(1) 897s + x <- runif(20, min = 1.0, max = 3.0) 897s + storage.mode(x) <- mode 897s + str(x) 897s + 897s + ## The logarithm of the harmonic mean 897s + y0 <- log(1 / mean(1 / x)) 897s + print(y0) ## -1.600885 897s + 897s + lx <- log(x) 897s + y1 <- log(length(x)) - logSumExp(-lx) 897s + print(y1) ## [1] -1.600885 897s + 897s + # Sanity check 897s + stopifnot(all.equal(y1, y0)) 897s + 897s + y2 <- log(length(x)) - logSumExp_R(-lx) 897s + # Sanity check 897s + stopifnot(all.equal(y2, y0)) 897s + } # for (mode ...) 897s mode: integer 897s int [1:20] 1 1 2 2 1 2 2 2 2 1 ... 897s [1] 0.3215836 897s [1] 0.3215836 897s mode: double 897s num [1:20] 1.53 1.74 2.15 2.82 1.4 ... 897s [1] 0.6673156 897s [1] 0.6673156 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Missing values 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > ## NA values 897s > lx <- c(1, 2, 3) 897s > lx[2] <- NA_real_ 897s > y0 <- logSumExp_R(lx, na.rm = FALSE) 897s > y <- logSumExp(lx, na.rm = FALSE) 897s > print(y) 897s [1] NA 897s > stopifnot(identical(y, NA_real_)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > y0 <- logSumExp_R(lx, na.rm = TRUE) 897s > y <- logSumExp(lx, na.rm = TRUE) 897s > print(y) 897s [1] 3.126928 897s > stopifnot(all.equal(y, y0)) 897s > 897s > ## NaN values 897s > lx <- c(1, 2, 3) 897s > lx[2] <- NaN 897s > y0 <- logSumExp_R(lx, na.rm = FALSE) 897s > y <- logSumExp(lx, na.rm = FALSE) 897s > print(y) 897s [1] NA 897s > stopifnot(identical(y, NA_real_)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > y0 <- logSumExp_R(lx, na.rm = TRUE) 897s > y <- logSumExp(lx, na.rm = TRUE) 897s > print(y) 897s [1] 3.126928 897s > stopifnot(all.equal(y, y0)) 897s > 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Corner cases 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > ## Zero-length vectors 897s > lx <- numeric(0L) 897s > y0 <- logSumExp_R(lx) 897s > y <- logSumExp(lx) 897s > print(y) 897s [1] -Inf 897s > stopifnot(identical(y, -Inf)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > ## Vectors of length one 897s > lx <- 1.0 897s > y0 <- logSumExp_R(lx) 897s > y <- logSumExp(lx) 897s > print(y) 897s [1] 1 897s > stopifnot(identical(y, lx)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > lx <- NA_real_ 897s > y0 <- logSumExp_R(lx, na.rm = TRUE) 897s > y <- logSumExp(lx, na.rm = TRUE) 897s > print(y) 897s [1] -Inf 897s > stopifnot(identical(y, -Inf)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > ## All missing values 897s > lx <- c(NA_real_, NA_real_) 897s > y0 <- logSumExp_R(lx, na.rm = TRUE) 897s > y <- logSumExp(lx, na.rm = TRUE) 897s > print(y) 897s [1] -Inf 897s > stopifnot(identical(y, -Inf)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > lx <- c(NA_real_, NA_real_) 897s > y0 <- logSumExp_R(lx, na.rm = FALSE) 897s > y <- logSumExp(lx, na.rm = FALSE) 897s > print(y) 897s [1] NA 897s > stopifnot(identical(y, NA_real_)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > 897s > ## +Inf values 897s > lx <- c(1, 2, +Inf) 897s > y0 <- logSumExp_R(lx) 897s > y <- logSumExp(lx) 897s > print(y) 897s [1] Inf 897s > stopifnot(identical(y, +Inf)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > ## First element is a missing value, cf. PR #33 897s > lx <- c(NA_real_, 1) 897s > y0 <- logSumExp_R(lx) 897s > print(y0) 897s [1] NA 897s > y <- logSumExp(lx, na.rm = FALSE) 897s > print(y) 897s [1] NA 897s > stopifnot(identical(y, NA_real_)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > y0 <- logSumExp_R(lx, na.rm = TRUE) 897s > print(y0) 897s [1] 1 897s > y <- logSumExp(lx, na.rm = TRUE) 897s > print(y) 897s [1] 1 897s > stopifnot(identical(y, 1)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > ## Multiple -Inf values, cf. issue #84 897s > lx <- c(-Inf, -Inf) 897s > y0 <- logSumExp_R(lx) 897s > y <- logSumExp(lx) 897s > print(y) 897s [1] -Inf 897s > stopifnot(identical(y, -Inf)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s > lx <- c(-Inf, 5, -Inf) 897s > y0 <- logSumExp_R(lx) 897s > y <- logSumExp(lx) 897s > print(y) 897s [1] 5 897s > stopifnot(identical(y, 5)) 897s > stopifnot(all.equal(y, y0)) 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > logSumExp_R <- function(lx, na.rm = FALSE) { 897s + log(sum(exp(lx), na.rm = na.rm)) 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > x <- runif(6, min = -6, max = 6) 897s > for (idxs in index_cases) { 897s + validateIndicesTestVector(x, idxs, 897s + ftest = logSumExp, fsure = logSumExp_R, 897s + na.rm = FALSE) 897s + validateIndicesTestVector(x, idxs, 897s + ftest = logSumExp, fsure = logSumExp_R, 897s + na.rm = TRUE) 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Consistency checks 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > set.seed(1) 897s > 897s > mean2_R <- function(x, na.rm = FALSE, idxs = NULL) { 897s + if (is.null(idxs)) { 897s + mean(x, na.rm = na.rm) 897s + } else { 897s + mean(x[idxs], na.rm = na.rm) 897s + } 897s + } # mean2_R() 897s > 897s > 897s > cat("Consistency checks:\n") 897s Consistency checks: 897s > for (kk in 1:20) { 897s + cat("Random test #", kk, "\n", sep = "") 897s + 897s + # Simulate data in a matrix of any shape 897s + n <- sample(100L, size = 1L) 897s + x <- rnorm(n, sd = 100) 897s + 897s + # Add NAs? 897s + if ((kk %% 4) %in% c(3, 0)) { 897s + cat("Adding NAs\n") 897s + nna <- sample(n, size = 1L) 897s + na_values <- c(NA_real_, NaN) 897s + t <- sample(na_values, size = nna, replace = TRUE) 897s + x[sample(length(x), size = nna)] <- t 897s + } 897s + 897s + # Integer or double? 897s + if ((kk %% 4) %in% c(2, 0)) { 897s + cat("Coercing to integers\n") 897s + storage.mode(x) <- "integer" 897s + } 897s + 897s + na.rm <- sample(c(TRUE, FALSE), size = 1L) 897s + 897s + # Sum over all 897s + y0 <- mean2_R(x, na.rm = na.rm) 897s + y1 <- mean2(x, na.rm = na.rm) 897s + stopifnot(all.equal(y1, y0)) 897s + 897s + # Sum over subset 897s + nidxs <- sample(n, size = 1L) 897s + idxs <- sample(n, size = nidxs) 897s + y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs) 897s + y1 <- mean2(x, na.rm = na.rm, idxs = idxs) 897s + stopifnot(all.equal(y1, y0)) 897s + 897s + if (storage.mode(x) == "integer") { 897s + storage.mode(x) <- "logical" 897s + 897s + y0 <- mean2_R(x, na.rm = na.rm) 897s + y1 <- mean2(x, na.rm = na.rm) 897s + stopifnot(all.equal(y1, y0)) 897s + 897s + y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs) 897s + y1 <- mean2(x, na.rm = na.rm, idxs = idxs) 897s + stopifnot(all.equal(y1, y0)) 897s + } 897s + } # for (kk ...) 897s Random test #1 897s Random test #2 897s Coercing to integers 897s Random test #3 897s Adding NAs 897s Random test #4 897s Adding NAs 897s Coercing to integers 897s Random test #5 897s Random test #6 897s Coercing to integers 897s Random test #7 897s Adding NAs 897s Random test #8 897s Adding NAs 897s Coercing to integers 897s Random test #9 897s Random test #10 897s Coercing to integers 897s Random test #11 897s Adding NAs 897s Random test #12 897s Adding NAs 897s Coercing to integers 897s Random test #13 897s Random test #14 897s Coercing to integers 897s Random test #15 897s Adding NAs 897s Random test #16 897s Adding NAs 897s Coercing to integers 897s Random test #17 897s Random test #18 897s Coercing to integers 897s Random test #19 897s Adding NAs 897s Random test #20 897s Adding NAs 897s Coercing to integers 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Special cases 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > for (na.rm in c(FALSE, TRUE)) { 897s + # Averaging over zero elements (integers) 897s + x <- integer(0) 897s + s1 <- mean(x, na.rm = na.rm) 897s + s2 <- mean2(x, na.rm = na.rm) 897s + stopifnot(identical(s1, s2)) 897s + 897s + x <- 1:5 897s + idxs <- integer(0) 897s + s1 <- mean(x[idxs], na.rm = na.rm) 897s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 897s + stopifnot(identical(s1, s2)) 897s + 897s + # Averaging over NA_integer_:s 897s + x <- rep(NA_integer_, times = 5L) 897s + s1 <- mean(x, na.rm = na.rm) 897s + s2 <- mean2(x, na.rm = na.rm) 897s + stopifnot(identical(s1, s2)) 897s + 897s + x <- rep(NA_integer_, times = 5L) 897s + idxs <- 1:3 897s + s1 <- mean(x[idxs], na.rm = na.rm) 897s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 897s + stopifnot(identical(s1, s2)) 897s + 897s + 897s + # Averaging over zero elements (doubles) 897s + x <- double(0) 897s + s1 <- mean(x) 897s + s2 <- mean2(x) 897s + stopifnot(identical(s1, s2)) 897s + 897s + x <- as.double(1:10) 897s + idxs <- integer(0) 897s + s1 <- mean(x[idxs]) 897s + s2 <- mean2(x, idxs = idxs) 897s + stopifnot(identical(s1, s2)) 897s + 897s + # Averaging over NA_real_:s 897s + x <- rep(NA_real_, times = 5L) 897s + s1 <- mean(x, na.rm = na.rm) 897s + s2 <- mean2(x, na.rm = na.rm) 897s + stopifnot(identical(s1, s2)) 897s + 897s + x <- rep(NA_real_, times = 5L) 897s + idxs <- 1:3 897s + s1 <- mean(x[idxs], na.rm = na.rm) 897s + s2 <- mean2(x, idxs = idxs, na.rm = na.rm) 897s + stopifnot(identical(s1, s2)) 897s + 897s + # Averaging over -Inf:s 897s + x <- rep(-Inf, times = 3L) 897s + s1 <- mean(x, na.rm = na.rm) 897s + s2 <- mean2(x, na.rm = na.rm) 897s + stopifnot(identical(s1, s2)) 897s + 897s + # Averaging over +Inf:s 897s + x <- rep(+Inf, times = 3L) 897s + s1 <- mean(x, na.rm = na.rm) 897s + s2 <- mean2(x, na.rm = na.rm) 897s + stopifnot(identical(s1, s2)) 897s + 897s + # Averaging over mix of -Inf:s and +Inf:s 897s + x <- rep(c(-Inf, +Inf), times = 3L) 897s + s1 <- mean(x, na.rm = na.rm) 897s + s2 <- mean2(x, na.rm = na.rm) 897s + stopifnot(identical(s1, s2)) 897s + 897s + # Averaging over mix of -Inf:s and +Inf:s and numerics 897s + x <- rep(c(-Inf, +Inf, 3.14), times = 2L) 897s + s1 <- mean(x, na.rm = na.rm) 897s + s2 <- mean2(x, na.rm = na.rm) 897s + stopifnot(identical(s1, s2)) 897s + 897s + # Averaging over mix of NaN, NA, +Inf, and numerics 897s + x <- c(NaN, NA, +Inf, 3.14) 897s + s1 <- mean(x, na.rm = na.rm) 897s + s2 <- mean2(x, na.rm = na.rm) 897s + if (na.rm) { 897s + stopifnot(identical(s2, s1)) 897s + } else { 897s + stopifnot(is.na(s1), is.na(s2)) 897s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 897s + ## returned here (as one would expect). NaN might very well be returned, 897s + ## when both NA and NaN are involved. This is an accepted feature in R, 897s + ## which is documented in help("is.nan"). See also 897s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 897s + ## Thus, we cannot guarantee that s1 is identical to s0. 897s + } 897s + 897s + # Averaging over mix of NaN, NA_real_, +Inf, and numerics 897s + x <- c(NA_real_, NaN, +Inf, 3.14) 897s + s1 <- mean(x, na.rm = na.rm) 897s + s2 <- mean2(x, na.rm = na.rm) 897s + if (na.rm) { 897s + stopifnot(identical(s2, s1)) 897s + } else { 897s + stopifnot(is.na(s1), is.na(s2)) 897s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 897s + ## returned here (as one would expect). NaN might very well be returned, 897s + ## when both NA and NaN are involved. This is an accepted feature in R, 897s + ## which is documented in help("is.nan"). See also 897s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 897s + ## Thus, we cannot guarantee that s1 is identical to s0. 897s + } 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Argument 'idxs' 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- 1:5 897s > idxs_list <- list( 897s + integer = 1:3, 897s + double = as.double(1:3), 897s + logical = (x <= 3) 897s + ) 897s > 897s > for (idxs in idxs_list) { 897s + cat("idxs:\n") 897s + str(idxs) 897s + s1 <- mean(x[idxs], na.rm = TRUE) 897s + s2 <- mean2(x, idxs = idxs, na.rm = TRUE) 897s + stopifnot(identical(s1, s2)) 897s + } 897s idxs: 897s int [1:3] 1 2 3 897s idxs: 897s num [1:3] 1 2 3 897s idxs: 897s logi [1:5] TRUE TRUE TRUE FALSE FALSE 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > x <- runif(6, min = -6, max = 6) 897s > storage.mode(x) <- "integer" 897s > for (idxs in index_cases) { 897s + validateIndicesTestVector(x, idxs, 897s + ftest = mean2, fsure = mean, 897s + na.rm = FALSE) 897s + validateIndicesTestVector(x, idxs, 897s + ftest = mean2, fsure = mean, 897s + na.rm = TRUE) 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > for (mode in c("integer", "double")) { 897s + cat("mode: ", mode, "\n", sep = "") 897s + 897s + # Empty vector 897s + x <- 0 897s + storage.mode(x) <- mode 897s + y <- prod(x, na.rm = TRUE) 897s + print(y) 897s + z <- product(x, na.rm = TRUE) 897s + print(z) 897s + stopifnot(all.equal(z, y)) 897s + 897s + # Test negative values 897s + x <- c(1, -4, 2) 897s + storage.mode(x) <- mode 897s + y <- prod(x, na.rm = TRUE) 897s + print(y) 897s + z <- product(x, na.rm = TRUE) 897s + print(z) 897s + stopifnot(all.equal(z, y)) 897s + 897s + # Test missing values 897s + x <- c(1, NA, NaN, 2) 897s + storage.mode(x) <- mode 897s + y <- prod(x, na.rm = TRUE) 897s + print(y) 897s + z <- product(x, na.rm = TRUE) 897s + print(z) 897s + stopifnot(all.equal(z, y)) 897s + 897s + x <- c(1, NA, NaN, 2) 897s + storage.mode(x) <- mode 897s + y <- prod(x, na.rm = FALSE) 897s + print(y) 897s + z <- product(x, na.rm = FALSE) 897s + print(z) 897s + stopifnot(all(is.na(z), is.na(y))) 897s + 897s + x <- c(1, NaN, 2) 897s + storage.mode(x) <- mode 897s + y <- prod(x, na.rm = FALSE) 897s + print(y) 897s + stopifnot(is.na(y)) 897s + z <- product(x, na.rm = FALSE) 897s + print(z) 897s + stopifnot(is.na(z)) 897s + 897s + } # for (mode ...) 897s mode: integer 897s [1] 0 897s [1] 0 897s [1] -8 897s [1] -8 897s [1] 2 897s [1] 2 897s [1] NA 897s [1] NA 897s [1] NA 897s [1] NA 897s mode: double 897s [1] 0 897s [1] 0 897s [1] -8 897s [1] -8 897s [1] 2 897s [1] 2 897s [1] NA 897s [1] NA 897s [1] NaN 897s [1] NA 897s > 897s > 897s > # NAs following 0s 897s > x <- c(0L, NA_integer_) 897s > y <- prod(x, na.rm = FALSE) 897s > print(y) 897s [1] NA 897s > z <- product(x, na.rm = FALSE) 897s > print(z) 897s [1] NA 897s > stopifnot(identical(z, y)) 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > x <- runif(6, min = -6, max = 6) 897s > storage.mode(x) <- "integer" 897s > for (idxs in index_cases) { 897s + validateIndicesTestVector(x, idxs, 897s + ftest = product, fsure = prod, 897s + na.rm = TRUE) 897s + validateIndicesTestVector(x, idxs, 897s + ftest = product, fsure = prod, 897s + na.rm = FALSE) 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > library("utils") ## utils::str 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Local functions 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > psortKM_R <- function(x, k, m) { 897s + x <- sort(x) 897s + x[(k - m + 1):k] 897s + } 897s > 897s > psortKM_R2 <- function(x, k, m) { 897s + partial <- (k - m + 1):k 897s + x <- sort.int(x, partial = partial) 897s + x[partial] 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Consistency checks 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > set.seed(1) 897s > 897s > cat("Consistency checks:\n") 897s Consistency checks: 897s > x <- 1:30 897s > x[18:20] <- 20 897s > y <- sample(x) 897s > cat("x:\n") 897s x: 897s > str(x) 897s num [1:30] 1 2 3 4 5 6 7 8 9 10 ... 897s > cat("sample(x):\n") 897s sample(x): 897s > str(y) 897s num [1:30] 25 4 7 1 2 23 11 14 20 20 ... 897s > 897s > for (k in c(1L, 2L, 20L, 21L, length(x))) { 897s + for (m in 1:min(5L, k)) { 897s + px0 <- psortKM_R(x, k = k, m = m) 897s + px0b <- psortKM_R2(x, k = k, m = m) 897s + stopifnot(identical(px0b, px0)) 897s + px1 <- matrixStats:::.psortKM(x, k = k, m = m) 897s + cat(sprintf(".psortKM(x, k = %d, m = %d):\n", k, m)) 897s + print(px1) 897s + stopifnot(identical(px1, px0)) 897s + 897s + py0 <- psortKM_R(y, k = k, m = m) 897s + py0b <- psortKM_R2(y, k = k, m = m) 897s + stopifnot(identical(py0b, py0)) 897s + py1 <- matrixStats:::.psortKM(y, k = k, m = m) 897s + cat(sprintf(".psortKM(y, k = %d, m = %d):\n", k, m)) 897s + print(py1) 897s + stopifnot(identical(py1, py0)) 897s + stopifnot(identical(py1, px1)) 897s + } # for (m ...) 897s + } # for (k ...) 897s .psortKM(x, k = 1, m = 1): 897s [1] 1 897s .psortKM(y, k = 1, m = 1): 897s [1] 1 897s .psortKM(x, k = 2, m = 1): 897s [1] 2 897s .psortKM(y, k = 2, m = 1): 897s [1] 2 897s .psortKM(x, k = 2, m = 2): 897s [1] 1 2 897s .psortKM(y, k = 2, m = 2): 897s [1] 1 2 897s .psortKM(x, k = 20, m = 1): 897s [1] 20 897s .psortKM(y, k = 20, m = 1): 897s [1] 20 897s .psortKM(x, k = 20, m = 2): 897s [1] 20 20 897s .psortKM(y, k = 20, m = 2): 897s [1] 20 20 897s .psortKM(x, k = 20, m = 3): 897s [1] 20 20 20 897s .psortKM(y, k = 20, m = 3): 897s [1] 20 20 20 897s .psortKM(x, k = 20, m = 4): 897s [1] 17 20 20 20 897s .psortKM(y, k = 20, m = 4): 897s [1] 17 20 20 20 897s .psortKM(x, k = 20, m = 5): 897s [1] 16 17 20 20 20 897s .psortKM(y, k = 20, m = 5): 897s [1] 16 17 20 20 20 897s .psortKM(x, k = 21, m = 1): 897s [1] 21 897s .psortKM(y, k = 21, m = 1): 897s [1] 21 897s .psortKM(x, k = 21, m = 2): 897s [1] 20 21 897s .psortKM(y, k = 21, m = 2): 897s [1] 20 21 897s .psortKM(x, k = 21, m = 3): 897s [1] 20 20 21 897s .psortKM(y, k = 21, m = 3): 897s [1] 20 20 21 897s .psortKM(x, k = 21, m = 4): 897s [1] 20 20 20 21 897s .psortKM(y, k = 21, m = 4): 897s [1] 20 20 20 21 897s .psortKM(x, k = 21, m = 5): 897s [1] 17 20 20 20 21 897s .psortKM(y, k = 21, m = 5): 897s [1] 17 20 20 20 21 897s .psortKM(x, k = 30, m = 1): 897s [1] 30 897s .psortKM(y, k = 30, m = 1): 897s [1] 30 897s .psortKM(x, k = 30, m = 2): 897s [1] 29 30 897s .psortKM(y, k = 30, m = 2): 897s [1] 29 30 897s .psortKM(x, k = 30, m = 3): 897s [1] 28 29 30 897s .psortKM(y, k = 30, m = 3): 897s [1] 28 29 30 897s .psortKM(x, k = 30, m = 4): 897s [1] 27 28 29 30 897s .psortKM(y, k = 30, m = 4): 897s [1] 27 28 29 30 897s .psortKM(x, k = 30, m = 5): 897s [1] 26 27 28 29 30 897s .psortKM(y, k = 30, m = 5): 897s [1] 26 27 28 29 30 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) { 897s + if (is.na(value)) { 897s + res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm) 897s + } else { 897s + y <- x == value 897s + 897s + # Preserve dimnames attribute 897s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 897s + if (!isTRUE(all.equal(dim(y), dim))) { 897s + dim(y) <- dim 897s + dimnames(y) <- dimnames(x) 897s + } 897s + 897s + res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm) 897s + } 897s + if (is.na(useNames) || !useNames) names(res) <- NULL 897s + res 897s + } 897s > 897s > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) { 897s + if (is.na(value)) { 897s + res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm) 897s + } else { 897s + y <- x == value 897s + 897s + # Preserve dimnames attribute 897s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 897s + if (!isTRUE(all.equal(dim(y), dim))) { 897s + dim(y) <- dim 897s + dimnames(y) <- dimnames(x) 897s + } 897s + 897s + res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm) 897s + } 897s + if (is.na(useNames) || !useNames) names(res) <- NULL 897s + res 897s + } 897s > 897s > rowAnyMissings_R <- function(x, ..., useNames = NA) { 897s + res <- apply(x, MARGIN = 1L, FUN = anyMissing) 897s + if (is.na(useNames) || !useNames) names(res) <- NULL 897s + res 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Data type: logical 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- matrix(FALSE, nrow = 10L, ncol = 4L) 897s > x[7:8, 2:3] <- TRUE 897s > x[1:3, ] <- TRUE 897s > x[, 1] <- TRUE 897s > x[4, ] <- FALSE 897s > x[, 4] <- FALSE 897s > x[2, ] <- FALSE 897s > x[3, ] <- TRUE 897s > 897s > # To check names attribute 897s > dimnames <- list(letters[1:10], LETTERS[1:4]) 897s > 897s > for (kk in 1:3) { 897s + if (kk == 2) { 897s + x[2, 2] <- NA 897s + } else if (kk == 3) { 897s + x[, 2] <- NA 897s + x[2, ] <- NA 897s + } 897s + 897s + # Test with and without dimnames on x 897s + for (setDimnames in c(TRUE, FALSE)) { 897s + dimnames(x) <- if (setDimnames) dimnames else NULL 897s + 897s + for (na.rm in c(FALSE, TRUE)) { 897s + # Check names attribute 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + m0 <- rowAlls_R(x, na.rm = na.rm, useNames = useNames) 897s + m1 <- rowAlls(x, na.rm = na.rm, useNames = useNames) 897s + m2 <- colAlls(t(x), na.rm = na.rm, useNames = useNames) 897s + str(list("all()", m0 = m0, m1 = m1, m2 = m2)) 897s + stopifnot(identical(m1, m0)) 897s + stopifnot(identical(m2, m0)) 897s + 897s + m0 <- rowAnys_R(x, na.rm = na.rm, useNames = useNames) 897s + m1 <- rowAnys(x, na.rm = na.rm, useNames = useNames) 897s + m2 <- colAnys(t(x), na.rm = na.rm, useNames = useNames) 897s + str(list("any()", m0 = m0, m1 = m1, m2 = m2)) 897s + stopifnot(identical(m1, m0)) 897s + stopifnot(identical(m2, m0)) 897s + 897s + m0 <- rowAnyMissings_R(x, useNames = useNames) 897s + m1 <- rowAnyMissings(x, useNames = useNames) 897s + m2 <- colAnyMissings(t(x), useNames = useNames) 897s + str(list("anyMissing()", m0 = m0, m1 = m1, m2 = m2)) 897s + stopifnot(identical(m1, m0)) 897s + stopifnot(identical(m2, m0)) 897s + } 897s + } 897s + } 897s + } # for (kk ...) 897s List of 4 897s $ : chr "all()" 897s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "any()" 897s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "any()" 897s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "any()" 897s $ m0: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "any()" 897s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "any()" 897s $ m0: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "any()" 897s $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s List of 4 897s $ : chr "all()" 897s $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ... 897s List of 4 897s $ : chr "any()" 897s $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ... 897s List of 4 897s $ : chr "anyMissing()" 897s $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ... 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Data type: integer 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- matrix(rep(1:6, length.out = 4 * 5), nrow = 4L, ncol = 5L) 897s > x[2, ] <- 7L 897s > x[3, 1] <- 7L 897s > x[2:3, 3:4] <- NA_integer_ 897s > 897s > # To check names attribute 897s > dimnames <- list(letters[1:4], LETTERS[1:5]) 897s > 897s > # Row/column counts 897s > value <- 7L 897s > 897s > # Test with and without dimnames on x 897s > for (setDimnames in c(TRUE, FALSE)) { 897s + dimnames(x) <- if (setDimnames) dimnames else NULL 897s + for (na.rm in c(FALSE, TRUE)) { 897s + # Check names attribute 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames) 897s + r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames) 897s + r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames) 897s + stopifnot(identical(r1, r0)) 897s + stopifnot(identical(r2, r1)) 897s + if (!is.na(useNames) && !useNames && !setDimnames) { 897s + for (rr in seq_len(nrow(x))) { 897s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 897s + stopifnot(identical(c, r1[rr])) 897s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 897s + stopifnot(identical(c, r1[rr])) 897s + } 897s + } 897s + 897s + r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames) 897s + r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames) 897s + r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames) 897s + stopifnot(identical(r1, r0)) 897s + stopifnot(identical(r2, r1)) 897s + if (!is.na(useNames) && !useNames && !setDimnames) { 897s + for (rr in seq_len(nrow(x))) { 897s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 897s + stopifnot(identical(c, r1[rr])) 897s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 897s + stopifnot(identical(c, r1[rr])) 897s + } 897s + } 897s + } 897s + } 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # rowAlls(x) et al. on numeric 'x' with logical 'value' 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- matrix(0, nrow = 4L, ncol = 5L) 897s > x[2:4, 2] <- (1:3) / 4 897s > x[2, 2:4] <- (1:3) / 4 897s > x[3:4, 3] <- (3:4) / 4 897s > x[3, 3:4] <- (3:4) / 4 897s > x[1:4, 5] <- (1:4) / 5 897s > x[4, 4] <- NA_real_ 897s > 897s > # To check names attribute 897s > dimnames <- list(letters[1:4], LETTERS[1:5]) 897s > 897s > for (value in c(TRUE, FALSE)) { 897s + for (na.rm in c(FALSE, TRUE)) { 897s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 897s + y <- rowAnys(x, na.rm = na.rm, value = value) 897s + stopifnot(identical(y, y0)) 897s + # Check names attribute 897s + dimnames(x) <- dimnames 897s + y <- rowAnys(x, na.rm = na.rm, value = value, useNames = FALSE) 897s + stopifnot(all.equal(y, y0)) 897s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 897s + y <- rowAnys(x, na.rm = na.rm, value = value, useNames = TRUE) 897s + stopifnot(all.equal(y, y0)) 897s + dimnames(x) <- NULL 897s + 897s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 897s + y <- colAnys(x, na.rm = na.rm, value = value) 897s + stopifnot(identical(y, y0)) 897s + # Check names attribute 897s + dimnames(x) <- dimnames 897s + y <- colAnys(x, na.rm = na.rm, value = value, useNames = FALSE) 897s + stopifnot(all.equal(y, y0)) 897s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm))) 897s + y <- colAnys(x, na.rm = na.rm, value = value, useNames = TRUE) 897s + stopifnot(all.equal(y, y0)) 897s + dimnames(x) <- NULL 897s + 897s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 897s + y <- rowAlls(x, na.rm = na.rm, value = value) 897s + stopifnot(identical(y, y0)) 897s + # Check names attribute 897s + dimnames(x) <- dimnames 897s + y <- rowAlls(x, na.rm = na.rm, value = value, useNames = FALSE) 897s + stopifnot(all.equal(y, y0)) 897s + y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 897s + y <- rowAlls(x, na.rm = na.rm, value = value, useNames = TRUE) 897s + stopifnot(all.equal(y, y0)) 897s + dimnames(x) <- NULL 897s + 897s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 897s + y <- colAlls(x, na.rm = na.rm, value = value) 897s + stopifnot(identical(y, y0)) 897s + print(y0) 897s + # Check names attribute 897s + dimnames(x) <- dimnames 897s + y <- colAlls(x, na.rm = na.rm, value = value, useNames = FALSE) 897s + stopifnot(all.equal(y, y0)) 897s + y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm))) 897s + y <- colAlls(x, na.rm = na.rm, value = value, useNames = TRUE) 897s + stopifnot(all.equal(y, y0)) 897s + dimnames(x) <- NULL 897s + } ## for (na.rm ...) 897s + } ## for(value ...) 897s [1] FALSE FALSE FALSE FALSE TRUE 897s [1] FALSE FALSE FALSE FALSE TRUE 897s [1] TRUE FALSE FALSE FALSE FALSE 897s [1] TRUE FALSE FALSE FALSE FALSE 897s > 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Data type: character (not sure if this should be supported) 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > all_R <- function(x, value = TRUE, ...) { 897s + if (is.na(value)) { 897s + all(is.na(x), ...) 897s + } else { 897s + all(x == value, ...) 897s + } 897s + } 897s > 897s > any_R <- function(x, value = TRUE, ...) { 897s + if (is.na(value)) { 897s + any(is.na(x), ...) 897s + } else { 897s + any(x == value, ...) 897s + } 897s + } 897s > 897s > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L) 897s > x[2, ] <- "g" 897s > x[2:4, 3:4] <- NA_character_ 897s > 897s > # To check names attribute 897s > dimnames <- list(letters[1:10], LETTERS[1:5]) 897s > 897s > # Test with and without dimnames on x 897s > for (setDimnames in c(TRUE, FALSE)) { 897s + dimnames(x) <- if (setDimnames) dimnames else NULL 897s + 897s + # Row/column counts 897s + for (value in c("g", NA_character_)) { 897s + for (na.rm in c(FALSE, TRUE)) { 897s + # Check names attribute 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames) 897s + r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames) 897s + r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames) 897s + stopifnot(identical(r1, r0)) 897s + stopifnot(identical(r2, r1)) 897s + if (!is.na(useNames) && !useNames && !setDimnames) { 897s + for (rr in seq_len(nrow(x))) { 897s + c0 <- all_R(x[rr, ], value, na.rm = na.rm) 897s + c <- allValue(x[rr, ], value = value, na.rm = na.rm) 897s + stopifnot(identical(c, r1[rr])) 897s + stopifnot(identical(c, c0)) 897s + } 897s + } 897s + 897s + r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames) 897s + r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames) 897s + r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames) 897s + stopifnot(identical(r1, r0)) 897s + stopifnot(identical(r2, r1)) 897s + if (!is.na(useNames) && !useNames && !setDimnames) { 897s + for (rr in seq_len(nrow(x))) { 897s + c0 <- any_R(x[rr, ], value, na.rm = na.rm) 897s + c <- anyValue(x[rr, ], value = value, na.rm = na.rm) 897s + stopifnot(identical(c, c0)) 897s + stopifnot(identical(c, r1[rr])) 897s + } 897s + } 897s + } 897s + } 897s + } 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # NA 0 test 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > x <- matrix(0, nrow = 3L, ncol = 3L) 897s > x[1, ] <- c(NA_real_, NA_real_, 0) 897s > x[3, ] <- c(1, 0, 1) 897s > 897s > dimnames <- list(letters[1:3], LETTERS[1:3]) 897s > 897s > # Test with and without dimnames on x 897s > for (setDimnames in c(TRUE, FALSE)) { 897s + dimnames(x) <- if (setDimnames) dimnames else NULL 897s + # Check names attribute 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + r0 <- rowAnys_R(x, value = 0, useNames = useNames) 897s + r1 <- rowAnys(x, value = 0, useNames = useNames) 897s + stopifnot(identical(r0, r1)) 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) { 897s + if (is.na(value)) { 897s + res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm) 897s + } else { 897s + y <- x == value 897s + 897s + # Preserve dimnames attribute 897s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 897s + if (!isTRUE(all.equal(dim(y), dim))) { 897s + dim(y) <- dim 897s + dimnames(y) <- dimnames(x) 897s + } 897s + 897s + res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm) 897s + } 897s + if (is.na(useNames) || !useNames) names(res) <- NULL 897s + res 897s + } 897s > 897s > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) { 897s + if (is.na(value)) { 897s + res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm) 897s + } else { 897s + y <- x == value 897s + 897s + # Preserve dimnames attribute 897s + dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0) 897s + if (!isTRUE(all.equal(dim(y), dim))) { 897s + dim(y) <- dim 897s + dimnames(y) <- dimnames(x) 897s + } 897s + 897s + res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm) 897s + } 897s + if (is.na(useNames) || !useNames) names(res) <- NULL 897s + res 897s + } 897s > 897s > rowAnyMissings_R <- function(x, ..., useNames = NA) { 897s + res <- apply(x, MARGIN = 1L, FUN = anyMissing) 897s + if (is.na(useNames) || !useNames) names(res) <- NULL 897s + res 897s + } 897s > 897s > 897s > all_R <- function(x, value = TRUE, ...) { 897s + if (is.na(value)) { 897s + all(is.na(x), ...) 897s + } else { 897s + all(x == value, ...) 897s + } 897s + } 897s > 897s > any_R <- function(x, value = TRUE, ...) { 897s + if (is.na(value)) { 897s + any(is.na(x), ...) 897s + } else { 897s + any(x == value, ...) 897s + } 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 897s > storage.mode(x) <- "integer" 897s > x[2:3, ] <- NA_integer_ 897s > x[2, 1] <- 0L 897s > x[4:5, ] <- 0L 897s > x[4, 6] <- NA_integer_ 897s > 897s > # To check names attribute 897s > dimnames <- list(letters[1:6], LETTERS[1:6]) 897s > 897s > # Test with and without dimnames on x 897s > for (setDimnames in c(TRUE, FALSE)) { 897s + if (setDimnames) dimnames(x) <- dimnames 897s + else dimnames(x) <- NULL 897s + 897s + count <- 0L 897s + for (rows in index_cases) { 897s + for (cols in index_cases) { 897s + count <- count + 1L 897s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 897s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 897s + useNames <- useNames[count %% length(useNames) + 1] 897s + 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAlls, fsure = rowAlls_R, 897s + value = 0, na.rm = TRUE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAlls, fsure = rowAlls_R, 897s + value = 0, na.rm = FALSE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAlls, fsure = rowAlls_R, 897s + value = NA_integer_, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAlls, fsure = rowAlls_R, 897s + value = 0, na.rm = TRUE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAlls, fsure = rowAlls_R, 897s + value = 0, na.rm = FALSE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAlls, fsure = rowAlls_R, 897s + value = NA_integer_, useNames = useNames) 897s + 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAnys, fsure = rowAnys_R, 897s + value = 0, na.rm = TRUE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAnys, fsure = rowAnys_R, 897s + value = 0, na.rm = FALSE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAnys, fsure = rowAnys_R, 897s + value = NA_integer_, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAnys, fsure = rowAnys_R, 897s + value = 0, na.rm = TRUE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAnys, fsure = rowAnys_R, 897s + value = 0, na.rm = FALSE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAnys, fsure = rowAnys_R, 897s + value = NA_integer_, useNames = useNames) 897s + 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAnyMissings, 897s + fsure = rowAnyMissings_R, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAnyMissings, 897s + fsure = rowAnyMissings_R, useNames = useNames) 897s + } 897s + } 897s + } 897s > 897s > for (rr in seq_len(nrow(x))) { 897s + for (idxs in index_cases) { 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = allValue, fsure = all_R, 897s + value = 0, na.rm = TRUE) 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = allValue, fsure = all_R, 897s + value = 0, na.rm = FALSE) 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = allValue, fsure = all_R, 897s + value = NA_integer_) 897s + 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = anyValue, fsure = any_R, 897s + value = 0, na.rm = TRUE) 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = anyValue, fsure = any_R, 897s + value = 0, na.rm = FALSE) 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = anyValue, fsure = any_R, 897s + value = NA_integer_) 897s + } 897s + } 897s > 897s > 897s > storage.mode(x) <- "character" 897s > # Test with and without dimnames on x 897s > for (setDimnames in c(TRUE, FALSE)) { 897s + if (setDimnames) dimnames(x) <- dimnames 897s + else dimnames(x) <- NULL 897s + for (rows in index_cases) { 897s + for (cols in index_cases) { 897s + # Check names attribute 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAlls, fsure = rowAlls_R, 897s + value = "0", na.rm = TRUE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAlls, fsure = rowAlls_R, 897s + value = "0", na.rm = FALSE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAlls, fsure = rowAlls_R, 897s + value = NA_character_, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAlls, fsure = rowAlls_R, 897s + value = "0", na.rm = TRUE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAlls, fsure = rowAlls_R, 897s + value = "0", na.rm = FALSE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAlls, fsure = rowAlls_R, 897s + value = NA_character_, useNames = useNames) 897s + 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAnys, fsure = rowAnys_R, 897s + value = "0", na.rm = TRUE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAnys, fsure = rowAnys_R, 897s + value = "0", na.rm = FALSE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAnys, fsure = rowAnys_R, 897s + value = NA_character_, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAnys, fsure = rowAnys_R, 897s + value = "0", na.rm = TRUE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAnys, fsure = rowAnys_R, 897s + value = "0", na.rm = FALSE, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAnys, fsure = rowAnys_R, 897s + value = NA_character_, useNames = useNames) 897s + 897s + validateIndicesTestMatrix(x, rows, cols, 897s + ftest = rowAnyMissings, 897s + fsure = rowAnyMissings_R, useNames = useNames) 897s + validateIndicesTestMatrix(x, rows, cols, 897s + fcoltest = colAnyMissings, 897s + fsure = rowAnyMissings_R, useNames = useNames) 897s + } 897s + } 897s + } 897s + } 897s > 897s > for (rr in seq_len(nrow(x))) { 897s + for (idxs in index_cases) { 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = allValue, fsure = all_R, 897s + value = "0", na.rm = TRUE) 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = allValue, fsure = all_R, 897s + value = "0", na.rm = FALSE) 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = allValue, fsure = all_R, 897s + value = NA_integer_) 897s + 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = anyValue, fsure = any_R, 897s + value = "0", na.rm = TRUE) 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = anyValue, fsure = any_R, 897s + value = "0", na.rm = FALSE) 897s + validateIndicesTestVector(x[rr, ], idxs, 897s + ftest = anyValue, fsure = any_R, 897s + value = NA_integer_) 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > X <- matrix(rnorm(20 * 6), nrow = 20, ncol = 6) 897s > rownames(X) <- LETTERS[1:nrow(X)] 897s > colnames(X) <- letters[1:ncol(X)] 897s > print(X) 897s a b c d e f 897s A 0.64080599 0.34088835 -1.15258083 1.1261186 0.75547291 -1.30244226 897s B -0.76293940 -0.80037023 0.72165292 -0.9726983 -0.37204764 -0.07419550 897s C 1.27355202 0.02768486 0.03754879 -0.1374387 -0.14282734 1.46340407 897s D -0.17021141 0.94754724 -1.50670020 -0.5175935 -1.19594934 -1.02453021 897s E -1.48840884 -0.16974331 -0.24948551 0.2934948 -0.40679101 0.11107064 897s F 1.96788928 0.17339816 0.25289177 -0.1400075 -0.44672315 -2.13113010 897s G -0.24835538 1.19070610 -1.25761210 -0.7949714 0.99923345 -0.60813322 897s H 1.21022210 -1.57514477 0.21017900 -0.3999402 0.54359422 -1.37819310 897s I 0.99432045 -0.42061766 -0.04454352 -0.2407413 -0.02671574 0.05726801 897s J 1.54595515 0.95935386 -1.26390605 -1.1671522 1.61994055 0.68106908 897s K -0.53489124 -1.26725449 0.03339206 1.0395414 -0.23544980 -0.52663245 897s L -0.87832546 -2.72713489 -0.76387478 0.6148285 1.53283121 1.01744867 897s M -0.98927872 1.11578741 1.16471579 2.4662591 0.98322733 0.37315408 897s N -0.79725044 0.26282398 1.87136520 1.0230805 -1.81434366 -0.21080128 897s O -0.38762440 -0.21432625 -0.35719718 -0.3840795 0.49145772 0.20885868 897s P 0.97813185 2.86320005 0.19691207 -2.7684829 1.07843219 -0.73379801 897s Q -0.65369571 -1.91225889 -1.14512622 -0.8509376 -2.98716926 -0.43314671 897s R 0.08804104 -0.66000603 -1.43401618 1.0324332 -0.16351248 0.51429313 897s S 0.06831507 0.29451096 0.06390813 1.2710324 0.17600802 0.95203389 897s T 1.33091175 0.44551322 -0.04213698 1.5940161 2.13469944 0.83672612 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Apply rowMeans() for 3 sets of 2 columns 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > nbr_of_sets <- 3L 897s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 897s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 897s > print(S) 897s s1 s2 s3 897s [1,] 1 3 5 897s [2,] 2 4 6 897s > 897s > Z <- rowAvgsPerColSet(X, S = S) 897s > print(Z) 897s s1 s2 s3 897s A 0.49084717 -0.01323112 -0.27348467 897s B -0.78165481 -0.12552270 -0.22312157 897s C 0.65061844 -0.04994496 0.66028837 897s D 0.38866792 -1.01214684 -1.11023978 897s E -0.82907607 0.02200463 -0.14786019 897s F 1.07064372 0.05644213 -1.28892663 897s G 0.47117536 -1.02629174 0.19555011 897s H -0.18246134 -0.09488061 -0.41729944 897s I 0.28685139 -0.14264239 0.01527613 897s J 1.25265451 -1.21552912 1.15050481 897s K -0.90107287 0.53646671 -0.38104112 897s L -1.80273017 -0.07452312 1.27513994 897s M 0.06325435 1.81548743 0.67819071 897s N -0.26721323 1.44722283 -1.01257247 897s O -0.30097532 -0.37063833 0.35015820 897s P 1.92066595 -1.28578541 0.17231709 897s Q -1.28297730 -0.99803191 -1.71015799 897s R -0.28598250 -0.20079151 0.17539033 897s S 0.18141302 0.66747028 0.56402095 897s T 0.88821248 0.77593957 1.48571278 897s > 897s > # Validation 897s > Z0 <- cbind(s1 = rowMeans(X[, 1:2]), s2 = rowMeans(X[, 3:4]), 897s + s3 = rowMeans(X[, 5:6])) 897s > stopifnot(identical(drop(Z), Z0)) 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Apply colMeans() for 5 sets of 4 rows 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > nbr_of_sets <- 5L 897s > S <- matrix(1:nrow(X), ncol = nbr_of_sets) 897s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 897s > print(S) 897s s1 s2 s3 s4 s5 897s [1,] 1 5 9 13 17 897s [2,] 2 6 10 14 18 897s [3,] 3 7 11 15 19 897s [4,] 4 8 12 16 20 897s > 897s > Z <- colAvgsPerRowSet(X, S = S) 897s > print(Z) 897s a b c d e f 897s s1 0.2453018 0.12893756 -0.4750198 -0.12540298 -0.2388379 -0.23444098 897s s2 0.3603368 -0.09519596 -0.2610067 -0.26035609 0.1723284 -1.00159645 897s s3 0.2817647 -0.86391330 -0.5097331 0.06161911 0.7226516 0.30728833 897s s4 -0.2990054 1.00687130 0.7189490 0.08419429 0.1846934 -0.09064663 897s s5 0.2083930 -0.45806018 -0.6393428 0.76163603 -0.2099936 0.46747660 897s > 897s > # Validation 897s > Z0 <- rbind(s1 = colMeans(X[1:4, ]), s2 = colMeans(X[5:8, ]), 897s + s3 = colMeans(X[9:12, ]), s4 = colMeans(X[13:16, ]), 897s + s5 = colMeans(X[17:20, ])) 897s > stopifnot(identical(drop(Z), Z0)) 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # When there is only one "complete" set 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > nbr_of_sets <- 1L 897s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 897s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 897s > print(S) 897s s1 897s [1,] 1 897s [2,] 2 897s [3,] 3 897s [4,] 4 897s [5,] 5 897s [6,] 6 897s > 897s > Z <- rowAvgsPerColSet(X, S = S, FUN = rowMeans) 897s > print(Z) 897s s1 897s A 0.06804379 897s B -0.37676636 897s C 0.42032062 897s D -0.57790623 897s E -0.31831054 897s F -0.05394693 897s G -0.11985542 897s H -0.23154713 897s I 0.05316171 897s J 0.39587673 897s K -0.24854909 897s L -0.20070445 897s M 0.85231083 897s N 0.05581238 897s O -0.10715182 897s P 0.26906588 897s Q -1.33038906 897s R -0.10379456 897s S 0.47096808 897s T 1.04995495 897s > 897s > Z0 <- rowMeans(X) 897s > stopifnot(identical(drop(Z), Z0)) 897s > 897s > 897s > nbr_of_sets <- 1L 897s > S <- matrix(1:nrow(X), ncol = nbr_of_sets) 897s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 897s > print(S) 897s s1 897s [1,] 1 897s [2,] 2 897s [3,] 3 897s [4,] 4 897s [5,] 5 897s [6,] 6 897s [7,] 7 897s [8,] 8 897s [9,] 9 897s [10,] 10 897s [11,] 11 897s [12,] 12 897s [13,] 13 897s [14,] 14 897s [15,] 15 897s [16,] 16 897s [17,] 17 897s [18,] 18 897s [19,] 19 897s [20,] 20 897s > 897s > Z <- colAvgsPerRowSet(X, S = S, FUN = colMeans) 897s > print(Z) 897s a b c d e f 897s s1 0.1593582 -0.05627212 -0.2332307 0.1043381 0.1261684 -0.1103838 897s > 897s > Z0 <- colMeans(X) 897s > stopifnot(identical(drop(Z), Z0)) 897s > 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Use weights 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > nbr_of_sets <- 3L 897s > S <- matrix(1:ncol(X), ncol = nbr_of_sets) 897s > colnames(S) <- sprintf("s%d", 1:nbr_of_sets) 897s > print(S) 897s s1 s2 s3 897s [1,] 1 3 5 897s [2,] 2 4 6 897s > 897s > W <- matrix(runif(length(X)), nrow = nrow(X), ncol = ncol(X)) 897s > Z1 <- rowAvgsPerColSet(X, W = W, S = S, FUN = rowWeightedMeans) 897s > print(Z1) 897s s1 s2 s3 897s A 0.49084717 -0.01323112 -0.27348467 897s B -0.78165481 -0.12552270 -0.22312157 897s C 0.65061844 -0.04994496 0.66028837 897s D 0.38866792 -1.01214684 -1.11023978 897s E -0.82907607 0.02200463 -0.14786019 897s F 1.07064372 0.05644213 -1.28892663 897s G 0.47117536 -1.02629174 0.19555011 897s H -0.18246134 -0.09488061 -0.41729944 897s I 0.28685139 -0.14264239 0.01527613 897s J 1.25265451 -1.21552912 1.15050481 897s K -0.90107287 0.53646671 -0.38104112 897s L -1.80273017 -0.07452312 1.27513994 897s M 0.06325435 1.81548743 0.67819071 897s N -0.26721323 1.44722283 -1.01257247 897s O -0.30097532 -0.37063833 0.35015820 897s P 1.92066595 -1.28578541 0.17231709 897s Q -1.28297730 -0.99803191 -1.71015799 897s R -0.28598250 -0.20079151 0.17539033 897s S 0.18141302 0.66747028 0.56402095 897s T 0.88821248 0.77593957 1.48571278 897s > Z2 <- colAvgsPerRowSet(X, W = W, S = S, FUN = colWeightedMeans) 897s > print(Z2) 897s a b c d e f 897s s1 -0.0610667 -0.229740940 -0.215463954 0.07671013 0.1917126 -0.6883189 897s s2 0.5516703 0.487616052 -0.734575706 -0.32751609 -0.6693883 0.2194369 897s s3 0.2397402 0.001827423 0.001703129 0.07674363 -0.4267571 -1.0100297 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Result should always be a matrix, including when nrow(X) <= 1 897s > # (https://github.com/HenrikBengtsson/matrixStats/issues/108) 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > X <- matrix(1:3, nrow = 1L, ncol = 3L) 897s > S <- matrix(1, nrow = 1L, ncol = 1L) 897s > Z1 <- rowAvgsPerColSet(X, S = S) 897s > stopifnot(is.matrix(Z1)) 897s > Z2 <- rowAvgsPerColSet(X, S = S, rows = 0) 897s > stopifnot(is.matrix(Z2)) 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Works with many, one or zero columns / rows 897s > # (https://github.com/HenrikBengtsson/matrixStats/issues/172) 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > S <- cbind(1:2, 3:4, 5:6) 897s > X <- matrix(rnorm(2 * 6), nrow = 6, ncol = 2) 897s > Z2 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 897s > Z2_ref <- rbind(colSums2(X[S[,1], ,drop=FALSE]), 897s + colSums2(X[S[,2], ,drop=FALSE]), 897s + colSums2(X[S[,3], ,drop=FALSE])) 897s > stopifnot(identical(Z2, Z2_ref)) 897s > X <- matrix(rnorm(6), nrow = 6, ncol = 1) 897s > Z1 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 897s > Z1_ref <- rbind(colSums2(X[S[,1], ,drop=FALSE]), 897s + colSums2(X[S[,2], ,drop=FALSE]), 897s + colSums2(X[S[,3], ,drop=FALSE])) 897s > stopifnot(identical(Z1, Z1_ref)) 897s > X <- matrix(numeric(0), nrow = 6, ncol = 0) 897s > Z0 <- colAvgsPerRowSet(X, S = S, FUN = colSums2) 897s > Z0_ref <- matrix(numeric(0), nrow = ncol(S), ncol = 0) 897s > stopifnot(identical(Z0, unname(Z0_ref))) 897s > 897s > 897s > S <- rbind(1:4, 5:8) 897s > X <- matrix(rnorm(n = 2 * 8), nrow = 2, ncol = 8) 897s > Z2 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 897s > Z2_ref <- cbind(rowMeans2(X[,S[,1],drop=FALSE]), 897s + rowMeans2(X[,S[,2],drop=FALSE]), 897s + rowMeans2(X[,S[,3],drop=FALSE]), 897s + rowMeans2(X[,S[,4],drop=FALSE])) 897s > stopifnot(identical(Z2, Z2_ref)) 897s > X <- matrix(rnorm(n = 8), nrow = 1, ncol = 8) 897s > Z1 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 897s > Z1_ref <- cbind(rowMeans2(X[,S[,1],drop=FALSE]), 897s + rowMeans2(X[,S[,2],drop=FALSE]), 897s + rowMeans2(X[,S[,3],drop=FALSE]), 897s + rowMeans2(X[,S[,4],drop=FALSE])) 897s > stopifnot(identical(Z1, Z1_ref)) 897s > X <- matrix(numeric(0), nrow = 0, ncol = 8) 897s > Z0 <- rowAvgsPerColSet(X, S = S, FUN = rowMeans2) 897s > Z0_ref <- matrix(numeric(0), nrow = 0, ncol = ncol(S)) 897s > stopifnot(identical(Z0, Z0_ref)) 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 897s > #W <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 897s > for (rows in index_cases) { 897s + for (cols in index_cases) { 897s + if (is.null(rows)) { 897s + rows <- seq_len(nrow(x)) 897s + rows_finite <- rows 897s + } else { 897s + rows_finite <- rows[is.finite(rows)] 897s + } 897s + 897s + if (is.null(cols)) { 897s + cols <- seq_len(ncol(x)) 897s + cols_finite <- cols 897s + } else { 897s + cols_finite <- cols[is.finite(cols)] 897s + } 897s + 897s + suppressWarnings({ 897s + actual <- tryCatch({ 897s + rowAvgsPerColSet(x, rows = rows, S = matrix(cols, ncol = 1), 897s + FUN = rowMeans) 897s + }, error = function(c) "error") 897s + expect <- tryCatch({ 897s + rowMeans(x[rows, cols_finite, drop = FALSE], na.rm = TRUE) 897s + }, error = function(c) "error") 897s + }) 897s + stopifnot(all.equal(as.vector(actual), expect)) 897s + 897s + suppressWarnings({ 897s + actual <- tryCatch({ 897s + colAvgsPerRowSet(x, cols = cols, S = matrix(rows, ncol = 1), 897s + FUN = colMeans) 897s + }, error = function(c) "error") 897s + expect <- tryCatch({ 897s + colMeans(x[rows_finite, cols, drop = FALSE], na.rm = TRUE) 897s + }, error = function(c) "error") 897s + }) 897s + stopifnot(all.equal(as.vector(actual), expect)) 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > x <- matrix(1:27, ncol = 3) 897s > 897s > # To check names attribute 897s > dimnames <- list(letters[1:9], LETTERS[1:3]) 897s > 897s > rowCollapse_R <- function(x, idxs, ..., useNames = NA) { 897s + res <- x[, idxs] 897s + # Preserve names attribute? 897s + if (is.na(useNames) || !useNames) names(res) <- NULL 897s + res 897s + } 897s > 897s > idxs <- 1L 897s > # Test with and without dimnames on x 897s > for (setDimnames in c(TRUE, FALSE)) { 897s + if (setDimnames) dimnames(x) <- dimnames 897s + else dimnames(x) <- NULL 897s + # Check names attribute 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 897s + y <- rowCollapse(x, idxs, useNames = useNames) 897s + stopifnot(identical(y, y_truth)) 897s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 897s + stopifnot(identical(y2, y)) 897s + } 897s + } 897s > 897s > idxs <- 2L 897s > # Test with and without dimnames on x 897s > for (setDimnames in c(TRUE, FALSE)) { 897s + if (setDimnames) dimnames(x) <- dimnames 897s + else dimnames(x) <- NULL 897s + # Check names attribute 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 897s + y <- rowCollapse(x, idxs, useNames = useNames) 897s + stopifnot(identical(y, y_truth)) 897s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 897s + stopifnot(identical(y2, y)) 897s + } 897s + } 897s > 897s > 897s > rowCollapse_R <- function(x, idxs, ..., useNames = NA) { 897s + res <- c(x[1:5, 1], x[6:9, 3]) 897s + # Preserve names attribute? 897s + if (is.na(useNames) || !useNames) names(res) <- NULL 897s + res 897s + } 897s > 897s > idxs <- c(1, 1, 1, 1, 1, 3, 3, 3, 3) 897s > # Test with and without dimnames on x 897s > for (setDimnames in c(TRUE, FALSE)) { 897s + if (setDimnames) dimnames(x) <- dimnames 897s + else dimnames(x) <- NULL 897s + # Check names attribute 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 897s + y <- rowCollapse(x, idxs, useNames = useNames) 897s + stopifnot(identical(y, y_truth)) 897s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 897s + stopifnot(identical(y2, y)) 897s + } 897s + } 897s > 897s > 897s > rowCollapse_R <- function(x, idxs, ..., useNames = NA) { 897s + res <- c(x[1, 1], x[2, 2], x[3, 3], x[4, 1], x[5, 2], 897s + x[6, 3], x[7, 1], x[8, 2], x[9, 3]) 897s + # Preserve names attribute? 897s + if (isTRUE(useNames)) { 897s + names <- rownames(x) 897s + if (!is.null(names)) names(res) <- names 897s + } 897s + res 897s + } 897s > 897s > idxs <- 1:3 897s > # Test with and without dimnames on x 897s > for (setDimnames in c(TRUE, FALSE)) { 897s + if (setDimnames) dimnames(x) <- dimnames 897s + else dimnames(x) <- NULL 897s + # Check names attribute 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + y_truth <- rowCollapse_R(x, idxs, useNames = useNames) 897s + y <- rowCollapse(x, idxs, useNames = useNames) 897s + stopifnot(identical(y, y_truth)) 897s + y2 <- colCollapse(t(x), idxs, useNames = useNames) 897s + stopifnot(identical(y2, y)) 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > rowCollapse_R <- function(x, idxs, ..., useNames = NA) { 897s + ans <- c() 897s + storage.mode(ans) <- storage.mode(x) 897s + for (ii in seq_len(length(idxs))) { 897s + ans[ii] <- x[ii, idxs[ii]] 897s + } 897s + 897s + # Preserve names attribute 897s + if (isTRUE(useNames)) { 897s + names <- rownames(x) 897s + if (!is.null(names)) names(ans) <- names 897s + } 897s + 897s + ans 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Subsetted tests 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > source("utils/validateIndicesFramework.R") 897s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 897s > storage.mode(x) <- "integer" 897s > 897s > # To check names attribute 897s > dimnames <- list(letters[1:6], LETTERS[1:6]) 897s > 897s > for (rows in index_cases) { 897s + if (is.null(rows)) rows <- seq_len(nrow(x)) 897s + 897s + for (idxs in list(2L, seq_len(6L))) { 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + suppressWarnings({ 897s + actual <- tryCatch(rowCollapse(x, idxs, rows = rows, useNames = useNames), 897s + error = function(c) "error") 897s + expect <- tryCatch({ 897s + idxs_0 <- rep(idxs, length.out = nrow(x))[rows] 897s + rowCollapse_R(x[rows, , drop = FALSE], idxs_0, useNames = useNames) 897s + }, error = function(c) "error") 897s + }) 897s + stopifnot(all.equal(actual, expect)) 897s + 897s + suppressWarnings({ 897s + actual <- tryCatch(colCollapse(t(x), idxs, cols = rows, useNames = useNames), 897s + error = function(c) "error") 897s + }) 897s + stopifnot(all.equal(actual, expect)) 897s + 897s + # Check names attribute 897s + dimnames(x) <- dimnames 897s + suppressWarnings({ 897s + actual <- tryCatch(rowCollapse(x, idxs, rows = rows, useNames = useNames), 897s + error = function(c) "error") 897s + expect <- tryCatch({ 897s + idxs_0 <- rep(idxs, length.out = nrow(x))[rows] 897s + rowCollapse_R(x[rows, , drop = FALSE], idxs_0, useNames = useNames) 897s + }, error = function(c) "error") 897s + }) 897s + stopifnot(all.equal(actual, expect)) 897s + 897s + suppressWarnings({ 897s + actual <- tryCatch(colCollapse(t(x), idxs, cols = rows, useNames = useNames), 897s + error = function(c) "error") 897s + }) 897s + stopifnot(all.equal(actual, expect)) 897s + 897s + dimnames(x) <- NULL 897s + } 897s + } 897s + } 897s > 897s 897s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 897s Copyright (C) 2024 The R Foundation for Statistical Computing 897s Platform: s390x-ibm-linux-gnu 897s 897s R is free software and comes with ABSOLUTELY NO WARRANTY. 897s You are welcome to redistribute it under certain conditions. 897s Type 'license()' or 'licence()' for distribution details. 897s 897s R is a collaborative project with many contributors. 897s Type 'contributors()' for more information and 897s 'citation()' on how to cite R or R packages in publications. 897s 897s Type 'demo()' for some demos, 'help()' for on-line help, or 897s 'help.start()' for an HTML browser interface to help. 897s Type 'q()' to quit R. 897s 897s > library("matrixStats") 897s > 897s > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ...) { 897s + if (is.na(value)) { 897s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 897s + sum(is.na(x)) 897s + ) 897s + } else { 897s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 897s + sum(x == value, na.rm = na.rm) 897s + ) 897s + } 897s + # Preserve names attribute 897s + names <- names(counts) 897s + counts <- as.integer(counts) 897s + if (isTRUE(useNames) && !is.null(names)) names(counts) <- names 897s + counts 897s + } 897s > 897s > 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > # Data type: integer and numeric 897s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 897s > for (mode in c("integer", "double")) { 897s + x <- matrix(runif(10 * 5, min = -3, max = 3), nrow = 10L, ncol = 5L) 897s + x[sample.int(length(x), size = 7L)] <- 0 897s + storage.mode(x) <- mode 897s + 897s + dimnames = list(letters[1:10], LETTERS[1:5]) 897s + 897s + # Test with and without dimnames on x 897s + for (setDimnames in c(TRUE, FALSE)) { 897s + if (setDimnames) dimnames(x) <- dimnames 897s + else dimnames(x) <- NULL 897s + for (na.rm in c(FALSE, TRUE)) { 897s + # Check names attribute 897s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 897s + # Count zeros 897s + r0 <- rowCounts_R(x, value = 0, na.rm = na.rm, useNames = useNames) 897s + r1 <- rowCounts(x, value = 0, na.rm = na.rm, useNames = useNames) 897s + r2 <- colCounts(t(x), value = 0, na.rm = na.rm, useNames = useNames) 897s + stopifnot(identical(r1, r0)) 897s + stopifnot(identical(r2, r0)) 897s + 897s + # Count NAs 897s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 897s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 897s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 897s + stopifnot(identical(r1, r0)) 897s + stopifnot(identical(r2, r0)) 897s + 897s + if (mode == "integer") { 898s + ux <- unique(as.vector(x)) 898s + r0 <- r1 <- r2 <- integer(nrow(x)) 898s + for (value in ux) { 898s + r0 <- r0 + rowCounts_R(x, value = value, na.rm = na.rm, useNames = useNames) 898s + r1 <- r1 + rowCounts(x, value = value, na.rm = na.rm, useNames = useNames) 898s + r2 <- r2 + colCounts(t(x), value = value, na.rm = na.rm, useNames = useNames) 898s + stopifnot(identical(r1, r0)) 898s + stopifnot(identical(r2, r0)) 898s + } 898s + stopifnot(all(r0 == ncol(x))) 898s + } # if (mode == "integer") 898s + } # for (useNames ...) 898s + } # for (na.rm ...) 898s + } # for (setDimnames ...) 898s + } # for (mode ...) 898s > 898s > 898s > # All NAs 898s > na_list <- list(NA_integer_, NA_real_, NaN) 898s > for (na_value in na_list) { 898s + x <- matrix(na_value, nrow = 10L, ncol = 5L) 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (na.rm in c(FALSE, TRUE)) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames) 898s + r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames) 898s + r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames) 898s + stopifnot(identical(r1, r0)) 898s + stopifnot(identical(r2, r0)) 898s + 898s + # Count NAs 898s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 898s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 898s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 898s + stopifnot(all(r0 == ncol(x))) 898s + stopifnot(identical(r1, r0)) 898s + stopifnot(identical(r2, r0)) 898s + } 898s + } 898s + } 898s + } # for (na_value ...) 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Data type: logical 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > x <- matrix(FALSE, nrow = 10L, ncol = 4L) 898s > x[7:8, 2:3] <- TRUE 898s > x[1:3, ] <- TRUE 898s > x[, 1] <- TRUE 898s > x[4, ] <- FALSE 898s > x[, 4] <- FALSE 898s > x[2, ] <- FALSE 898s > x[3, ] <- TRUE 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:10], LETTERS[1:4]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Row/column counts 898s + for (na.rm in c(FALSE, TRUE)) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames) 898s + r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames) 898s + r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames) 898s + stopifnot(identical(r1, r0)) 898s + stopifnot(identical(r2, r0)) 898s + 898s + r_true <- rowCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames) 898s + r_false <- rowCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames) 898s + stopifnot(r_true + r_false == ncol(x)) 898s + 898s + c_true <- colCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames) 898s + c_false <- colCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames) 898s + stopifnot(c_true + c_false == nrow(x)) 898s + 898s + # Count NAs 898s + r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames) 898s + r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames) 898s + r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames) 898s + stopifnot(identical(r1, r0)) 898s + stopifnot(identical(r2, r0)) 898s + } 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Data type: character (not sure if this should be supported) 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L) 898s > x[2:3, 3:4] <- NA_character_ 898s > 898s > # Row/column counts 898s > for (na.rm in c(FALSE, TRUE)) { 898s + for (value in c("g", NA_character_)) { 898s + r0 <- rowCounts_R(x, value = value, na.rm = na.rm) 898s + r1 <- rowCounts(x, value = value, na.rm = na.rm) 898s + r2 <- colCounts(t(x), value = value, na.rm = na.rm) 898s + stopifnot(identical(r1, r0)) 898s + stopifnot(identical(r2, r0)) 898s + 898s + c <- count(x[1, ], value = value, na.rm = na.rm) 898s + stopifnot(identical(c, r1[1])) 898s + 898s + c <- count(x[2, ], value = value, na.rm = na.rm) 898s + stopifnot(identical(c, r1[2])) 898s + } 898s + } 898s > 898s > # NA row 898s > x <- matrix(0, nrow = 2L, ncol = 2L) 898s > x[1, ] <- NA_integer_ 898s > 898s > dimnames <- list(letters[1:2], LETTERS[1:2]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCounts(x, value = 0, useNames = useNames) 898s + r1 <- rowCounts_R(x, value = 0, useNames = useNames) 898s + stopifnot(identical(r0, r1)) 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) { 898s + if (is.na(value)) { 898s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 898s + sum(is.na(x)) 898s + ) 898s + } else { 898s + counts <- apply(x, MARGIN = 1L, FUN = function(x) 898s + sum(x == value, na.rm = na.rm) 898s + ) 898s + } 898s + # Preserve names attribute 898s + names <- names(counts) 898s + counts <- as.integer(counts) 898s + if (isTRUE(useNames) && !is.null(names)) names(counts) <- names 898s + counts 898s + } # rowCounts_R() 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 898s > x[2:3, 3:4] <- NA_real_ 898s > storage.mode(x) <- "integer" 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowCounts, fsure = rowCounts_R, 898s + value = 0, na.rm = TRUE, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colCounts, fsure = rowCounts_R, 898s + value = 0, na.rm = TRUE, useNames = useNames) 898s + for (value in c(0, NA_integer_)) { 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowCounts, fsure = rowCounts_R, 898s + value = value, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colCounts, fsure = rowCounts_R, 898s + value = value, useNames = useNames) 898s + } 898s + } 898s + } 898s + } 898s + } 898s > 898s > x <- matrix(rep(letters, length.out = 6 * 6), nrow = 6, ncol = 6) 898s > x[2:3, 3:4] <- NA_character_ 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + 898s + count <- 0L 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + count <- count + 1L 898s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 898s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 898s + useNames <- useNames[count %% length(useNames) + 1] 898s + 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowCounts, fsure = rowCounts_R, 898s + value = "g", na.rm = TRUE, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colCounts, fsure = rowCounts_R, 898s + value = "g", na.rm = TRUE, useNames = useNames) 898s + for (value in c("g", NA_character_)) { 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowCounts, fsure = rowCounts_R, 898s + value = value, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colCounts, fsure = rowCounts_R, 898s + value = value, useNames = useNames) 898s + } 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowCummins_R <- function(x, ..., useNames = NA) { 898s + suppressWarnings({ 898s + y <- t(apply(x, MARGIN = 1L, FUN = cummin)) 898s + }) 898s + 898s + # Preserve dimnames attribute? 898s + dim(y) <- dim(x) 898s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 898s + y 898s + } 898s > 898s > rowCummaxs_R <- function(x, ..., useNames = NA) { 898s + mode <- storage.mode(x) 898s + # Change mode because a bug is detected on cummax for integer in R-3.2.0 898s + storage.mode(x) <- "numeric" 898s + suppressWarnings({ 898s + y <- t(apply(x, MARGIN = 1L, FUN = cummax)) 898s + }) 898s + 898s + # Preserve dimnames attribute? 898s + dim(y) <- dim(x) 898s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 898s + 898s + y 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # With and without some NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + for (add_na in c(FALSE, TRUE)) { 898s + cat("add_na = ", add_na, "\n", sep = "") 898s + 898s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 898s + diag(x) <- 0 898s + if (add_na) { 898s + x[3:7, c(2, 4)] <- NA_real_ 898s + } 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # To check dimnames attribute 898s + dimnames <- list(letters[1:10], LETTERS[1:5]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + # Row/column ranges 898s + r0 <- rowCummins_R(x, useNames = useNames) 898s + r1 <- rowCummins(x, useNames = useNames) 898s + r2 <- t(colCummins(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + 898s + r0 <- rowCummaxs_R(x, useNames = useNames) 898s + r1 <- rowCummaxs(x, useNames = useNames) 898s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (add_na ...) 898s + } # for (mode ...) 898s add_na = FALSE 898s mode: logical 898s logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ... 898s add_na = TRUE 898s mode: logical 898s logi [1:10, 1:5] FALSE TRUE TRUE TRUE TRUE TRUE ... 898s add_na = FALSE 898s mode: integer 898s int [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 898s add_na = TRUE 898s mode: integer 898s int [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 898s add_na = FALSE 898s mode: double 898s num [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 898s add_na = TRUE 898s mode: double 898s num [1:10, 1:5] 0 2 3 4 5 6 7 8 9 10 ... 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # All NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCummins_R(x, useNames = useNames) 898s + r1 <- rowCummins(x, useNames = useNames) 898s + r2 <- t(colCummins(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + 898s + r0 <- rowCummaxs_R(x, useNames = useNames) 898s + r1 <- rowCummaxs(x, useNames = useNames) 898s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (mode ...) 898s mode: logical 898s logi [1:10, 1:5] NA NA NA NA NA NA ... 898s mode: integer 898s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 898s mode: double 898s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # A 1x1 matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + x <- matrix(0, nrow = 1L, ncol = 1L) 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # To check dimnames attribute 898s + dimnames <- list("a", "A") 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCummins_R(x, useNames = useNames) 898s + r1 <- rowCummins(x, useNames = useNames) 898s + r2 <- t(colCummins(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + 898s + r0 <- rowCummaxs_R(x, useNames = useNames) 898s + r1 <- rowCummaxs(x, useNames = useNames) 898s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (mode ...) 898s mode: logical 898s logi [1, 1] FALSE 898s mode: integer 898s int [1, 1] 0 898s mode: double 898s num [1, 1] 0 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Corner cases 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + value <- 0 898s + storage.mode(value) <- mode 898s + value0 <- if (mode == "logical") 0L else value 898s + 898s + # A 0x0 matrix 898s + x <- matrix(value, nrow = 0L, ncol = 0L) 898s + str(x) 898s + r0 <- matrix(value0, nrow = nrow(x), ncol = ncol(x)) 898s + r1 <- rowCummins(x) 898s + r2 <- t(colCummins(t(x))) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + 898s + # A 0xK matrix 898s + x <- matrix(value, nrow = 0L, ncol = 5L) 898s + str(x) 898s + colnames <- LETTERS[1:5] 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) colnames(x) <- colnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCummins_R(x, useNames = useNames) 898s + r1 <- rowCummins(x, useNames = useNames) 898s + r2 <- t(colCummins(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + r0 <- rowCummaxs_R(x, useNames = useNames) 898s + r1 <- rowCummaxs(x, useNames = useNames) 898s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + 898s + # A Nx0 matrix 898s + x <- matrix(value, nrow = 5L, ncol = 0L) 898s + str(x) 898s + rownames <- LETTERS[1:5] 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) rownames(x) <- rownames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCummins_R(x, useNames = useNames) 898s + r1 <- rowCummins(x, useNames = useNames) 898s + r2 <- t(colCummins(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + 898s + r0 <- rowCummaxs_R(x, useNames = useNames) 898s + r1 <- rowCummaxs(x, useNames = useNames) 898s + r2 <- t(colCummaxs(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (mode ...) 898s mode: logical 898s logi[0 , 0 ] 898s logi[0 , 1:5] 898s logi[1:5, 0 ] 898s mode: integer 898s int[0 , 0 ] 898s int[0 , 1:5] 898s int[1:5, 0 ] 898s mode: double 898s num[0 , 0 ] 898s num[0 , 1:5] 898s num[1:5, 0 ] 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowCummins_R <- function(x, ..., useNames = NA) { 898s + suppressWarnings({ 898s + y <- t(apply(x, MARGIN = 1L, FUN = cummin)) 898s + }) 898s + 898s + # Preserve dimnames attribute? 898s + dim(y) <- dim(x) 898s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 898s + 898s + y 898s + } 898s > 898s > rowCummaxs_R <- function(x, ..., useNames = NA) { 898s + mode <- storage.mode(x) 898s + # Change mode because a bug is detected on cummax for integer in R-3.2.0 898s + storage.mode(x) <- "numeric" 898s + suppressWarnings({ 898s + y <- t(apply(x, MARGIN = 1L, FUN = cummax)) 898s + }) 898s + 898s + # Preserve dimnames attribute? 898s + dim(y) <- dim(x) 898s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 898s + 898s + storage.mode(y) <- mode 898s + y 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 898s > storage.mode(x) <- "integer" 898s > 898s > # To check dimnames attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowCummins, fsure = rowCummins_R, useNames = useNames,verbose=TRUE) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = function(x, rows, cols, ..., useNames) { 898s + t(colCummins(t(x), rows = cols, cols = rows, useNames = useNames)) 898s + }, fsure = rowCummins_R, useNames = useNames) 898s + 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowCummaxs, fsure = rowCummaxs_R, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = function(x, rows, cols, ..., useNames) { 898s + t(colCummaxs(t(x), rows = cols, cols = rows, useNames = useNames)) 898s + }, fsure = rowCummaxs_R, useNames = useNames) 898s + } 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowCumprods_R <- function(x, ..., useNames = NA) { 898s + suppressWarnings({ 898s + y <- t(apply(x, MARGIN = 1L, FUN = cumprod)) 898s + }) 898s + 898s + # Preserve dimnames attribute? 898s + dim(y) <- dim(x) 898s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 898s + 898s + y 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # With and without some NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + for (add_na in c(FALSE, TRUE)) { 898s + cat("add_na = ", add_na, "\n", sep = "") 898s + 898s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 898s + if (add_na) { 898s + x[3:7, c(2, 4)] <- NA_real_ 898s + } 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # To check dimnames attribute 898s + dimnames <- list(letters[1:10], LETTERS[1:5]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + # Row/column ranges 898s + r0 <- rowCumprods_R(x, useNames = useNames) 898s + r1 <- rowCumprods(x, useNames = useNames) 898s + r2 <- t(colCumprods(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (add_na ...) 898s + } # for (mode ...) 898s add_na = FALSE 898s mode: logical 898s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s add_na = TRUE 898s mode: logical 898s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s add_na = FALSE 898s mode: integer 898s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s add_na = TRUE 898s mode: integer 898s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s add_na = FALSE 898s mode: double 898s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s add_na = TRUE 898s mode: double 898s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # All NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + # Row/column ranges 898s + r0 <- rowCumprods_R(x, useNames = useNames) 898s + r1 <- rowCumprods(x, useNames = useNames) 898s + r2 <- t(colCumprods(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (mode ...) 898s mode: logical 898s logi [1:10, 1:5] NA NA NA NA NA NA ... 898s mode: integer 898s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 898s mode: double 898s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # A 1x1 matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + x <- matrix(0, nrow = 1L, ncol = 1L) 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + dimnames <- list("a", "A") 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + # Row/column ranges 898s + r0 <- rowCumprods_R(x, useNames = useNames) 898s + r1 <- rowCumprods(x, useNames = useNames) 898s + r2 <- t(colCumprods(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } 898s mode: logical 898s logi [1, 1] FALSE 898s mode: integer 898s int [1, 1] 0 898s mode: double 898s num [1, 1] 0 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # BUG FIX TEST: Assert zeros don't trump NAs in integer matrices 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + x <- matrix(NA_real_, nrow = 3L, ncol = 2L) 898s + x[1, 2] <- 0 898s + x[2, 2] <- 1 898s + x[3, 1] <- 0 898s + storage.mode(x) <- mode 898s + cat("mode: ", mode, "\n", sep = "") 898s + str(x) 898s + 898s + dimnames <- list(letters[1:3], LETTERS[1:2]) 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + # Row/column ranges 898s + r0 <- rowCumprods_R(x, useNames = useNames) 898s + r1 <- rowCumprods(x, useNames = useNames) 898s + r2 <- t(colCumprods(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } 898s mode: logical 898s logi [1:3, 1:2] NA NA FALSE FALSE TRUE NA 898s mode: integer 898s int [1:3, 1:2] NA NA 0 0 1 NA 898s mode: double 898s num [1:3, 1:2] NA NA 0 0 1 NA 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Corner cases 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + value <- 0 898s + storage.mode(value) <- mode 898s + if (mode == "logical") value2 <- 0L 898s + 898s + # A 0x0 matrix 898s + x <- matrix(value, nrow = 0L, ncol = 0L) 898s + str(x) 898s + r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x)) 898s + r1 <- rowCumprods(x) 898s + r2 <- t(colCumprods(t(x))) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + 898s + # A 0xK matrix 898s + x <- matrix(value, nrow = 0L, ncol = 5L) 898s + str(x) 898s + colnames <- LETTERS[1:5] 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) colnames(x) <- colnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCumprods_R(x, useNames = useNames) 898s + r1 <- rowCumprods(x, useNames = useNames) 898s + r2 <- t(rowCumprods(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + 898s + # A Nx0 matrix 898s + x <- matrix(value, nrow = 5L, ncol = 0L) 898s + str(x) 898s + rownames <- LETTERS[1:5] 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) rownames(x) <- rownames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCumprods_R(x, useNames = useNames) 898s + r1 <- rowCumprods(x, useNames = useNames) 898s + r2 <- t(rowCumprods(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (mode ...) 898s mode: logical 898s logi[0 , 0 ] 898s logi[0 , 1:5] 898s logi[1:5, 0 ] 898s mode: integer 898s int[0 , 0 ] 898s int[0 , 1:5] 898s int[1:5, 0 ] 898s mode: double 898s num[0 , 0 ] 898s num[0 , 1:5] 898s num[1:5, 0 ] 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowCumprods_R <- function(x, ..., useNames = NA) { 898s + suppressWarnings({ 898s + y <- t(apply(x, MARGIN = 1L, FUN = cumprod)) 898s + }) 898s + 898s + # Preserve dimnames attribute? 898s + dim(y) <- dim(x) 898s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 898s + 898s + y 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 898s > storage.mode(x) <- "integer" 898s > 898s > # To check dimnames attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowCumprods, fsure = rowCumprods_R, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = function(x, rows, cols, ..., useNames) { 898s + t(colCumprods(t(x), rows = cols, cols = rows, useNames = useNames)) 898s + }, fsure = rowCumprods_R, useNames = useNames) 898s + } 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowCumsums_R <- function(x, ..., useNames = NA) { 898s + suppressWarnings({ 898s + y <- t(apply(x, MARGIN = 1L, FUN = cumsum)) 898s + }) 898s + 898s + # Preserve dimnames attribute? 898s + dim(y) <- dim(x) 898s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 898s + 898s + y 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # With and without some NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > dimnames <- list(letters[1:10], LETTERS[1:5]) # to check dimnames attribute 898s > for (mode in c("logical", "integer", "double")) { 898s + for (add_na in c(FALSE, TRUE)) { 898s + cat("add_na = ", add_na, "\n", sep = "") 898s + 898s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 898s + if (add_na) { 898s + x[3:7, c(2, 4)] <- NA_real_ 898s + } 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + # Row/column ranges 898s + r0 <- rowCumsums_R(x, useNames = useNames) 898s + r1 <- rowCumsums(x, useNames = useNames) 898s + r2 <- t(colCumsums(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (add_na ...) 898s + } 898s add_na = FALSE 898s mode: logical 898s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s add_na = TRUE 898s mode: logical 898s logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s add_na = FALSE 898s mode: integer 898s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s add_na = TRUE 898s mode: integer 898s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s add_na = FALSE 898s mode: double 898s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s add_na = TRUE 898s mode: double 898s num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # All NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + # Row/column ranges 898s + r0 <- rowCumsums_R(x, useNames = useNames) 898s + r1 <- rowCumsums(x, useNames = useNames) 898s + r2 <- t(colCumsums(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (mode ...) 898s mode: logical 898s logi [1:10, 1:5] NA NA NA NA NA NA ... 898s mode: integer 898s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 898s mode: double 898s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # A 1x1 matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > dimnames <- list("a", "A") # to check dimnames attribute 898s > for (mode in c("logical", "integer", "double")) { 898s + x <- matrix(0, nrow = 1L, ncol = 1L) 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + r0 <- rowCumsums_R(x) 898s + r1 <- rowCumsums(x) 898s + r2 <- t(colCumsums(t(x))) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + 898s + # Check dimnames attribute 898s + dimnames(x) <- dimnames 898s + # r0 <- rowCumsums_R(x) 898s + # > r0 898s + # a 898s + # [1,] 0 898s + r1 <- rowCumsums(x, useNames = TRUE) 898s + r2 <- t(colCumsums(t(x), useNames = TRUE)) 898s + stopifnot(identical(dimnames(r1), dimnames)) 898s + stopifnot(identical(dimnames(r2), dimnames)) 898s + dimnames(x) <- NULL 898s + } 898s mode: logical 898s logi [1, 1] FALSE 898s mode: integer 898s int [1, 1] 0 898s mode: double 898s num [1, 1] 0 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Corner cases 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > names <- LETTERS[1:5] # to check dimnames attribute 898s > for (mode in c("logical", "integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + value <- 0 898s + storage.mode(value) <- mode 898s + value2 <- value 898s + if (mode == "logical") value2 <- 0L 898s + 898s + # A 0x0 matrix 898s + x <- matrix(value, nrow = 0L, ncol = 0L) 898s + str(x) 898s + r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x)) 898s + r1 <- rowCumsums(x) 898s + r2 <- t(colCumsums(t(x))) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + 898s + # A 0xK matrix 898s + x <- matrix(value, nrow = 0L, ncol = 5L) 898s + str(x) 898s + colnames <- LETTERS[1:5] 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) colnames(x) <- colnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCumsums_R(x, useNames = useNames) 898s + r1 <- rowCumsums(x, useNames = useNames) 898s + r2 <- t(rowCumsums(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + 898s + # A Nx0 matrix 898s + x <- matrix(value, nrow = 5L, ncol = 0L) 898s + str(x) 898s + rownames <- LETTERS[1:5] 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) rownames(x) <- rownames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowCumsums_R(x, useNames = useNames) 898s + r1 <- rowCumsums(x, useNames = useNames) 898s + r2 <- t(rowCumsums(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (mode ...) 898s mode: logical 898s logi[0 , 0 ] 898s logi[0 , 1:5] 898s logi[1:5, 0 ] 898s mode: integer 898s int[0 , 0 ] 898s int[0 , 1:5] 898s int[1:5, 0 ] 898s mode: double 898s num[0 , 0 ] 898s num[0 , 1:5] 898s num[1:5, 0 ] 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowCumsums_R <- function(x, ..., useNames = NA) { 898s + suppressWarnings({ 898s + y <- t(apply(x, MARGIN = 1L, FUN = cumsum)) 898s + }) 898s + 898s + # Preserve dimnames attribute? 898s + dim(y) <- dim(x) 898s + dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL 898s + 898s + y 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 898s > storage.mode(x) <- "integer" 898s > 898s > # To check dimnames attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowCumsums, fsure = rowCumsums_R, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = function(x, rows, cols, ..., useNames) { 898s + t(colCumsums(t(x), rows = cols, cols = rows, useNames = useNames)) 898s + }, fsure = rowCumsums_R, useNames = useNames) 898s + } 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = NA) { 898s + ncol2 <- ncol(x) - lag * differences 898s + if (ncol2 <= 0) { 898s + y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L) 898s + # Preserve names attribute 898s + if (isTRUE(useNames) && !is.null(rownames(x))) rownames(y) <- rownames(x) 898s + return(y) 898s + } 898s + suppressWarnings({ 898s + y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences) 898s + }) 898s + y <- t(y) 898s + 898s + # Preserve dimnames attribute 898s + dim(y) <- c(nrow(x), ncol2) 898s + if (isTRUE(useNames) && !is.null(dimnames(x))) { 898s + colnames <- colnames(x) 898s + if (!is.null(colnames)) { 898s + len <- length(colnames) 898s + colnames <- colnames[(len - ncol2 + 1):len] 898s + } 898s + dimnames(y) <- list(rownames(x), colnames) 898s + } 898s + else dimnames(y) <- NULL 898s + 898s + y 898s + } 898s > 898s > 898s > set.seed(0x42) 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # With and without some NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + 898s + for (add_na in c(FALSE, TRUE)) { 898s + cat("add_na = ", add_na, "\n", sep = "") 898s + 898s + x <- matrix(sample(10 * 8) + 0.1, nrow = 10L, ncol = 8L) 898s + if (add_na) { 898s + x[3:7, c(2, 4)] <- NA_real_ 898s + } 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + dimnames <- list(letters[1:10], LETTERS[1:8]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check dimnames attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + for (lag in 1:4) { 898s + for (differences in 1:3) { 898s + cat(sprintf("mode: %s, lag = %d, differences = %d\n", 898s + mode, lag, differences)) 898s + # Row/column ranges 898s + r0 <- rowDiffs_R(x, lag = lag, differences = differences, useNames = useNames) 898s + r1 <- rowDiffs(x, lag = lag, differences = differences, useNames = useNames) 898s + r2 <- t(colDiffs(t(x), lag = lag, differences = differences, useNames = useNames)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + stopifnot(all.equal(r1, r2)) 898s + } 898s + } 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (add_na ...) 898s + } # for (mode ...) 898s mode: integer 898s add_na = FALSE 898s int [1:10, 1:8] 68 26 29 47 48 10 1 38 16 40 ... 898s mode: integer, lag = 1, differences = 1 898s mode: integer, lag = 1, differences = 2 898s mode: integer, lag = 1, differences = 3 898s mode: integer, lag = 2, differences = 1 898s mode: integer, lag = 2, differences = 2 898s mode: integer, lag = 2, differences = 3 898s mode: integer, lag = 3, differences = 1 898s mode: integer, lag = 3, differences = 2 898s mode: integer, lag = 3, differences = 3 898s mode: integer, lag = 4, differences = 1 898s mode: integer, lag = 4, differences = 2 898s mode: integer, lag = 4, differences = 3 898s mode: integer, lag = 1, differences = 1 898s mode: integer, lag = 1, differences = 2 898s mode: integer, lag = 1, differences = 3 898s mode: integer, lag = 2, differences = 1 898s mode: integer, lag = 2, differences = 2 898s mode: integer, lag = 2, differences = 3 898s mode: integer, lag = 3, differences = 1 898s mode: integer, lag = 3, differences = 2 898s mode: integer, lag = 3, differences = 3 898s mode: integer, lag = 4, differences = 1 898s mode: integer, lag = 4, differences = 2 898s mode: integer, lag = 4, differences = 3 898s mode: integer, lag = 1, differences = 1 898s mode: integer, lag = 1, differences = 2 898s mode: integer, lag = 1, differences = 3 898s mode: integer, lag = 2, differences = 1 898s mode: integer, lag = 2, differences = 2 898s mode: integer, lag = 2, differences = 3 898s mode: integer, lag = 3, differences = 1 898s mode: integer, lag = 3, differences = 2 898s mode: integer, lag = 3, differences = 3 898s mode: integer, lag = 4, differences = 1 898s mode: integer, lag = 4, differences = 2 898s mode: integer, lag = 4, differences = 3 898s mode: integer, lag = 1, differences = 1 898s mode: integer, lag = 1, differences = 2 898s mode: integer, lag = 1, differences = 3 898s mode: integer, lag = 2, differences = 1 898s mode: integer, lag = 2, differences = 2 898s mode: integer, lag = 2, differences = 3 898s mode: integer, lag = 3, differences = 1 898s mode: integer, lag = 3, differences = 2 898s mode: integer, lag = 3, differences = 3 898s mode: integer, lag = 4, differences = 1 898s mode: integer, lag = 4, differences = 2 898s mode: integer, lag = 4, differences = 3 898s add_na = TRUE 898s int [1:10, 1:8] 80 71 7 52 79 22 31 10 29 63 ... 898s mode: integer, lag = 1, differences = 1 898s mode: integer, lag = 1, differences = 2 898s mode: integer, lag = 1, differences = 3 898s mode: integer, lag = 2, differences = 1 898s mode: integer, lag = 2, differences = 2 898s mode: integer, lag = 2, differences = 3 898s mode: integer, lag = 3, differences = 1 898s mode: integer, lag = 3, differences = 2 898s mode: integer, lag = 3, differences = 3 898s mode: integer, lag = 4, differences = 1 898s mode: integer, lag = 4, differences = 2 898s mode: integer, lag = 4, differences = 3 898s mode: integer, lag = 1, differences = 1 898s mode: integer, lag = 1, differences = 2 898s mode: integer, lag = 1, differences = 3 898s mode: integer, lag = 2, differences = 1 898s mode: integer, lag = 2, differences = 2 898s mode: integer, lag = 2, differences = 3 898s mode: integer, lag = 3, differences = 1 898s mode: integer, lag = 3, differences = 2 898s mode: integer, lag = 3, differences = 3 898s mode: integer, lag = 4, differences = 1 898s mode: integer, lag = 4, differences = 2 898s mode: integer, lag = 4, differences = 3 898s mode: integer, lag = 1, differences = 1 898s mode: integer, lag = 1, differences = 2 898s mode: integer, lag = 1, differences = 3 898s mode: integer, lag = 2, differences = 1 898s mode: integer, lag = 2, differences = 2 898s mode: integer, lag = 2, differences = 3 898s mode: integer, lag = 3, differences = 1 898s mode: integer, lag = 3, differences = 2 898s mode: integer, lag = 3, differences = 3 898s mode: integer, lag = 4, differences = 1 898s mode: integer, lag = 4, differences = 2 898s mode: integer, lag = 4, differences = 3 898s mode: integer, lag = 1, differences = 1 898s mode: integer, lag = 1, differences = 2 898s mode: integer, lag = 1, differences = 3 898s mode: integer, lag = 2, differences = 1 898s mode: integer, lag = 2, differences = 2 898s mode: integer, lag = 2, differences = 3 898s mode: integer, lag = 3, differences = 1 898s mode: integer, lag = 3, differences = 2 898s mode: integer, lag = 3, differences = 3 898s mode: integer, lag = 4, differences = 1 898s mode: integer, lag = 4, differences = 2 898s mode: integer, lag = 4, differences = 3 898s mode: double 898s add_na = FALSE 898s num [1:10, 1:8] 36.1 15.1 27.1 63.1 62.1 58.1 28.1 19.1 41.1 3.1 ... 898s mode: double, lag = 1, differences = 1 898s mode: double, lag = 1, differences = 2 898s mode: double, lag = 1, differences = 3 898s mode: double, lag = 2, differences = 1 898s mode: double, lag = 2, differences = 2 898s mode: double, lag = 2, differences = 3 898s mode: double, lag = 3, differences = 1 898s mode: double, lag = 3, differences = 2 898s mode: double, lag = 3, differences = 3 898s mode: double, lag = 4, differences = 1 898s mode: double, lag = 4, differences = 2 898s mode: double, lag = 4, differences = 3 898s mode: double, lag = 1, differences = 1 898s mode: double, lag = 1, differences = 2 898s mode: double, lag = 1, differences = 3 898s mode: double, lag = 2, differences = 1 898s mode: double, lag = 2, differences = 2 898s mode: double, lag = 2, differences = 3 898s mode: double, lag = 3, differences = 1 898s mode: double, lag = 3, differences = 2 898s mode: double, lag = 3, differences = 3 898s mode: double, lag = 4, differences = 1 898s mode: double, lag = 4, differences = 2 898s mode: double, lag = 4, differences = 3 898s mode: double, lag = 1, differences = 1 898s mode: double, lag = 1, differences = 2 898s mode: double, lag = 1, differences = 3 898s mode: double, lag = 2, differences = 1 898s mode: double, lag = 2, differences = 2 898s mode: double, lag = 2, differences = 3 898s mode: double, lag = 3, differences = 1 898s mode: double, lag = 3, differences = 2 898s mode: double, lag = 3, differences = 3 898s mode: double, lag = 4, differences = 1 898s mode: double, lag = 4, differences = 2 898s mode: double, lag = 4, differences = 3 898s mode: double, lag = 1, differences = 1 898s mode: double, lag = 1, differences = 2 898s mode: double, lag = 1, differences = 3 898s mode: double, lag = 2, differences = 1 898s mode: double, lag = 2, differences = 2 898s mode: double, lag = 2, differences = 3 898s mode: double, lag = 3, differences = 1 898s mode: double, lag = 3, differences = 2 898s mode: double, lag = 3, differences = 3 898s mode: double, lag = 4, differences = 1 898s mode: double, lag = 4, differences = 2 898s mode: double, lag = 4, differences = 3 898s add_na = TRUE 898s num [1:10, 1:8] 67.1 80.1 45.1 8.1 39.1 66.1 27.1 71.1 47.1 46.1 ... 898s mode: double, lag = 1, differences = 1 898s mode: double, lag = 1, differences = 2 898s mode: double, lag = 1, differences = 3 898s mode: double, lag = 2, differences = 1 898s mode: double, lag = 2, differences = 2 898s mode: double, lag = 2, differences = 3 898s mode: double, lag = 3, differences = 1 898s mode: double, lag = 3, differences = 2 898s mode: double, lag = 3, differences = 3 898s mode: double, lag = 4, differences = 1 898s mode: double, lag = 4, differences = 2 898s mode: double, lag = 4, differences = 3 898s mode: double, lag = 1, differences = 1 898s mode: double, lag = 1, differences = 2 898s mode: double, lag = 1, differences = 3 898s mode: double, lag = 2, differences = 1 898s mode: double, lag = 2, differences = 2 898s mode: double, lag = 2, differences = 3 898s mode: double, lag = 3, differences = 1 898s mode: double, lag = 3, differences = 2 898s mode: double, lag = 3, differences = 3 898s mode: double, lag = 4, differences = 1 898s mode: double, lag = 4, differences = 2 898s mode: double, lag = 4, differences = 3 898s mode: double, lag = 1, differences = 1 898s mode: double, lag = 1, differences = 2 898s mode: double, lag = 1, differences = 3 898s mode: double, lag = 2, differences = 1 898s mode: double, lag = 2, differences = 2 898s mode: double, lag = 2, differences = 3 898s mode: double, lag = 3, differences = 1 898s mode: double, lag = 3, differences = 2 898s mode: double, lag = 3, differences = 3 898s mode: double, lag = 4, differences = 1 898s mode: double, lag = 4, differences = 2 898s mode: double, lag = 4, differences = 3 898s mode: double, lag = 1, differences = 1 898s mode: double, lag = 1, differences = 2 898s mode: double, lag = 1, differences = 3 898s mode: double, lag = 2, differences = 1 898s mode: double, lag = 2, differences = 2 898s mode: double, lag = 2, differences = 3 898s mode: double, lag = 3, differences = 1 898s mode: double, lag = 3, differences = 2 898s mode: double, lag = 3, differences = 3 898s mode: double, lag = 4, differences = 1 898s mode: double, lag = 4, differences = 2 898s mode: double, lag = 4, differences = 3 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # All NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + dimnames <- list(letters[1:10], LETTERS[1:5]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check dimnames attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowDiffs_R(x, useNames = useNames) 898s + r1 <- rowDiffs(x, useNames = useNames) 898s + r2 <- t(colDiffs(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + stopifnot(all.equal(r1, r2)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s + } # for (mode ...) 898s mode: integer 898s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 898s mode: double 898s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # A 1x1 matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > x <- matrix(0, nrow = 1L, ncol = 1L) 898s > dimnames <- list("a", "A") 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check dimnames attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + r0 <- rowDiffs_R(x, useNames = useNames) 898s + r1 <- rowDiffs(x, useNames = useNames) 898s + r2 <- t(colDiffs(t(x), useNames = useNames)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + stopifnot(all.equal(r1, r2)) 898s + } # for (useNames ...) 898s + } # for (setDimnames ...) 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = NA) { 898s + ncol2 <- ncol(x) - lag * differences 898s + if (ncol2 <= 0) { 898s + y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L) 898s + # Preserve names attribute 898s + if (isTRUE(useNames) && !is.null(rownames(x))) rownames(y) <- rownames(x) 898s + return(y) 898s + } 898s + suppressWarnings({ 898s + y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences) 898s + }) 898s + y <- t(y) 898s + 898s + # Preserve dimnames attribute 898s + dim(y) <- c(nrow(x), ncol2) 898s + if (isTRUE(useNames) && !is.null(dimnames(x))) { 898s + colnames <- colnames(x) 898s + if (!is.null(colnames)) { 898s + len <- length(colnames) 898s + colnames <- colnames[(len - ncol2 + 1):len] 898s + } 898s + dimnames(y) <- list(rownames(x), colnames) 898s + } 898s + else dimnames(y) <- NULL 898s + 898s + y 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 898s > storage.mode(x) <- "integer" 898s > 898s > # To check dimnames attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + 898s + count <- 0L 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + count <- count + 1L 898s + for (lag in 1:2) { 898s + for (differences in 1:3) { 898s + # Check dimnames attribute 898s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 898s + useNames <- useNames[count %% length(useNames) + 1] 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowDiffs, fsure = rowDiffs_R, 898s + lag = lag, differences = differences, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = function(x, rows, cols, ..., useNames) { 898s + t(colDiffs(t(x), rows = cols, cols = rows, ..., useNames = useNames)) 898s + }, fsure = rowDiffs_R, 898s + lag = lag, differences = differences, useNames = useNames) 898s + } 898s + } 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + quantile_na <- function(x, ..., na.rm = FALSE) { 898s + if (!na.rm && anyMissing(x)) 898s + return(c(NA_real_, NA_real_)) 898s + quantile(x, ..., na.rm = na.rm) 898s + } 898s + q <- apply(x, MARGIN = 1L, FUN = quantile_na, 898s + probs = c(0.25, 0.75), na.rm = na.rm) 898s + rownames(q) <- NULL # Not needed anymore 898s + 898s + # Preserve names attribute 898s + dim(q) <- c(2L, nrow(x)) 898s + colnames(q) <- if (isTRUE(useNames)) rownames(x) else NULL 898s + 898s + q[2L, , drop = TRUE] - q[1L, , drop = TRUE] 898s + } 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Test with multiple quantiles 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + x <- matrix(1:100 + 0.1, nrow = 10, ncol = 10) 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # To check names attribute 898s + dimnames <- list(letters[1:10], LETTERS[1:10]) 898s + 898s + for (add_na in c(FALSE, TRUE)) { 898s + if (add_na) { 898s + x[3:5, 6:9] <- NA 898s + } 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (na.rm in c(FALSE, TRUE)) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + probs <- c(0, 0.5, 1) 898s + q0 <- rowIQRs_R(x, na.rm = na.rm, useNames = useNames) 898s + print(q0) 898s + q1 <- rowIQRs(x, na.rm = na.rm, useNames = useNames) 898s + print(q1) 898s + stopifnot(all.equal(q1, q0)) 898s + q2 <- colIQRs(t(x), na.rm = na.rm, useNames = useNames) 898s + stopifnot(all.equal(q2, q0)) 898s + 898s + q <- iqr(x[3, ], na.rm = na.rm) 898s + print(q) 898s + } # for (useNames ...) 898s + } # for (na.rm ...) 898s + } # for (setDimnames ...) 898s + } # for (add_na ...) 898s + } # for (mode ...) 898s mode: integer 898s int [1:10, 1:10] 1 2 3 4 5 6 7 8 9 10 ... 898s a b c d e f g h i j 898s 45 45 45 45 45 45 45 45 45 45 898s a b c d e f g h i j 898s 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s a b c d e f g h i j 898s 45 45 45 45 45 45 45 45 45 45 898s a b c d e f g h i j 898s 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s a b c d e f g h i j 898s 45 45 NA NA NA 45 45 45 45 45 898s a b c d e f g h i j 898s 45 45 NA NA NA 45 45 45 45 45 898s [1] NA 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] NA 898s a b c d e f g h i j 898s 45 45 25 25 25 45 45 45 45 45 898s a b c d e f g h i j 898s 45 45 25 25 25 45 45 45 45 45 898s [1] 25 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 25 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] NA 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] NA 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 25 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 25 898s mode: double 898s num [1:10, 1:10] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 898s a b c d e f g h i j 898s 45 45 45 45 45 45 45 45 45 45 898s a b c d e f g h i j 898s 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s a b c d e f g h i j 898s 45 45 45 45 45 45 45 45 45 45 898s a b c d e f g h i j 898s 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 45 45 45 45 45 45 45 45 45 898s [1] 45 898s a b c d e f g h i j 898s 45 45 NA NA NA 45 45 45 45 45 898s a b c d e f g h i j 898s 45 45 NA NA NA 45 45 45 45 45 898s [1] NA 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] NA 898s a b c d e f g h i j 898s 45 45 25 25 25 45 45 45 45 45 898s a b c d e f g h i j 898s 45 45 25 25 25 45 45 45 45 45 898s [1] 25 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 25 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] NA 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] 45 45 NA NA NA 45 45 45 45 45 898s [1] NA 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 25 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 45 45 25 25 25 45 45 45 45 45 898s [1] 25 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Test corner cases 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + # Empty vectors 898s + x <- integer(0L) 898s + storage.mode(x) <- mode 898s + str(x) 898s + q <- iqr(x) 898s + print(q) 898s + stopifnot(identical(q, NA_real_)) 898s + 898s + # Scalar 898s + x <- 1L 898s + storage.mode(x) <- mode 898s + str(x) 898s + q <- iqr(x) 898s + str(q) 898s + stopifnot(identical(q, 0)) 898s + } 898s mode: integer 898s int(0) 898s [1] NA 898s int 1 898s num 0 898s mode: double 898s num(0) 898s [1] NA 898s num 1 898s num 0 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Single row matrices 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > x <- matrix(1, nrow = 1L, ncol = 2L) 898s > dimnames <- list("a", LETTERS[1:2]) 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + q0 <- rowIQRs_R(x, useNames = useNames) 898s + q1 <- rowIQRs(x, useNames = useNames) 898s + q2 <- colIQRs(t(x), useNames = useNames) 898s + stopifnot(all.equal(q0, q1)) 898s + stopifnot(all.equal(q0, q2)) 898s + } 898s + } 898s > 898s > x <- matrix(1, nrow = 2L, ncol = 1L) 898s > q <- colIQRs(x) 898s > stopifnot(identical(q, 0)) 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowIQRs_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + quantile_na <- function(x, ..., na.rm = FALSE) { 898s + if (!na.rm && anyMissing(x)) 898s + return(c(NA_real_, NA_real_)) 898s + quantile(x, ..., na.rm = na.rm) 898s + } 898s + q <- apply(x, MARGIN = 1L, FUN = quantile_na, 898s + probs = c(0.25, 0.75), na.rm = na.rm) 898s + rownames(q) <- NULL # Not needed anymore 898s + 898s + # Preserve names attribute 898s + dim(q) <- c(2L, nrow(x)) 898s + colnames(q) <- if (isTRUE(useNames)) rownames(x) else NULL 898s + 898s + q[2L, , drop = TRUE] - q[1L, , drop = TRUE] 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- runif(6, min = -6, max = 6) 898s > for (idxs in index_cases) { 898s + for (na.rm in c(TRUE, FALSE)) { 898s + validateIndicesTestVector(x, idxs, ftest = iqr, fsure = function(x, na.rm) { 898s + dim(x) <- c(1L, length(x)) 898s + rowIQRs_R(x, na.rm = na.rm) 898s + }, na.rm = na.rm) 898s + } 898s + } 898s > 898s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + 898s + count <- 0L 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + count <- count + 1L 898s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 898s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 898s + useNames <- useNames[count %% length(useNames) + 1] 898s + 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowIQRs, fsure = rowIQRs_R, 898s + na.rm = na.rm, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colIQRs, fsure = rowIQRs_R, 898s + na.rm = na.rm, useNames = useNames) 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > # Test inspired by the harmonic mean example in R-help 898s > # thread '[R] Beyond double-precision?' on May 9, 2009. 898s > 898s > library("matrixStats") 898s > library("stats") 898s > 898s > logSumExp0 <- function(lx) { 898s + idx_max <- which.max(lx) 898s + log1p(sum(exp(lx[-idx_max] - lx[idx_max]))) + lx[idx_max] 898s + } 898s > 898s > n <- 200L 898s > set.seed(1) 898s > 898s > for (mode in c("integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + x <- matrix(runif(n, min = 1.0, max = 3.0), nrow = 20L) 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # The logarithm of the harmonic mean by rows 898s + y_h <- log(1 / rowMeans(1 / x)) 898s + str(y_h) 898s + 898s + lx_neg <- -log(x) 898s + 898s + y0 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp0) 898s + stopifnot(all.equal(y0, y_h)) 898s + 898s + y1 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y2 <- log(ncol(x)) - rowLogSumExps(lx_neg) 898s + stopifnot(all.equal(y2, y0)) 898s + 898s + y3 <- log(ncol(x)) - colLogSumExps(t(lx_neg)) 898s + stopifnot(all.equal(y3, y0)) 898s + 898s + 898s + # The logarithm of the harmonic mean by columns 898s + y_h <- log(1 / colMeans(1 / x)) 898s + str(y_h) 898s + 898s + y0 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp0) 898s + stopifnot(all.equal(y0, y_h)) 898s + 898s + y1 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y2 <- log(nrow(x)) - colLogSumExps(lx_neg) 898s + stopifnot(all.equal(y2, y0)) 898s + 898s + y3 <- log(nrow(x)) - rowLogSumExps(t(lx_neg)) 898s + stopifnot(all.equal(y3, y0)) 898s + 898s + # Testing names 898s + rownames(lx_neg) <- seq_len(nrow(x)) 898s + colnames(lx_neg) <- seq_len(ncol(x)) 898s + y2 <- rowLogSumExps(lx_neg, useNames = TRUE) 898s + stopifnot(identical(names(y2), rownames(lx_neg))) 898s + y3 <- colLogSumExps(t(lx_neg), useNames = TRUE) 898s + stopifnot(identical(names(y3), rownames(lx_neg))) 898s + } # for (mode ...) 898s mode: integer 898s int [1:20, 1:10] 1 1 2 2 1 2 2 2 2 1 ... 898s num [1:20] 0.357 0.223 0.223 0.288 0.511 ... 898s num [1:10] 0.322 0.223 0.322 0.255 0.255 ... 898s mode: double 898s num [1:20, 1:10] 1.54 1.44 2.03 1.54 1.36 ... 898s num [1:20] 0.526 0.466 0.734 0.638 0.604 ... 898s num [1:10] 0.627 0.582 0.617 0.474 0.418 ... 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Corner cases 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > ## Zero-size matrices 898s > lx <- matrix(numeric(0L), nrow = 0L, ncol = 0L) 898s > y <- rowLogSumExps(lx) 898s > print(y) 898s numeric(0) 898s > stopifnot(length(y) == nrow(lx)) 898s > 898s > y <- colLogSumExps(lx) 898s > print(y) 898s numeric(0) 898s > stopifnot(length(y) == ncol(lx)) 898s > 898s > ## Zero-height matrices 898s > lx <- matrix(numeric(0L), nrow = 0L, ncol = 5L) 898s > y <- rowLogSumExps(lx) 898s > print(y) 898s numeric(0) 898s > stopifnot(length(y) == nrow(lx)) 898s > 898s > y <- colLogSumExps(lx) 898s > print(y) 898s [1] -Inf -Inf -Inf -Inf -Inf 898s > stopifnot(length(y) == ncol(lx)) 898s > stopifnot(all(y == -Inf)) 898s > 898s > ## Zero-width matrices 898s > lx <- matrix(numeric(0L), nrow = 5L, ncol = 0L) 898s > y <- colLogSumExps(lx) 898s > print(y) 898s numeric(0) 898s > stopifnot(length(y) == ncol(lx)) 898s > 898s > y <- rowLogSumExps(lx) 898s > print(y) 898s [1] -Inf -Inf -Inf -Inf -Inf 898s > stopifnot(length(y) == nrow(lx)) 898s > stopifnot(all(y == -Inf)) 898s > 898s > 898s > ## Matrices with one element 898s > lx <- matrix(1.0, nrow = 1L, ncol = 1L) 898s > y <- rowLogSumExps(lx) 898s > print(y) 898s [1] 1 898s > stopifnot(length(y) == nrow(lx)) 898s > stopifnot(all(y == lx)) 898s > 898s > y <- colLogSumExps(lx) 898s > print(y) 898s [1] 1 898s > stopifnot(length(y) == ncol(lx)) 898s > stopifnot(all(y == lx)) 898s > 898s > ## All missing values 898s > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L) 898s > y <- rowLogSumExps(lx, na.rm = TRUE) 898s > print(y) 898s [1] -Inf 898s > stopifnot(length(y) == nrow(lx)) 898s > stopifnot(identical(y, -Inf)) 898s > 898s > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L) 898s > y <- colLogSumExps(lx, na.rm = TRUE) 898s > print(y) 898s [1] -Inf 898s > stopifnot(length(y) == ncol(lx)) 898s > stopifnot(identical(y, -Inf)) 898s > 898s > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L) 898s > y <- rowLogSumExps(lx, na.rm = TRUE) 898s > print(y) 898s [1] -Inf -Inf 898s > stopifnot(length(y) == nrow(lx)) 898s > stopifnot(all(y == -Inf)) 898s > 898s > y <- rowLogSumExps(lx, na.rm = FALSE) 898s > print(y) 898s [1] NA NA 898s > stopifnot(length(y) == nrow(lx)) 898s > stopifnot(all(is.na(y) & !is.nan(y))) 898s > 898s > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L) 898s > y <- colLogSumExps(lx, na.rm = TRUE) 898s > print(y) 898s [1] -Inf -Inf 898s > stopifnot(length(y) == ncol(lx)) 898s > stopifnot(all(y == -Inf)) 898s > 898s > y <- colLogSumExps(lx, na.rm = FALSE) 898s > print(y) 898s [1] NA NA 898s > stopifnot(length(y) == ncol(lx)) 898s > stopifnot(all(is.na(y) & !is.nan(y))) 898s > 898s > ## +Inf values 898s > lx <- matrix(c(1, 2, +Inf), nrow = 3L, ncol = 2L) 898s > y <- colLogSumExps(lx, na.rm = TRUE) 898s > print(y) 898s [1] Inf Inf 898s > stopifnot(length(y) == ncol(lx)) 898s > stopifnot(all(y == +Inf)) 898s > 898s > ## multiple -Inf values 898s > lx <- matrix(c(-Inf, -Inf), nrow = 2L, ncol = 3L) 898s > y <- rowLogSumExps(lx) 898s > print(y) 898s [1] -Inf -Inf 898s > stopifnot(length(y) == nrow(lx)) 898s > stopifnot(all(y == -Inf)) 898s > 898s > lx <- matrix(c(-Inf, 5, -Inf), nrow = 2L, ncol = 3L, byrow = TRUE) 898s > y <- rowLogSumExps(lx) 898s > print(y) 898s [1] 5 5 898s > stopifnot(length(y) == nrow(lx)) 898s > stopifnot(all(y == 5)) 898s > 898s > ## Bug report #104 (https://github.com/HenrikBengtsson/matrixStats/issues/104) 898s > ## (This would core dump on Windows) 898s > x <- matrix(0.0, nrow = 2L, ncol = 32762L) 898s > y <- colLogSumExps(x) 898s > str(y) 898s num [1:32762] 0.693 0.693 0.693 0.693 0.693 ... 898s > 898s > ## Bug report #120 (https://github.com/HenrikBengtsson/matrixStats/issues/120) 898s > ## (This would error if x had rownames/colnames and non-NULL rows/cols were 898s > ## used) 898s > x <- matrix(runif(6), nrow = 2L, ncol = 3L, 898s + dimnames = list(c("A", "B"), c("a", "b", "c"))) 898s > y <- colLogSumExps(x, cols = 3:1, useNames = TRUE) 898s > stopifnot(names(y) == c("c", "b", "a")) 898s > y <- rowLogSumExps(x, rows = 2, useNames = TRUE) 898s > stopifnot(names(y) == "B") 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Check names attributes 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > 898s > ## Create isFALSE() if running on an old version of R 898s > if (!exists("isFALSE", mode="function")) { 898s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 898s + } 898s > 898s > rowLogSumExps_R <- function(x, ..., useNames = NA) { 898s + res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) { 898s + log(sum(exp(rx), ...)) 898s + }, ...) 898s + if (isFALSE(useNames)) names(res) <- NULL 898s + res 898s + } 898s > 898s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowLogSumExps_R(x, useNames = useNames) 898s + y1 <- rowLogSumExps(x, useNames = useNames) 898s + y2 <- colLogSumExps(t(x), useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + stopifnot(all.equal(y2, y0)) 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > ## Create isFALSE() if running on an old version of R 898s > if (!exists("isFALSE", mode="function")) { 898s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 898s + } 898s > 898s > rowLogSumExps_R <- function(x, ..., useNames = NA) { 898s + res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) { 898s + log(sum(exp(rx), ...)) 898s + }, ...) 898s + if (isFALSE(useNames)) names(res) <- NULL 898s + res 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + for (na.rm in c(TRUE, FALSE)) { 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowLogSumExps, 898s + fsure = rowLogSumExps_R, 898s + na.rm = na.rm, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colLogSumExps, 898s + fsure = rowLogSumExps_R, 898s + na.rm = na.rm, useNames = useNames) 898s + } 898s + } 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 898s > options(matrixStats.center.onUse = "ignore") 898s > 898s > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + suppressWarnings({ 898s + res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm) 898s + }) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > colMads_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + suppressWarnings({ 898s + res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm) 898s + }) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 898s + center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE) 898s + rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 898s + } 898s > 898s > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 898s + center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE) 898s + colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # A 3x3 matrix (no ties) 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("integer", "double")) { 898s + x <- matrix(c(1, 2, 3, 2, 3, 4, 3, 4, 5) + 0.1, nrow = 3, ncol = 3) 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # To check name attribute 898s + dimnames <- list(letters[1:3], LETTERS[1:3]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + tx <- t(x) 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + cat("rowMads():\n") 898s + center <- rowMedians(x, na.rm = TRUE, useNames = useNames) 898s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 898s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 898s + r1b <- rowMads_center(x, na.rm = TRUE, useNames = useNames) 898s + r1c <- rowMads(x, center = center, na.rm = TRUE, useNames = useNames) 898s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 898s + r2b <- colMads_center(tx, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r1b, r1)) 898s + stopifnot(all.equal(r1c, r1)) 898s + stopifnot(all.equal(r2, r0)) 898s + stopifnot(all.equal(r2b, r2)) 898s + 898s + cat("colMads():\n") 898s + center <- colMedians(x, na.rm = TRUE, useNames = useNames) 898s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 898s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 898s + r1b <- colMads_center(x, na.rm = TRUE, useNames = useNames) 898s + r1c <- colMads(x, center = center, na.rm = TRUE, useNames = useNames) 898s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 898s + r2b <- rowMads_center(tx, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r1b, r1)) 898s + stopifnot(all.equal(r1c, r1)) 898s + stopifnot(all.equal(r2, r0)) 898s + stopifnot(all.equal(r2b, r2)) 898s + } 898s + } 898s + } 898s mode: integer 898s int [1:3, 1:3] 1 2 3 2 3 4 3 4 5 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s mode: double 898s num [1:3, 1:3] 1.1 2.1 3.1 2.1 3.1 4.1 3.1 4.1 5.1 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Ties: a 4x4 matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("integer", "double")) { 898s + x <- matrix(c(1:4, 2:5, 3:6, 4:7) + 0.1, nrow = 4, ncol = 4) 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + tx <- t(x) 898s + 898s + # To check name attribute 898s + dimnames <- list(letters[1:4], LETTERS[1:4]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + tx <- t(x) 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + cat("rowMads():\n") 898s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 898s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 898s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + 898s + cat("colMads():\n") 898s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 898s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 898s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } 898s + } 898s + } 898s mode: integer 898s int [1:4, 1:4] 1 2 3 4 2 3 4 5 3 4 ... 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s mode: double 898s num [1:4, 1:4] 1.1 2.1 3.1 4.1 2.1 3.1 4.1 5.1 3.1 4.1 ... 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s > tx <- NULL 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # No ties: a 3x3 matrix with an NA value 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("integer", "double")) { 898s + x <- matrix(c(1, 2, 3, 2, 3, 4, 3, 4, 5) + 0.1, nrow = 3, ncol = 3) 898s + x[2, 2] <- NA_real_ 898s + 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + tx <- t(x) 898s + 898s + # To check name attribute 898s + dimnames <- list(letters[1:3], LETTERS[1:3]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + tx <- t(x) 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + cat("rowMads():\n") 898s + r0 <- rowMads_R(x, na.rm = TRUE, useNames = useNames) 898s + r1 <- rowMads(x, na.rm = TRUE, useNames = useNames) 898s + r2 <- colMads(tx, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + 898s + cat("colMads():\n") 898s + r0 <- colMads_R(x, na.rm = TRUE, useNames = useNames) 898s + r1 <- colMads(x, na.rm = TRUE, useNames = useNames) 898s + r2 <- rowMads(tx, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } 898s + } 898s + } 898s mode: integer 898s int [1:3, 1:3] 1 2 3 2 NA 4 3 4 5 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s mode: double 898s num [1:3, 1:3] 1.1 2.1 3.1 2.1 NA 4.1 3.1 4.1 5.1 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s rowMads(): 898s colMads(): 898s > tx <- NULL 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # With and without some NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (add_na in c(FALSE, TRUE)) { 898s + cat("add_na = ", add_na, "\n", sep = "") 898s + 898s + x <- matrix(1:50, nrow = 10L, ncol = 5L) 898s + if (add_na) { 898s + x[3:7, c(2, 4)] <- NA_real_ 898s + } 898s + 898s + # To check name attribute 898s + dimnames <- list(letters[1:10], LETTERS[1:5]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + tx <- t(x) 898s + # Row/column ranges 898s + for (na.rm in c(FALSE, TRUE)) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + cat("na.rm = ", na.rm, "\n", sep = "") 898s + cat("rowMads():\n") 898s + center <- rowMedians(x, na.rm = na.rm, useNames = useNames) 898s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 898s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 898s + r2 <- rowMads(x, center = center, na.rm = na.rm, useNames = useNames) 898s + r3 <- colMads(tx, na.rm = na.rm, useNames = useNames) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + stopifnot(all.equal(r2, r1)) 898s + stopifnot(all.equal(r3, r0)) 898s + stopifnot(all.equal(r3, r1)) 898s + stopifnot(all.equal(r3, r2)) 898s + 898s + cat("colMads():\n") 898s + center <- colMedians(x, na.rm = na.rm, useNames = useNames) 898s + r0 <- colMads_R(x, na.rm = na.rm, useNames = useNames) 898s + r1 <- colMads(x, na.rm = na.rm, useNames = useNames) 898s + r2 <- colMads(x, center = center, na.rm = na.rm, useNames = useNames) 898s + r3 <- rowMads(tx, na.rm = na.rm, useNames = useNames) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + stopifnot(all.equal(r2, r1)) 898s + stopifnot(all.equal(r3, r0)) 898s + stopifnot(all.equal(r3, r1)) 898s + stopifnot(all.equal(r3, r2)) 898s + } 898s + } 898s + } 898s + tx <- NULL 898s + } # for (add_na ...) 898s add_na = FALSE 898s na.rm = FALSE 898s rowMads(): 898s colMads(): 898s na.rm = FALSE 898s rowMads(): 898s colMads(): 898s na.rm = TRUE 898s rowMads(): 898s colMads(): 898s na.rm = TRUE 898s rowMads(): 898s colMads(): 898s na.rm = FALSE 898s rowMads(): 898s colMads(): 898s na.rm = FALSE 898s rowMads(): 898s colMads(): 898s na.rm = TRUE 898s rowMads(): 898s colMads(): 898s na.rm = TRUE 898s rowMads(): 898s colMads(): 898s add_na = TRUE 898s na.rm = FALSE 898s rowMads(): 898s colMads(): 898s na.rm = FALSE 898s rowMads(): 898s colMads(): 898s na.rm = TRUE 898s rowMads(): 898s colMads(): 898s na.rm = TRUE 898s rowMads(): 898s colMads(): 898s na.rm = FALSE 898s rowMads(): 898s colMads(): 898s na.rm = FALSE 898s rowMads(): 898s colMads(): 898s na.rm = TRUE 898s rowMads(): 898s colMads(): 898s na.rm = TRUE 898s rowMads(): 898s colMads(): 898s > 898s > 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # All NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + tx <- t(x) 898s + # Row/column ranges 898s + for (na.rm in c(FALSE, TRUE)) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + cat("na.rm = ", na.rm, "\n", sep = "") 898s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 898s + if (na.rm) r0[is.na(r0)] <- NaN 898s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 898s + r2 <- colMads(tx, na.rm = na.rm, useNames = useNames) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + stopifnot(all.equal(r1, r2)) 898s + } 898s + } 898s + } 898s na.rm = FALSE 898s na.rm = FALSE 898s na.rm = TRUE 898s na.rm = TRUE 898s na.rm = FALSE 898s na.rm = FALSE 898s na.rm = TRUE 898s na.rm = TRUE 898s > tx <- NULL 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # A 1x1 matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > x <- matrix(0, nrow = 1L, ncol = 1L) 898s > dimnames <- list("a", "A") 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + tx <- t(x) 898s + # Row/column ranges 898s + for (na.rm in c(FALSE, TRUE)) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + cat("na.rm = ", na.rm, "\n", sep = "") 898s + r0 <- rowMads_R(x, na.rm = na.rm, useNames = useNames) 898s + r1 <- rowMads(x, na.rm = na.rm, useNames = useNames) 898s + r2 <- colMads(tx, na.rm = na.rm, useNames = useNames) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + stopifnot(all.equal(r1, r2)) 898s + } 898s + } 898s + } 898s na.rm = FALSE 898s na.rm = FALSE 898s na.rm = TRUE 898s na.rm = TRUE 898s na.rm = FALSE 898s na.rm = FALSE 898s na.rm = TRUE 898s na.rm = TRUE 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # A 0x0 matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > x <- matrix(double(0), nrow = 0, ncol = 0) 898s > tx <- t(x) 898s > for (na.rm in c(FALSE, TRUE)) { 898s + cat("na.rm = ", na.rm, "\n", sep = "") 898s + r0 <- rowMads_R(x, na.rm = na.rm) 898s + r1 <- rowMads(x, na.rm = na.rm) 898s + r2 <- colMads(tx, na.rm = na.rm) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + stopifnot(all.equal(r2, r0)) 898s + } 898s na.rm = FALSE 898s na.rm = TRUE 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 898s > options(matrixStats.center.onUse = "ignore") 898s > 898s > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + suppressWarnings({ 898s + res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm) 898s + }) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > colMads_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + suppressWarnings({ 898s + res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm) 898s + }) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 898s + center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE) 898s + rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 898s + } 898s > 898s > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 898s + center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE) 898s + colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 898s > storage.mode(x) <- "integer" 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + 898s + count <- 0L 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + count <- count + 1L 898s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 898s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 898s + useNames <- useNames[count %% length(useNames) + 1] 898s + 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowMads, fsure = rowMads_R, 898s + na.rm = na.rm, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowMads_center, fsure = rowMads_R, 898s + na.rm = na.rm, useNames = useNames) 898s + 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colMads, fsure = rowMads_R, 898s + na.rm = na.rm, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colMads_center, fsure = rowMads_R, 898s + na.rm = na.rm, useNames = useNames) 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowMeans_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + res <- rowMeans(x, na.rm = na.rm) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > colMeans_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + res <- colMeans(x, na.rm = na.rm) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > for (mode in c("integer", "logical", "double")) { 898s + x <- matrix(-4:4, nrow = 3, ncol = 3) 898s + storage.mode(x) <- mode 898s + if (mode == "double") x <- x + 0.1 898s + 898s + # To check names attribute 898s + dimnames <- list(letters[1:3], LETTERS[1:3]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s + } 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: Single-element matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: Single-element matrix:\n") 898s Special case: Single-element matrix: 898s > for (mode in c("integer", "logical", "double")) { 898s + x <- matrix(1, nrow = 1, ncol = 1) 898s + storage.mode(x) <- mode 898s + 898s + # To check names attribute 898s + dimnames <- list("a", "A") 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: Empty matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: Empty matrix:\n") 898s Special case: Empty matrix: 898s > for (mode in c("integer", "logical", "double")) { 898s + x <- matrix(integer(0), nrow = 0, ncol = 0) 898s + storage.mode(x) <- mode 898s + 898s + y0 <- rowMeans(x, na.rm = FALSE) 898s + y1 <- rowMeans2(x, na.rm = FALSE) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMeans(x, na.rm = FALSE) 898s + y1 <- colMeans2(x, na.rm = FALSE) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: All NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: All NAs:\n") 898s Special case: All NAs: 898s > for (mode in c("integer", "logical", "double")) { 898s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 898s + storage.mode(x) <- mode 898s + 898s + # To check names attribute 898s + dimnames <- list(letters[1:3], LETTERS[1:3]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMeans_R(x, na.rm = TRUE, useNames = useNames) 898s + y1 <- rowMeans2(x, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMeans_R(x, na.rm = TRUE, useNames = useNames) 898s + y1 <- colMeans2(x, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: All NaNs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: All NaNs:\n") 898s Special case: All NaNs: 898s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMeans_R(x, na.rm = TRUE, useNames = useNames) 898s + y1 <- rowMeans2(x, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMeans_R(x, na.rm = TRUE, useNames = useNames) 898s + y1 <- colMeans2(x, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: All Infs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: All Infs:\n") 898s Special case: All Infs: 898s > x <- matrix(Inf, nrow = 3, ncol = 3) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: All -Infs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: All -Infs:\n") 898s Special case: All -Infs: 898s > x <- matrix(-Inf, nrow = 3, ncol = 3) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: Infs and -Infs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: Infs and -Infs:\n") 898s Special case: Infs and -Infs: 898s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:4], LETTERS[1:4]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: NaNs and NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: NaNs and NAs:\n") 898s Special case: NaNs and NAs: 898s > x <- matrix(c(NaN, NA_real_), nrow = 4, ncol = 4) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + str(y0) 898s + stopifnot(all(is.na(y0)), length(unique(y0)) >= 1L) 898s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 898s + str(y1) 898s + stopifnot(all(is.na(y1)), length(unique(y1)) >= 1L) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all(is.na(y0)), length(unique(y0)) == 1L) 898s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all(is.na(y1)), length(unique(y1)) == 1L) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s Named num [1:4] NaN NA NaN NA 898s - attr(*, "names")= chr [1:4] "a" "b" "c" "d" 898s Named num [1:4] NaN NA NaN NA 898s - attr(*, "names")= chr [1:4] "a" "b" "c" "d" 898s num [1:4] NaN NA NaN NA 898s num [1:4] NaN NA NaN NA 898s num [1:4] NaN NA NaN NA 898s num [1:4] NaN NA NaN NA 898s num [1:4] NaN NA NaN NA 898s num [1:4] NaN NA NaN NA 898s > ## NOTE, due to compiler optimization, it is not guaranteed that NA is 898s > ## returned here (as one would expect). NaN might very well be returned, 898s > ## when both NA and NaN are involved. This is an accepted feature in R, 898s > ## which is documented in help("is.nan"). See also 898s > ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 898s > ## Thus, we cannot guarantee that y1 is identical to y0. 898s > 898s > 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: Integer overflow with ties 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: Integer overflow with ties:\n") 898s Special case: Integer overflow with ties: 898s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMeans_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMeans2(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Consistency checks 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > set.seed(1) 898s > 898s > cat("Consistency checks:\n") 898s Consistency checks: 898s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 898s > for (kk in seq_len(n_sims)) { 898s + cat("Random test #", kk, "\n", sep = "") 898s + 898s + # Simulate data in a matrix of any shape 898s + dim <- sample(50:200, size = 2) 898s + n <- prod(dim) 898s + x <- rnorm(n, sd = 100) 898s + dim(x) <- dim 898s + 898s + # Add NAs? 898s + if ((kk %% 4) %in% c(3, 0)) { 898s + cat("Adding NAs\n") 898s + nna <- sample(n, size = 1) 898s + na_values <- c(NA_real_, NaN) 898s + t <- sample(na_values, size = nna, replace = TRUE) 898s + x[sample(length(x), size = nna)] <- t 898s + } 898s + 898s + # Mode? 898s + modes <- "double" 898s + if ((kk %% 4) %in% c(2, 0)) { 898s + modes <- c("integer", "logical") 898s + } 898s + 898s + for (mode in modes) { 898s + if (mode != "double") { 898s + cat(sprintf("Coercing from %s to %s\n", storage.mode(x), mode)) 898s + storage.mode(x) <- mode 898s + } 898s + 898s + na.rm <- sample(c(TRUE, FALSE), size = 1) 898s + 898s + # rowMeans2(): 898s + y0 <- rowMeans(x, na.rm = na.rm) 898s + y1 <- rowMeans2(x, na.rm = na.rm) 898s + stopifnot(all.equal(y1, y0)) 898s + y2 <- colMeans2(t(x), na.rm = na.rm) 898s + stopifnot(all.equal(y2, y0)) 898s + 898s + # colMeans2(): 898s + y0 <- colMeans(x, na.rm = na.rm) 898s + y1 <- colMeans2(x, na.rm = na.rm) 898s + stopifnot(all.equal(y1, y0)) 898s + y2 <- rowMeans2(t(x), na.rm = na.rm) 898s + stopifnot(all.equal(y2, y0)) 898s + } 898s + } # for (kk ...) 898s Random test #1 898s Random test #2 898s Coercing from double to integer 898s Coercing from integer to logical 898s Random test #3 898s Adding NAs 898s Random test #4 898s Adding NAs 898s Coercing from double to integer 898s Coercing from integer to logical 898s Random test #5 898s Random test #6 898s Coercing from double to integer 898s Coercing from integer to logical 898s Random test #7 898s Adding NAs 898s Random test #8 898s Adding NAs 898s Coercing from double to integer 898s Coercing from integer to logical 898s Random test #9 898s Random test #10 898s Coercing from double to integer 898s Coercing from integer to logical 898s Random test #11 898s Adding NAs 898s Random test #12 898s Adding NAs 898s Coercing from double to integer 898s Coercing from integer to logical 898s Random test #13 898s Random test #14 898s Coercing from double to integer 898s Coercing from integer to logical 898s Random test #15 898s Adding NAs 898s Random test #16 898s Adding NAs 898s Coercing from double to integer 898s Coercing from integer to logical 898s Random test #17 898s Random test #18 898s Coercing from double to integer 898s Coercing from integer to logical 898s Random test #19 898s Adding NAs 898s Random test #20 898s Adding NAs 898s Coercing from double to integer 898s Coercing from integer to logical 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowMeans_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + res <- rowMeans(x, na.rm = na.rm) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 898s > storage.mode(x) <- "integer" 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + 898s + count <- 0L 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + count <- count + 1L 898s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 898s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 898s + useNames <- useNames[count %% length(useNames) + 1] 898s + 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowMeans2, fsure = rowMeans_R, 898s + na.rm = na.rm, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colMeans2, fsure = rowMeans_R, 898s + na.rm = na.rm, useNames = useNames) 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + res <- apply(x, MARGIN = 2L, FUN = median, na.rm = na.rm) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: Non-ties 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: Non-ties:\n") 898s Special case: Non-ties: 898s > for (mode in c("integer", "double")) { 898s + x <- matrix(1:9 + 0.1, nrow = 3, ncol = 3) 898s + storage.mode(x) <- mode 898s + 898s + # To check names attribute 898s + dimnames <- list(letters[1:3], LETTERS[1:3]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: Ties 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: Ties:\n") 898s Special case: Ties: 898s > for (mode in c("integer", "double")) { 898s + x <- matrix(1:16 + 0.1, nrow = 4, ncol = 4) 898s + storage.mode(x) <- mode 898s + 898s + # To check names attribute 898s + dimnames <- list(letters[1:4], LETTERS[1:4]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: Single-element matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: Single-element matrix:\n") 898s Special case: Single-element matrix: 898s > for (mode in c("integer", "double")) { 898s + x <- matrix(1, nrow = 1, ncol = 1) 898s + storage.mode(x) <- mode 898s + 898s + # To check names attribute 898s + dimnames <- list("a", "A") 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: Empty matrix 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: Empty matrix:\n") 898s Special case: Empty matrix: 898s > for (mode in c("integer", "double")) { 898s + x <- matrix(integer(0), nrow = 0, ncol = 0) 898s + storage.mode(x) <- mode 898s + 898s + y0 <- rowMedians_R(x, na.rm = FALSE) 898s + y1 <- rowMedians(x, na.rm = FALSE) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMedians_R(x, na.rm = FALSE) 898s + y1 <- colMedians(x, na.rm = FALSE) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: All NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: All NAs:\n") 898s Special case: All NAs: 898s > for (mode in c("integer", "double")) { 898s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 898s + storage.mode(x) <- mode 898s + 898s + # To check names attribute 898s + dimnames <- list(letters[1:3], LETTERS[1:3]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMedians_R(x, na.rm = TRUE, useNames = useNames) 898s + y1 <- rowMedians(x, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMedians_R(x, na.rm = TRUE, useNames = useNames) 898s + y1 <- colMedians(x, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: All NaNs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: All NaNs:\n") 898s Special case: All NaNs: 898s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMedians_R(x, na.rm = TRUE, useNames = useNames) 898s + y1 <- rowMedians(x, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMedians_R(x, na.rm = TRUE, useNames = useNames) 898s + y1 <- colMedians(x, na.rm = TRUE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: All Infs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: All Infs:\n") 898s Special case: All Infs: 898s > x <- matrix(Inf, nrow = 3, ncol = 3) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: All -Infs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: All -Infs:\n") 898s Special case: All -Infs: 898s > x <- matrix(-Inf, nrow = 3, ncol = 3) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: Infs and -Infs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: Infs and -Infs:\n") 898s Special case: Infs and -Infs: 898s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:4], LETTERS[1:4]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special case: Integer overflow with ties 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > cat("Special case: Integer overflow with ties:\n") 898s Special case: Integer overflow with ties: 898s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- rowMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + 898s + y0 <- colMedians_R(x, na.rm = FALSE, useNames = useNames) 898s + y1 <- colMedians(x, na.rm = FALSE, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + } 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Consistency checks 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > set.seed(1) 898s > 898s > cat("Consistency checks:\n") 898s Consistency checks: 898s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 898s > for (kk in seq_len(n_sims)) { 898s + cat("Random test #", kk, "\n", sep = "") 898s + 898s + # Simulate data in a matrix of any shape 898s + dim <- sample(50:200, size = 2) 898s + n <- prod(dim) 898s + x <- rnorm(n, sd = 100) 898s + dim(x) <- dim 898s + 898s + # Add NAs? 898s + if ((kk %% 4) %in% c(3, 0)) { 898s + cat("Adding NAs\n") 898s + nna <- sample(n, size = 1) 898s + na_values <- c(NA_real_, NaN) 898s + t <- sample(na_values, size = nna, replace = TRUE) 898s + x[sample(length(x), size = nna)] <- t 898s + } 898s + 898s + # Integer or double? 898s + if ((kk %% 4) %in% c(2, 0)) { 898s + cat("Coercing to integers\n") 898s + storage.mode(x) <- "integer" 898s + } 898s + 898s + na.rm <- sample(c(TRUE, FALSE), size = 1) 898s + 898s + # rowMedians(): 898s + y0 <- rowMedians_R(x, na.rm = na.rm) 898s + y1 <- rowMedians(x, na.rm = na.rm) 898s + stopifnot(all.equal(y1, y0)) 898s + y2 <- colMedians(t(x), na.rm = na.rm) 898s + stopifnot(all.equal(y2, y0)) 898s + 898s + # colMedians(): 898s + y0 <- colMedians_R(x, na.rm = na.rm) 898s + y1 <- colMedians(x, na.rm = na.rm) 898s + stopifnot(all.equal(y1, y0)) 898s + y2 <- rowMedians(t(x), na.rm = na.rm) 898s + stopifnot(all.equal(y2, y0)) 898s + } # for (kk ...) 898s Random test #1 898s Random test #2 898s Coercing to integers 898s Random test #3 898s Adding NAs 898s Random test #4 898s Adding NAs 898s Coercing to integers 898s Random test #5 898s Random test #6 898s Coercing to integers 898s Random test #7 898s Adding NAs 898s Random test #8 898s Adding NAs 898s Coercing to integers 898s Random test #9 898s Random test #10 898s Coercing to integers 898s Random test #11 898s Adding NAs 898s Random test #12 898s Adding NAs 898s Coercing to integers 898s Random test #13 898s Random test #14 898s Coercing to integers 898s Random test #15 898s Adding NAs 898s Random test #16 898s Adding NAs 898s Coercing to integers 898s Random test #17 898s Random test #18 898s Coercing to integers 898s Random test #19 898s Adding NAs 898s Random test #20 898s Adding NAs 898s Coercing to integers 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 898s + res <- apply(x, MARGIN = 2L, FUN = median, na.rm = na.rm) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 898s > storage.mode(x) <- "integer" 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + 898s + count <- 0L 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + count <- count + 1L 898s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 898s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 898s + useNames <- useNames[count %% length(useNames) + 1] 898s + 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowMedians, fsure = rowMedians_R, 898s + na.rm = na.rm, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colMedians, fsure = rowMedians_R, 898s + na.rm = na.rm, useNames = useNames) 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > library("stats") 898s > 898s > asWhich <- function(probs, max) { 898s + idx <- as.integer(round(probs * max)) 898s + if (idx < 1L) { 898s + idx <- 1L 898s + } else if (idx > max) { 898s + idx <- max 898s + } 898s + idx 898s + } # asWhich() 898s > 898s > rowOrderStats_R <- function(x, probs, ..., useNames = NA) { 898s + ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L) 898s + 898s + # Remove Attributes 898s + if (is.na(useNames) || !useNames || length(ans) == 0L) attributes(ans) <- NULL 898s + ans 898s + } # rowOrderStats_R() 898s > 898s > 898s > set.seed(1) 898s > 898s > 898s > # Simulate data in a matrix of any shape 898s > nrow <- 60L 898s > ncol <- 30L 898s > x <- rnorm(nrow * ncol) 898s > dim(x) <- c(nrow, ncol) 898s > probs <- 0.3 898s > which <- asWhich(probs, max = ncol) 898s > 898s > y0 <- rowOrderStats_R(x, probs = probs) 898s > y1 <- rowOrderStats(x, which = which) 898s > stopifnot(all.equal(y1, y0)) 898s > y2 <- colOrderStats(t(x), which = which) 898s > stopifnot(all.equal(y2, y0)) 898s > 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Consistency checks 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("integer", "double")) { 898s + cat("Consistency checks without NAs:\n") 898s + for (kk in 1:3) { 898s + cat("Random test #", kk, "\n", sep = "") 898s + 898s + # Simulate data in a matrix of any shape 898s + nrow <- sample(20L, size = 1L) 898s + ncol <- sample(20L, size = 1L) 898s + x <- rnorm(nrow * ncol) 898s + dim(x) <- c(nrow, ncol) 898s + 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + probs <- runif(1) 898s + which <- asWhich(probs, max = ncol) 898s + 898s + y0 <- rowOrderStats_R(x, probs = probs) 898s + y1 <- rowOrderStats(x, which = which) 898s + stopifnot(all.equal(y1, y0)) 898s + y2 <- colOrderStats(t(x), which = which) 898s + stopifnot(all.equal(y2, y0)) 898s + } # for (kk in ...) 898s + } # for (mode ...) 898s Consistency checks without NAs: 898s Random test #1 898s mode: integer 898s int [1:14, 1:6] 0 0 1 0 2 -1 1 0 0 0 ... 898s Random test #2 898s mode: integer 898s int [1:8, 1:13] 0 0 1 -2 0 0 0 0 1 0 ... 898s Random test #3 898s mode: integer 898s int [1:20, 1:17] 0 0 0 0 1 0 1 0 0 -1 ... 898s Consistency checks without NAs: 898s Random test #1 898s mode: double 898s num [1:9, 1:5] -1.4286 -0.00386 -0.70456 -0.29242 -0.49607 ... 898s Random test #2 898s mode: double 898s num [1:11, 1:20] -0.796 0.482 -0.952 0.5 1.242 ... 898s Random test #3 898s mode: double 898s num [1:7, 1:18] 1.553 -2.405 0.167 -0.403 -1.746 ... 898s > 898s > 898s > # Check names attribute 898s > x <- matrix(1:9 + 0.1, nrow = 3L, ncol = 3L) 898s > 898s > probs <- runif(1) 898s > which <- asWhich(probs, max = ncol(x)) 898s > 898s > dimnames <- list(letters[1:3], LETTERS[1:3]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowOrderStats_R(x, probs = probs, useNames = useNames) 898s + y1 <- rowOrderStats(x, which = which, useNames = useNames) 898s + stopifnot(all.equal(y1, y0)) 898s + y2 <- colOrderStats(t(x), which = which, useNames = useNames) 898s + stopifnot(all.equal(y2, y0)) 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowOrderStats_R <- function(x, probs, ..., useNames = NA) { 898s + ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L) 898s + 898s + # Remove Attributes 898s + if (is.na(useNames) || !useNames || length(ans) == 0L) attributes(ans) <- NULL 898s + ans 898s + } # rowOrderStats_R() 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 898s > storage.mode(x) <- "integer" 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > probs <- 0.3 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + if (is.null(cols)) which <- round(probs * ncol(x)) 898s + else { 898s + xxrows <- rows 898s + suppressWarnings({ 898s + xx <- tryCatch(x[, cols, drop = FALSE], error = function(c) "error") 898s + if (identical(xx, "error")) which <- 0L 898s + else which <- round(probs * ncol(xx)) 898s + }) 898s + } 898s + if (which == 0L) next 898s + 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowOrderStats, fsure = rowOrderStats_R, 898s + which = which, probs = probs, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colOrderStats, fsure = rowOrderStats_R, 898s + which = which, probs = probs, useNames = useNames) 898s + } 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = NA) { 898s + res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > all.equal.na <- function(target, current, ...) { 898s + # Computations involving NaN may return NaN or NA, cf. ?is.nan 898s + current[is.nan(current)] <- NA_real_ 898s + target[is.nan(target)] <- NA_real_ 898s + all.equal(target, current, ...) 898s + } 898s > 898s > for (mode in c("integer", "double")) { 898s + # Missing values 898s + x <- matrix(c(1, NA, NaN, 1, 1, 0, 1, 0), nrow = 4, ncol = 2) 898s + cat("mode: ", mode, "\n", sep = "") 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # To check names attribute 898s + dimnames <- list(letters[1:4], LETTERS[1:2]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + y0 <- rowProds_R(x, na.rm = TRUE, useNames = useNames) 898s + print(y0) 898s + y1 <- rowProds(x, na.rm = TRUE, useNames = useNames) 898s + print(y1) 898s + y2 <- colProds(t(x), na.rm = TRUE, useNames = useNames) 898s + print(y2) 898s + stopifnot(all.equal(y1, y0)) 898s + stopifnot(all.equal(y2, y1)) 898s + 898s + # Missing values 898s + y0 <- rowProds_R(x, na.rm = FALSE, useNames = useNames) 898s + print(y0) 898s + y1 <- rowProds(x, na.rm = FALSE, useNames = useNames) 898s + print(y1) 898s + y2 <- colProds(t(x), na.rm = FALSE, useNames = useNames) 898s + print(y2) 898s + stopifnot(all.equal(y1, y0)) 898s + stopifnot(all.equal(y2, y1)) 898s + 898s + # "Empty" rows 898s + y0 <- rowProds_R(x[integer(0), , drop = FALSE], na.rm = FALSE, useNames = useNames) 898s + print(y0) 898s + y1 <- rowProds(x[integer(0), , drop = FALSE], na.rm = FALSE, useNames = useNames) 898s + print(y1) 898s + y2 <- colProds(t(x[integer(0), , drop = FALSE]), na.rm = FALSE, useNames = useNames) 898s + print(y2) 898s + stopifnot(all.equal.na(y1, y0)) 898s + stopifnot(all.equal(y2, y1)) 898s + stopifnot(length(y1) == 0L) 898s + 898s + # Using product() 898s + y1 <- rowProds(x, method = "expSumLog", na.rm = FALSE, useNames = useNames) 898s + print(y1) 898s + y2 <- colProds(t(x), method = "expSumLog", na.rm = FALSE, useNames = useNames) 898s + print(y2) 898s + stopifnot(all.equal(y2, y1)) 898s + } 898s + } 898s + } # for (mode ...) 898s mode: integer 898s int [1:4, 1:2] 1 NA NA 1 1 0 1 0 898s a b c d 898s 1 0 1 0 898s a b c d 898s 1 0 1 0 898s a b c d 898s 1 0 1 0 898s a b c d 898s 1 NA NA 0 898s a b c d 898s 1 NA NA 0 898s a b c d 898s 1 NA NA 0 898s numeric(0) 898s numeric(0) 898s numeric(0) 898s a b c d 898s 1 NA NA 0 898s a b c d 898s 1 NA NA 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s numeric(0) 898s numeric(0) 898s numeric(0) 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s numeric(0) 898s numeric(0) 898s numeric(0) 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s numeric(0) 898s numeric(0) 898s numeric(0) 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s mode: double 898s num [1:4, 1:2] 1 NA NaN 1 1 0 1 0 898s a b c d 898s 1 0 1 0 898s a b c d 898s 1 0 1 0 898s a b c d 898s 1 0 1 0 898s a b c d 898s 1 NA NaN 0 898s a b c d 898s 1 NA NaN 0 898s a b c d 898s 1 NA NaN 0 898s numeric(0) 898s numeric(0) 898s numeric(0) 898s a b c d 898s 1 NA NA 0 898s a b c d 898s 1 NA NA 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 NA NaN 0 898s [1] 1 NA NaN 0 898s [1] 1 NA NaN 0 898s numeric(0) 898s numeric(0) 898s numeric(0) 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 NA NaN 0 898s [1] 1 NA NaN 0 898s [1] 1 NA NaN 0 898s numeric(0) 898s numeric(0) 898s numeric(0) 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 0 1 0 898s [1] 1 NA NaN 0 898s [1] 1 NA NaN 0 898s [1] 1 NA NaN 0 898s numeric(0) 898s numeric(0) 898s numeric(0) 898s [1] 1 NA NA 0 898s [1] 1 NA NA 0 898s > 898s > 898s > # Bug report 2012-06-25 898s > x <- matrix(c(1, 1, 1, 1, 1, 0, 1, 0), nrow = 4, ncol = 2) 898s > y0 <- rowProds_R(x) 898s > print(y0) 898s [1] 1 0 1 0 898s > y1 <- rowProds(x) 898s > print(y1) 898s [1] 1 0 1 0 898s > y2 <- colProds(t(x)) 898s > print(y2) 898s [1] 1 0 1 0 898s > stopifnot(all.equal.na(y1, y0)) 898s > stopifnot(all.equal.na(y1, x[, 1] * x[, 2])) 898s > stopifnot(all.equal.na(y2, y1)) 898s > # Check names attribute 898s > dimnames(x) <- dimnames 898s > y0 <- rowProds_R(x, useNames = TRUE) 898s > print(y0) 898s a b c d 898s 1 0 1 0 898s > y1 <- rowProds(x, useNames = TRUE) 898s > print(y1) 898s a b c d 898s 1 0 1 0 898s > y2 <- colProds(t(x), useNames = TRUE) 898s > print(y2) 898s a b c d 898s 1 0 1 0 898s > stopifnot(all.equal.na(y1, y0)) 898s > stopifnot(all.equal.na(y1, x[, 1] * x[, 2])) 898s > stopifnot(all.equal.na(y2, y1)) 898s > 898s > # Bug report 2014-03-25 ("all rows contains a zero") 898s > x <- matrix(c(0, 1, 1, 0), nrow = 2, ncol = 2) 898s > # To check names attribute 898s > dimnames <- list(letters[1:2], LETTERS[1:2]) 898s > y0 <- rowProds_R(x) 898s > print(y0) 898s [1] 0 0 898s > y1 <- rowProds(x) 898s > print(y1) 898s [1] 0 0 898s > y2 <- colProds(t(x)) 898s > print(y2) 898s [1] 0 0 898s > stopifnot(all.equal.na(y1, y0)) 898s > stopifnot(all.equal.na(y1, c(0, 0))) 898s > stopifnot(all.equal.na(y2, y1)) 898s > # Check names attribute 898s > dimnames(x) <- dimnames 898s > y0 <- rowProds_R(x, useNames = TRUE) 898s > print(y0) 898s a b 898s 0 0 898s > y1 <- rowProds(x, useNames = TRUE) 898s > print(y1) 898s a b 898s 0 0 898s > y2 <- colProds(t(x), useNames = TRUE) 898s > print(y2) 898s a b 898s 0 0 898s > stopifnot(all.equal.na(y1, y0)) 898s > stopifnot(all.equal.na(y2, y1)) 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = NA) { 898s + res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 898s > storage.mode(x) <- "integer" 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:6], LETTERS[1:6]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + for (na.rm in c(TRUE, FALSE)) { 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowProds, fsure = rowProds_R, 898s + method = "expSumLog", 898s + FUN = product, na.rm = na.rm, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colProds, fsure = rowProds_R, 898s + method = "expSumLog", 898s + FUN = product, na.rm = na.rm, useNames = useNames) 898s + } 898s + } 898s + } 898s + } 898s + } 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > ## Create isFALSE() if running on an old version of R 898s > if (!exists("isFALSE", mode="function")) { 898s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 898s + } 898s > 898s > rowQuantiles_R <- function(x, probs = c(0, 0.25, 0.50, 0.75, 1), na.rm = FALSE, drop = TRUE, type = 7L, ..., useNames = NA) { 898s + q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) { 898s + if (!na.rm && any(is.na(x))) { 898s + na_value <- NA_real_ 898s + if (type != 7L) storage.mode(na_value) <- storage.mode(x) 898s + rep(na_value, times = length(probs)) 898s + } else { 898s + as.vector(quantile(x, probs = probs, na.rm = na.rm, type = type, names = FALSE, ...)) 898s + } 898s + }, probs = probs, na.rm = na.rm) 898s + 898s + if (!is.null(dim(q))) q <- t(q) 898s + else dim(q) <- c(nrow(x), length(probs)) 898s + 898s + colnames(q) <- matrixStats:::quantile_probs_names(probs) 898s + rownames(q) <- rownames(x) 898s + if (isFALSE(useNames)) dimnames(q) <- NULL 898s + 898s + if (drop) q <- drop(q) 898s + q 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Test with multiple quantiles 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + x <- matrix(1:40 + 0.1, nrow = 8, ncol = 5) 898s + storage.mode(x) <- mode 898s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 898s + str(x) 898s + 898s + probs <- c(0, 0.5, 1) 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames) 898s + print(q0) 898s + q1 <- rowQuantiles(x, probs = probs, useNames = useNames) 898s + print(q1) 898s + ## FIXME: Workaround for R (< 3.0.0) 898s + if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q1) <- storage.mode(q0) 898s + stopifnot(all.equal(q1, q0)) 898s + q2 <- colQuantiles(t(x), probs = probs, useNames = useNames) 898s + ## FIXME: Workaround for R (< 3.0.0) 898s + if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q2) <- storage.mode(q0) 898s + stopifnot(all.equal(q2, q0)) 898s + } 898s + } 898s + } # for (mode ...) 898s mode: logical 898s logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s 0% 50% 100% 898s a 1 1 1 898s b 1 1 1 898s c 1 1 1 898s d 1 1 1 898s e 1 1 1 898s f 1 1 1 898s g 1 1 1 898s h 1 1 1 898s 0% 50% 100% 898s a 1 1 1 898s b 1 1 1 898s c 1 1 1 898s d 1 1 1 898s e 1 1 1 898s f 1 1 1 898s g 1 1 1 898s h 1 1 1 898s [,1] [,2] [,3] 898s [1,] 1 1 1 898s [2,] 1 1 1 898s [3,] 1 1 1 898s [4,] 1 1 1 898s [5,] 1 1 1 898s [6,] 1 1 1 898s [7,] 1 1 1 898s [8,] 1 1 1 898s [,1] [,2] [,3] 898s [1,] 1 1 1 898s [2,] 1 1 1 898s [3,] 1 1 1 898s [4,] 1 1 1 898s [5,] 1 1 1 898s [6,] 1 1 1 898s [7,] 1 1 1 898s [8,] 1 1 1 898s 0% 50% 100% 898s [1,] 1 1 1 898s [2,] 1 1 1 898s [3,] 1 1 1 898s [4,] 1 1 1 898s [5,] 1 1 1 898s [6,] 1 1 1 898s [7,] 1 1 1 898s [8,] 1 1 1 898s 0% 50% 100% 898s [1,] 1 1 1 898s [2,] 1 1 1 898s [3,] 1 1 1 898s [4,] 1 1 1 898s [5,] 1 1 1 898s [6,] 1 1 1 898s [7,] 1 1 1 898s [8,] 1 1 1 898s [,1] [,2] [,3] 898s [1,] 1 1 1 898s [2,] 1 1 1 898s [3,] 1 1 1 898s [4,] 1 1 1 898s [5,] 1 1 1 898s [6,] 1 1 1 898s [7,] 1 1 1 898s [8,] 1 1 1 898s [,1] [,2] [,3] 898s [1,] 1 1 1 898s [2,] 1 1 1 898s [3,] 1 1 1 898s [4,] 1 1 1 898s [5,] 1 1 1 898s [6,] 1 1 1 898s [7,] 1 1 1 898s [8,] 1 1 1 898s mode: integer 898s int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s 0% 50% 100% 898s a 1 17 33 898s b 2 18 34 898s c 3 19 35 898s d 4 20 36 898s e 5 21 37 898s f 6 22 38 898s g 7 23 39 898s h 8 24 40 898s 0% 50% 100% 898s a 1 17 33 898s b 2 18 34 898s c 3 19 35 898s d 4 20 36 898s e 5 21 37 898s f 6 22 38 898s g 7 23 39 898s h 8 24 40 898s [,1] [,2] [,3] 898s [1,] 1 17 33 898s [2,] 2 18 34 898s [3,] 3 19 35 898s [4,] 4 20 36 898s [5,] 5 21 37 898s [6,] 6 22 38 898s [7,] 7 23 39 898s [8,] 8 24 40 898s [,1] [,2] [,3] 898s [1,] 1 17 33 898s [2,] 2 18 34 898s [3,] 3 19 35 898s [4,] 4 20 36 898s [5,] 5 21 37 898s [6,] 6 22 38 898s [7,] 7 23 39 898s [8,] 8 24 40 898s 0% 50% 100% 898s [1,] 1 17 33 898s [2,] 2 18 34 898s [3,] 3 19 35 898s [4,] 4 20 36 898s [5,] 5 21 37 898s [6,] 6 22 38 898s [7,] 7 23 39 898s [8,] 8 24 40 898s 0% 50% 100% 898s [1,] 1 17 33 898s [2,] 2 18 34 898s [3,] 3 19 35 898s [4,] 4 20 36 898s [5,] 5 21 37 898s [6,] 6 22 38 898s [7,] 7 23 39 898s [8,] 8 24 40 898s [,1] [,2] [,3] 898s [1,] 1 17 33 898s [2,] 2 18 34 898s [3,] 3 19 35 898s [4,] 4 20 36 898s [5,] 5 21 37 898s [6,] 6 22 38 898s [7,] 7 23 39 898s [8,] 8 24 40 898s [,1] [,2] [,3] 898s [1,] 1 17 33 898s [2,] 2 18 34 898s [3,] 3 19 35 898s [4,] 4 20 36 898s [5,] 5 21 37 898s [6,] 6 22 38 898s [7,] 7 23 39 898s [8,] 8 24 40 898s mode: double 898s num [1:8, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 898s 0% 50% 100% 898s a 1.1 17.1 33.1 898s b 2.1 18.1 34.1 898s c 3.1 19.1 35.1 898s d 4.1 20.1 36.1 898s e 5.1 21.1 37.1 898s f 6.1 22.1 38.1 898s g 7.1 23.1 39.1 898s h 8.1 24.1 40.1 898s 0% 50% 100% 898s a 1.1 17.1 33.1 898s b 2.1 18.1 34.1 898s c 3.1 19.1 35.1 898s d 4.1 20.1 36.1 898s e 5.1 21.1 37.1 898s f 6.1 22.1 38.1 898s g 7.1 23.1 39.1 898s h 8.1 24.1 40.1 898s [,1] [,2] [,3] 898s [1,] 1.1 17.1 33.1 898s [2,] 2.1 18.1 34.1 898s [3,] 3.1 19.1 35.1 898s [4,] 4.1 20.1 36.1 898s [5,] 5.1 21.1 37.1 898s [6,] 6.1 22.1 38.1 898s [7,] 7.1 23.1 39.1 898s [8,] 8.1 24.1 40.1 898s [,1] [,2] [,3] 898s [1,] 1.1 17.1 33.1 898s [2,] 2.1 18.1 34.1 898s [3,] 3.1 19.1 35.1 898s [4,] 4.1 20.1 36.1 898s [5,] 5.1 21.1 37.1 898s [6,] 6.1 22.1 38.1 898s [7,] 7.1 23.1 39.1 898s [8,] 8.1 24.1 40.1 898s 0% 50% 100% 898s [1,] 1.1 17.1 33.1 898s [2,] 2.1 18.1 34.1 898s [3,] 3.1 19.1 35.1 898s [4,] 4.1 20.1 36.1 898s [5,] 5.1 21.1 37.1 898s [6,] 6.1 22.1 38.1 898s [7,] 7.1 23.1 39.1 898s [8,] 8.1 24.1 40.1 898s 0% 50% 100% 898s [1,] 1.1 17.1 33.1 898s [2,] 2.1 18.1 34.1 898s [3,] 3.1 19.1 35.1 898s [4,] 4.1 20.1 36.1 898s [5,] 5.1 21.1 37.1 898s [6,] 6.1 22.1 38.1 898s [7,] 7.1 23.1 39.1 898s [8,] 8.1 24.1 40.1 898s [,1] [,2] [,3] 898s [1,] 1.1 17.1 33.1 898s [2,] 2.1 18.1 34.1 898s [3,] 3.1 19.1 35.1 898s [4,] 4.1 20.1 36.1 898s [5,] 5.1 21.1 37.1 898s [6,] 6.1 22.1 38.1 898s [7,] 7.1 23.1 39.1 898s [8,] 8.1 24.1 40.1 898s [,1] [,2] [,3] 898s [1,] 1.1 17.1 33.1 898s [2,] 2.1 18.1 34.1 898s [3,] 3.1 19.1 35.1 898s [4,] 4.1 20.1 36.1 898s [5,] 5.1 21.1 37.1 898s [6,] 6.1 22.1 38.1 898s [7,] 7.1 23.1 39.1 898s [8,] 8.1 24.1 40.1 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Test with a single quantile 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("logical", "integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + x <- matrix(1:40, nrow = 8, ncol = 5) 898s + storage.mode(x) <- mode 898s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 898s + str(x) 898s + 898s + probs <- c(0.5) 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames) 898s + print(q0) 898s + q1 <- rowQuantiles(x, probs = probs, useNames = useNames) 898s + ## FIXME: Workaround for R (< 3.0.0) 898s + if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q1) <- storage.mode(q0) 898s + print(q1) 898s + stopifnot(all.equal(q1, q0)) 898s + q2 <- colQuantiles(t(x), probs = probs, useNames = useNames) 898s + ## FIXME: Workaround for R (< 3.0.0) 898s + if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q2) <- storage.mode(q0) 898s + stopifnot(all.equal(q2, q0)) 898s + } 898s + } 898s + } # for (mode ...) 898s mode: logical 898s logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s a b c d e f g h 898s 1 1 1 1 1 1 1 1 898s a b c d e f g h 898s 1 1 1 1 1 1 1 1 898s [1] 1 1 1 1 1 1 1 1 898s [1] 1 1 1 1 1 1 1 1 898s [1] 1 1 1 1 1 1 1 1 898s [1] 1 1 1 1 1 1 1 1 898s [1] 1 1 1 1 1 1 1 1 898s [1] 1 1 1 1 1 1 1 1 898s mode: integer 898s int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s a b c d e f g h 898s 17 18 19 20 21 22 23 24 898s a b c d e f g h 898s 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s mode: double 898s num [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s a b c d e f g h 898s 17 18 19 20 21 22 23 24 898s a b c d e f g h 898s 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s [1] 17 18 19 20 21 22 23 24 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Consistency checks 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > set.seed(1) 898s > 898s > probs <- seq(from = 0, to = 1, by = 0.25) 898s > 898s > cat("Consistency checks:\n") 898s Consistency checks: 898s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 6L else 24L 898s > for (kk in seq_len(n_sims)) { 898s + cat("Random test #", kk, "\n", sep = "") 898s + 898s + # Simulate data in a matrix of any shape 898s + dim <- sample(20:60, size = 2L) 898s + n <- prod(dim) 898s + x <- rnorm(n, sd = 100) 898s + dim(x) <- dim 898s + dimnames <- lapply(dim(x), FUN = function(n) rep(letters, length.out = n)) 898s + 898s + # Add NAs? 898s + has_na <- ((kk %% 2) == 0L) 898s + if (has_na) { 898s + cat("Adding NAs\n") 898s + nna <- sample(n, size = 1) 898s + na_values <- c(NA_real_, NaN) 898s + t <- sample(na_values, size = nna, replace = TRUE) 898s + x[sample(length(x), size = nna)] <- t 898s + } 898s + 898s + # Logical, integer, or double? 898s + mode <- "numeric" 898s + if ((kk %% 6) %in% 1:2) { 898s + cat("Coercing to logical\n") 898s + mode <- "logical" 898s + } else if ((kk %% 6) %in% 3:4) { 898s + cat("Coercing to integers\n") 898s + mode <- "integer" 898s + } 898s + storage.mode(x) <- mode 898s + 898s + str(x) 898s + 898s + # rowQuantiles(): 898s + for (type in 1:9) { 898s + cat(sprintf("type=%d, has_na=%s:\n", type, has_na)) 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + q0 <- rowQuantiles_R(x, probs = probs, na.rm = has_na, type = type, useNames = useNames) 898s + q1 <- rowQuantiles(x, probs = probs, na.rm = has_na, type = type, useNames = useNames) 898s + ## FIXME: Workaround for R (< 3.0.0) 898s + if (getRversion() < "3.0.0" && mode == "logical" && !has_na && type == 7L) storage.mode(q1) <- storage.mode(q0) 898s + stopifnot(all.equal(q1, q0)) 898s + q2 <- colQuantiles(t(x), probs = probs, na.rm = has_na, type = type, useNames = useNames) 898s + ## FIXME: Workaround for R (< 3.0.0) 898s + if (getRversion() < "3.0.0" && mode == "logical" && !has_na && type == 7L) storage.mode(q2) <- storage.mode(q0) 898s + stopifnot(all.equal(q2, q0)) 898s + } 898s + } 898s + } 898s + } # for (kk ...) 898s Random test #1 898s Coercing to logical 898s logi [1:23, 1:58] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #2 898s Adding NAs 898s Coercing to logical 898s logi [1:58, 1:33] TRUE TRUE TRUE TRUE TRUE NA ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #3 898s Coercing to integers 898s int [1:28, 1:60] 119 -164 115 -129 209 -175 2 -32 120 -28 ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #4 898s Adding NAs 898s Coercing to integers 898s int [1:54, 1:35] 147 11 116 -50 NA -69 132 NA 114 NA ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #5 898s num [1:39, 1:53] 5.94 -27.16 -30.78 173 126.05 ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #6 898s Adding NAs 898s num [1:46, 1:22] 197 -107 15 148 -110 ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #7 898s Coercing to logical 898s logi [1:21, 1:51] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #8 898s Adding NAs 898s Coercing to logical 898s logi [1:33, 1:53] NA NA TRUE TRUE TRUE TRUE ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #9 898s Coercing to integers 898s int [1:53, 1:24] -73 10 -73 -5 44 -107 -100 95 58 -50 ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #10 898s Adding NAs 898s Coercing to integers 898s int [1:44, 1:20] NA -140 NA -57 -252 NA NA 20 NA NA ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #11 898s num [1:54, 1:23] -160.87 74.13 196.08 7.27 4.92 ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #12 898s Adding NAs 898s num [1:59, 1:27] -139.2 -86.3 NA -40.7 NA ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #13 898s Coercing to logical 898s logi [1:53, 1:60] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #14 898s Adding NAs 898s Coercing to logical 898s logi [1:22, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #15 898s Coercing to integers 898s int [1:20, 1:34] 78 -41 183 190 -71 37 0 -4 -86 27 ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #16 898s Adding NAs 898s Coercing to integers 898s int [1:42, 1:37] NA 12 -15 41 -28 17 NA -74 NA NA ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #17 898s num [1:42, 1:29] -50.51 -6.51 -117.59 135.58 226.87 ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #18 898s Adding NAs 898s num [1:57, 1:39] 223 156.8 -44.6 -127.5 -147.7 ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #19 898s Coercing to logical 898s logi [1:52, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #20 898s Adding NAs 898s Coercing to logical 898s logi [1:25, 1:48] NA TRUE NA NA NA NA ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #21 898s Coercing to integers 898s int [1:53, 1:27] 3 -30 203 -49 19 -45 -138 28 46 -44 ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #22 898s Adding NAs 898s Coercing to integers 898s int [1:48, 1:36] -131 NA NA -201 45 -17 NA 57 NA NA ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s Random test #23 898s num [1:23, 1:43] -99.2 -68.8 -86.7 -104.2 48 ... 898s type=1, has_na=FALSE: 898s type=2, has_na=FALSE: 898s type=3, has_na=FALSE: 898s type=4, has_na=FALSE: 898s type=5, has_na=FALSE: 898s type=6, has_na=FALSE: 898s type=7, has_na=FALSE: 898s type=8, has_na=FALSE: 898s type=9, has_na=FALSE: 898s Random test #24 898s Adding NAs 898s num [1:53, 1:29] NaN -67.6 10.8 -88.4 130.1 ... 898s type=1, has_na=TRUE: 898s type=2, has_na=TRUE: 898s type=3, has_na=TRUE: 898s type=4, has_na=TRUE: 898s type=5, has_na=TRUE: 898s type=6, has_na=TRUE: 898s type=7, has_na=TRUE: 898s type=8, has_na=TRUE: 898s type=9, has_na=TRUE: 898s > 898s > 898s > 898s > for (mode in c("logical", "integer", "double")) { 898s + naValue <- NA_real_ 898s + storage.mode(naValue) <- mode 898s + 898s + someValue <- 1 898s + storage.mode(someValue) <- mode 898s + 898s + for (type in 1:9) { 898s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s + # All NA 898s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s + x <- matrix(naValue, nrow = 3L, ncol = 4L) 898s + dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + qr0 <- rowQuantiles_R(x, type = type, useNames = useNames) 898s + 898s + qr <- rowQuantiles(x, type = type, useNames = useNames) 898s + stopifnot(identical(qr, qr0)) 898s + 898s + # x <- matrix(naValue, nrow = 4L, ncol = 3L) 898s + qc <- colQuantiles(t(x), type = type, useNames = useNames) 898s + 898s + stopifnot(identical(qc, qr)) 898s + } 898s + } 898s + 898s + 898s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s + # Empty matrices 898s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s + probs <- c(0, 0.25, 0.75, 1) 898s + x <- matrix(naValue, nrow = 0L, ncol = 0L) 898s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 898s + q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 898s + stopifnot(identical(dim(q), c(nrow(x), length(probs)))) 898s + q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 898s + stopifnot(identical(dim(q), c(ncol(x), length(probs)))) 898s + 898s + x <- matrix(naValue, nrow = 2L, ncol = 0L) 898s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 898s + q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 898s + stopifnot(identical(dim(q), c(nrow(x), length(probs)))) 898s + 898s + x <- matrix(naValue, nrow = 0L, ncol = 2L) 898s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 898s + q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 898s + stopifnot(identical(dim(q), c(ncol(x), length(probs)))) 898s + 898s + 898s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s + # Single column matrices 898s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s + probs <- c(0, 0.25, 0.75, 1) 898s + x <- matrix(someValue, nrow = 2L, ncol = 1L) 898s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 898s + qr <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE) 898s + print(qr) 898s + 898s + x <- matrix(someValue, nrow = 1L, ncol = 2L) 898s + dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 898s + qc <- colQuantiles(x, probs = probs, type = type, useNames = TRUE) 898s + print(qc) 898s + 898s + stopifnot(identical(qc, qr)) 898s + } 898s + } 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s 0% 25% 75% 100% 898s a 1 1 1 1 898s b 1 1 1 1 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > ## Create isFALSE() if running on an old version of R 898s > if (!exists("isFALSE", mode="function")) { 898s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 898s + } 898s > 898s > rowQuantiles_R <- function(x, probs, na.rm = FALSE, drop = TRUE, ..., useNames = NA) { 898s + q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) { 898s + if (!na.rm && any(is.na(x))) { 898s + na_value <- NA_real_ 898s + storage.mode(na_value) <- storage.mode(x) 898s + rep(na_value, times = length(probs)) 898s + 898s + } else { 898s + as.vector(quantile(x, probs = probs, na.rm = na.rm, names = FALSE, ...)) 898s + } 898s + }, probs = probs, na.rm = na.rm) 898s + 898s + if (!is.null(dim(q))) q <- t(q) 898s + else dim(q) <- c(nrow(x), length(probs)) 898s + 898s + colnames(q) <- matrixStats:::quantile_probs_names(probs) 898s + rownames(q) <- rownames(x) 898s + if (isFALSE(useNames)) dimnames(q) <- NULL 898s + 898s + if (drop) q <- drop(q) 898s + q 898s + } 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Subsetted tests 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > source("utils/validateIndicesFramework.R") 898s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 898s > dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)]) 898s > probs <- c(0, 0.25, 0.75, 1) 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + 898s + count <- 0L 898s + for (rows in index_cases) { 898s + for (cols in index_cases) { 898s + count <- count + 1L 898s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 898s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 898s + useNames <- useNames[count %% length(useNames) + 1] 898s + 898s + validateIndicesTestMatrix(x, rows, cols, 898s + ftest = rowQuantiles, fsure = rowQuantiles_R, 898s + probs = probs, na.rm = na.rm, drop = FALSE, useNames = useNames) 898s + validateIndicesTestMatrix(x, rows, cols, 898s + fcoltest = colQuantiles, fsure = rowQuantiles_R, 898s + probs = probs, na.rm = na.rm, drop = FALSE, useNames = useNames) 898s + } 898s + } 898s + } 898s > 898s > 898s 898s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 898s Copyright (C) 2024 The R Foundation for Statistical Computing 898s Platform: s390x-ibm-linux-gnu 898s 898s R is free software and comes with ABSOLUTELY NO WARRANTY. 898s You are welcome to redistribute it under certain conditions. 898s Type 'license()' or 'licence()' for distribution details. 898s 898s R is a collaborative project with many contributors. 898s Type 'contributors()' for more information and 898s 'citation()' on how to cite R or R packages in publications. 898s 898s Type 'demo()' for some demos, 'help()' for on-line help, or 898s 'help.start()' for an HTML browser interface to help. 898s Type 'q()' to quit R. 898s 898s > library("matrixStats") 898s > 898s > rowMins_R <- function(x, ..., useNames = NA) { 898s + suppressWarnings({ 898s + res <- apply(x, MARGIN = 1L, FUN = min, ...) 898s + }) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } # rowMins_R() 898s > 898s > rowMaxs_R <- function(x, ..., useNames = NA) { 898s + suppressWarnings({ 898s + res <- apply(x, MARGIN = 1L, FUN = max, ...) 898s + }) 898s + if (is.na(useNames) || !useNames) names(res) <- NULL 898s + res 898s + } # rowMaxs_R() 898s > 898s > rowRanges_R <- function(x, ..., useNames = NA) { 898s + suppressWarnings({ 898s + ans <- t(apply(x, MARGIN = 1L, FUN = range, ...)) 898s + }) 898s + 898s + # Preserve rownames attribute 898s + dim <- c(dim(x)[1], 2L) 898s + if (!isTRUE(all.equal(dim(ans), dim))) { 898s + dim(ans) <- dim 898s + rownames <- rownames(x) 898s + if (!is.null(dimnames)) rownames(ans) <- rownames 898s + } 898s + if (is.na(useNames) || !useNames) dimnames(ans) <- NULL 898s + ans 898s + } # rowRanges_R() 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # With and without some NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + 898s + for (add_na in c(FALSE, TRUE)) { 898s + cat("add_na = ", add_na, "\n", sep = "") 898s + 898s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 898s + if (add_na) { 898s + x[3:7, c(2, 4)] <- NA_real_ 898s + } 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # To check names attribute 898s + dimnames <- list(letters[1:10], LETTERS[1:5]) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + # Row/column extremes 898s + for (na.rm in c(FALSE, TRUE)) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + cat("na.rm = ", na.rm, "\n", sep = "") 898s + 898s + # Ranges 898s + cat("range:\n") 898s + r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames) 898s + r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames) 898s + r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + 898s + # Min 898s + cat("min:\n") 898s + m0 <- rowMins_R(x, na.rm = na.rm, useNames = useNames) 898s + m1 <- rowMins(x, na.rm = na.rm, useNames = useNames) 898s + m2 <- colMins(t(x), na.rm = na.rm, useNames = useNames) 898s + stopifnot(all.equal(m1, m2)) 898s + stopifnot(all.equal(m1, m0)) 898s + 898s + # Max 898s + cat("max:\n") 898s + m0 <- rowMaxs_R(x, na.rm = na.rm, useNames = useNames) 898s + m1 <- rowMaxs(x, na.rm = na.rm, useNames = useNames) 898s + m2 <- colMaxs(t(x), na.rm = na.rm, useNames = useNames) 898s + stopifnot(all.equal(m1, m2)) 898s + stopifnot(all.equal(m1, m0)) 898s + } 898s + } 898s + } 898s + } # for (add_na ...) 898s + } # for (mode ...) 898s mode: integer 898s add_na = FALSE 898s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s add_na = TRUE 898s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s mode: double 898s add_na = FALSE 898s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s add_na = TRUE 898s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = FALSE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s na.rm = TRUE 898s range: 898s min: 898s max: 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # All NAs 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > for (mode in c("integer", "double")) { 898s + cat("mode: ", mode, "\n", sep = "") 898s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 898s + storage.mode(x) <- mode 898s + str(x) 898s + 898s + # Test with and without dimnames on x 898s + for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (na.rm in c(FALSE, TRUE)) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + cat("na.rm = ", na.rm, "\n", sep = "") 898s + r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames) 898s + r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames) 898s + r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames) 898s + stopifnot(all.equal(r1, r2)) 898s + stopifnot(all.equal(r1, r0)) 898s + } 898s + } 898s + } 898s + } # for (mode ...) 898s mode: integer 898s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 898s na.rm = FALSE 898s na.rm = FALSE 898s na.rm = TRUE 898s na.rm = TRUE 898s na.rm = FALSE 898s na.rm = FALSE 898s na.rm = TRUE 898s na.rm = TRUE 898s mode: double 898s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 898s na.rm = FALSE 898s na.rm = FALSE 898s na.rm = TRUE 898s na.rm = TRUE 898s na.rm = FALSE 898s na.rm = FALSE 898s na.rm = TRUE 898s na.rm = TRUE 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Special cases 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Nx0 matrix 898s > x <- matrix(double(0L), nrow = 5L, ncol = 0L) 898s > r0 <- rowRanges_R(x) 898s > #r1 <- rowRanges(x) 898s > #r_truth <- matrix(c(Inf, -Inf), nrow = nrow(x), ncol = 2L, byrow = TRUE) 898s > #stopifnot(all.equal(r1, r_truth)) 898s > 898s > # 0xN matrix 898s > x <- t(x) 898s > #r1 <- colRanges(x) 898s > #stopifnot(all.equal(r1, r_truth)) 898s > 898s > # Nx1 matrix 898s > x <- matrix(1:5, nrow = 5L, ncol = 1L) 898s > # To check names attribute 898s > dimnames <- list(letters[1:5], "A") 898s > r1 <- rowRanges(x) 898s > r_truth <- matrix(1:5, nrow = nrow(x), ncol = 2L, byrow = FALSE) 898s > stopifnot(all.equal(r1, r_truth)) 898s > # Check names attribute 898s > dimnames(x) <- dimnames 898s > r0 <- rowRanges_R(x, useNames = TRUE) 898s > r1 <- rowRanges(x, useNames = TRUE) 898s > stopifnot(all.equal(r1, r0)) 898s > dimnames(x) <- NULL 898s > 898s > # 1xN matrix 898s > x <- t(x) 898s > r1 <- colRanges(x) 898s > stopifnot(all.equal(r1, r_truth)) 898s > # Check names attribute 898s > dimnames(x) <- list("a", LETTERS[1:5]) 898s > r1 <- colRanges(x, useNames = TRUE) 898s > stopifnot(identical(rownames(r1), colnames(x))) 898s > 898s > 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > # Additional tests with NA_integer_, NA_real, NaN, -Inf, +Inf 898s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 898s > x <- matrix(1:12, nrow = 4L, ncol = 3L) 898s > 898s > na_list <- list( 898s + "integer" = matrix(1:12, nrow = 4L, ncol = 3L), 898s + "integer w/ NA" = matrix(NA_integer_, nrow = 4L, ncol = 3L), 898s + "real" = matrix(as.double(1:12), nrow = 4L, ncol = 3L), 898s + "real w/ NA" = matrix(NA_real_, nrow = 4L, ncol = 3L) 898s + ) 898s > 898s > na <- na_list[["real"]] 898s > na[2, 2] <- NA 898s > na_list[["real + NA cell"]] <- na 898s > 898s > na <- na_list[["real"]] 898s > na[2, ] <- NA 898s > na_list[["real + NA row"]] <- na 898s > 898s > na <- na_list[["real"]] 898s > na[2, ] <- NaN 898s > na_list[["real + NaN row"]] <- na 898s > 898s > na <- na_list[["real"]] 898s > na[2, 2] <- Inf 898s > na_list[["real + Inf cell"]] <- na 898s > 898s > na <- na_list[["real"]] 898s > na[2, ] <- Inf 898s > na_list[["real + Inf row"]] <- na 898s > 898s > na <- na_list[["real"]] 898s > na[2, 2] <- NaN 898s > na_list[["real + NaN cell"]] <- na 898s > 898s > na <- na_list[["real w/ NA"]] 898s > na[2, 2] <- NaN 898s > na_list[["real w/ NA + NaN cell"]] <- na 898s > 898s > na <- na_list[["real w/ NA"]] 898s > na[2, ] <- NaN 898s > na_list[["real w/ NA + NaN row"]] <- na 898s > 898s > # To check names attribute 898s > dimnames <- list(letters[1:4], LETTERS[1:3]) 898s > 898s > # Test with and without dimnames on x 898s > for (setDimnames in c(TRUE, FALSE)) { 898s + if (setDimnames) dimnames(x) <- dimnames 898s + else dimnames(x) <- NULL 898s + for (na.rm in c(FALSE, TRUE)) { 898s + for (name in names(na_list)) { 898s + # Check names attribute 898s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 898s + na <- na_list[[name]] 898s + cat(sprintf("%s (%s) w/ na.rm = %s:\n", name, typeof(na), na.rm)) 898s + print(na) 898s + 898s + cat(" min:\n") 898s + y0 <- rowMins_R(na, na.rm = na.rm, useNames = useNames) 898s + str(y0) 898s + y1 <- rowMins(na, na.rm = na.rm, useNames = useNames) 898s + str(y1) 898s + stopifnot(all.equal(y1, y0)) 898s + y1c <- colMins(t(na), na.rm = na.rm, useNames = useNames) 898s + str(y1c) 898s + stopifnot(all.equal(y1c, y1)) 898s + 898s + cat(" max:\n") 898s + y0 <- rowMaxs_R(na, na.rm = na.rm, useNames = useNames) 898s + str(y0) 898s + y1 <- rowMaxs(na, na.rm = na.rm, useNames = useNames) 898s + str(y1) 898s + stopifnot(all.equal(y1, y0)) 898s + y1c <- colMaxs(t(na), na.rm = na.rm, useNames = useNames) 898s + str(y1c) 898s + stopifnot(all.equal(y1c, y1)) 898s + 898s + cat(" range:\n") 898s + y0 <- rowRanges_R(na, na.rm = na.rm, useNames = useNames) 898s + str(y0) 898s + y1 <- rowRanges(na, na.rm = na.rm, useNames = useNames) 898s + str(y1) 898s + stopifnot(all.equal(y1, y0)) 898s + y1c <- colRanges(t(na), na.rm = na.rm, useNames = useNames) 898s + str(y1c) 898s + stopifnot(all.equal(y1c, y1)) 898s + } 898s + } # for (name ...) 898s + } # for (na.rm ...) 898s + } 898s integer (integer) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s max: 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s range: 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s integer (integer) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s max: 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s range: 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s integer w/ NA (integer) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s max: 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s range: 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s integer w/ NA (integer) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s max: 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s range: 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s real (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real w/ NA (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s max: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s range: 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s real w/ NA (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s max: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s range: 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s real + NA cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NA 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s max: 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s range: 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s real + NA cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NA 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s max: 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s range: 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s real + NA row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NA NA NA 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s max: 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s range: 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s real + NA row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NA NA NA 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s max: 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s range: 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s real + NaN row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NaN NaN NaN 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s max: 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s range: 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s real + NaN row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NaN NaN NaN 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s max: 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s range: 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s real + Inf cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 Inf 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s real + Inf cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 Inf 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s real + Inf row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] Inf Inf Inf 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + Inf row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] Inf Inf Inf 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + NaN cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NaN 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s max: 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s range: 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s real + NaN cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NaN 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s max: 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s range: 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NaN NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s max: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s range: 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NaN NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s max: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s range: 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s real w/ NA + NaN row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NaN NaN NaN 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s max: 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s range: 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s real w/ NA + NaN row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NaN NaN NaN 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s max: 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s range: 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s integer (integer) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s max: 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s range: 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s integer (integer) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s max: 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s range: 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s integer w/ NA (integer) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s integer w/ NA (integer) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s real (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real w/ NA (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s real w/ NA (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s real + NA cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NA 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real + NA cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NA 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real + NA row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NA NA NA 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + NA row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NA NA NA 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + NaN row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NaN NaN NaN 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + NaN row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NaN NaN NaN 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + Inf cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 Inf 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s real + Inf cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 Inf 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s real + Inf row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] Inf Inf Inf 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + Inf row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] Inf Inf Inf 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + NaN cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NaN 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real + NaN cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NaN 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NaN NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NaN NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s real w/ NA + NaN row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NaN NaN NaN 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s real w/ NA + NaN row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NaN NaN NaN 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s integer (integer) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s max: 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s range: 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s integer (integer) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s max: 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s range: 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s integer w/ NA (integer) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s max: 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s range: 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s integer w/ NA (integer) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s max: 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s int [1:4] NA NA NA NA 898s range: 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s int [1:4, 1:2] NA NA NA NA NA NA NA NA 898s real (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real w/ NA (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s max: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s range: 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s real w/ NA (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s max: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s range: 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s real + NA cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NA 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s max: 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s range: 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s real + NA cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NA 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s max: 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s range: 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s real + NA row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NA NA NA 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s max: 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s range: 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s real + NA row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NA NA NA 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s num [1:4] 1 NA 3 4 898s max: 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s num [1:4] 9 NA 11 12 898s range: 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s num [1:4, 1:2] 1 NA 3 4 9 NA 11 12 898s real + NaN row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NaN NaN NaN 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s max: 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s range: 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s real + NaN row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NaN NaN NaN 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s max: 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s range: 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s real + Inf cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 Inf 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s real + Inf cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 Inf 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s real + Inf row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] Inf Inf Inf 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + Inf row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] Inf Inf Inf 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + NaN cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NaN 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s max: 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s range: 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s real + NaN cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NaN 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s num [1:4] 1 NaN 3 4 898s max: 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s num [1:4] 9 NaN 11 12 898s range: 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12 898s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NaN NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s max: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s range: 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s real w/ NA + NaN cell (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NaN NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s max: 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s num [1:4] NA NA NA NA 898s range: 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s num [1:4, 1:2] NA NA NA NA NA NA NA NA 898s real w/ NA + NaN row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NaN NaN NaN 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s max: 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s range: 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s real w/ NA + NaN row (double) w/ na.rm = FALSE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NaN NaN NaN 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s max: 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s num [1:4] NA NaN NA NA 898s range: 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s num [1:4, 1:2] NA NaN NA NA NA NaN NA NA 898s integer (integer) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s max: 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s range: 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s integer (integer) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s int [1:4] 1 2 3 4 898s max: 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s int [1:4] 9 10 11 12 898s range: 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s int [1:4, 1:2] 1 2 3 4 9 10 11 12 898s integer w/ NA (integer) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s integer w/ NA (integer) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s real (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 6 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real w/ NA (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s real w/ NA (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] NA NA NA 898s [2,] NA NA NA 898s [3,] NA NA NA 898s [4,] NA NA NA 898s min: 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s num [1:4] Inf Inf Inf Inf 898s max: 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s num [1:4] -Inf -Inf -Inf -Inf 898s range: 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 898s real + NA cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NA 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real + NA cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NA 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s num [1:4] 9 10 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s num [1:4, 1:2] 1 2 3 4 9 10 11 12 898s real + NA row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NA NA NA 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + NA row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NA NA NA 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + NaN row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NaN NaN NaN 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + NaN row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] NaN NaN NaN 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s num [1:4] 9 -Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + Inf cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 Inf 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s real + Inf cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 Inf 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s num [1:4, 1:2] 1 2 3 4 9 ... 898s real + Inf row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] Inf Inf Inf 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + Inf row (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] Inf Inf Inf 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s num [1:4] 1 Inf 3 4 898s max: 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s num [1:4] 9 Inf 11 12 898s range: 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s num [1:4, 1:2] 1 Inf 3 4 9 ... 898s real + NaN cell (double) w/ na.rm = TRUE: 898s [,1] [,2] [,3] 898s [1,] 1 5 9 898s [2,] 2 NaN 10 898s [3,] 3 7 11 898s [4,] 4 8 12 898s min: 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 898s num [1:4] 1 2 3 4 899s max: 899s num [1:4] 9 10 11 12 899s num [1:4] 9 10 11 12 899s num [1:4] 9 10 11 12 899s range: 899s num [1:4, 1:2] 1 2 3 4 9 10 11 12 899s num [1:4, 1:2] 1 2 3 4 9 10 11 12 899s num [1:4, 1:2] 1 2 3 4 9 10 11 12 899s real + NaN cell (double) w/ na.rm = TRUE: 899s [,1] [,2] [,3] 899s [1,] 1 5 9 899s [2,] 2 NaN 10 899s [3,] 3 7 11 899s [4,] 4 8 12 899s min: 899s num [1:4] 1 2 3 4 899s num [1:4] 1 2 3 4 899s num [1:4] 1 2 3 4 899s max: 899s num [1:4] 9 10 11 12 899s num [1:4] 9 10 11 12 899s num [1:4] 9 10 11 12 899s range: 899s num [1:4, 1:2] 1 2 3 4 9 10 11 12 899s num [1:4, 1:2] 1 2 3 4 9 10 11 12 899s num [1:4, 1:2] 1 2 3 4 9 10 11 12 899s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 899s [,1] [,2] [,3] 899s [1,] NA NA NA 899s [2,] NA NaN NA 899s [3,] NA NA NA 899s [4,] NA NA NA 899s min: 899s num [1:4] Inf Inf Inf Inf 899s num [1:4] Inf Inf Inf Inf 899s num [1:4] Inf Inf Inf Inf 899s max: 899s num [1:4] -Inf -Inf -Inf -Inf 899s num [1:4] -Inf -Inf -Inf -Inf 899s num [1:4] -Inf -Inf -Inf -Inf 899s range: 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s real w/ NA + NaN cell (double) w/ na.rm = TRUE: 899s [,1] [,2] [,3] 899s [1,] NA NA NA 899s [2,] NA NaN NA 899s [3,] NA NA NA 899s [4,] NA NA NA 899s min: 899s num [1:4] Inf Inf Inf Inf 899s num [1:4] Inf Inf Inf Inf 899s num [1:4] Inf Inf Inf Inf 899s max: 899s num [1:4] -Inf -Inf -Inf -Inf 899s num [1:4] -Inf -Inf -Inf -Inf 899s num [1:4] -Inf -Inf -Inf -Inf 899s range: 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s real w/ NA + NaN row (double) w/ na.rm = TRUE: 899s [,1] [,2] [,3] 899s [1,] NA NA NA 899s [2,] NaN NaN NaN 899s [3,] NA NA NA 899s [4,] NA NA NA 899s min: 899s num [1:4] Inf Inf Inf Inf 899s num [1:4] Inf Inf Inf Inf 899s num [1:4] Inf Inf Inf Inf 899s max: 899s num [1:4] -Inf -Inf -Inf -Inf 899s num [1:4] -Inf -Inf -Inf -Inf 899s num [1:4] -Inf -Inf -Inf -Inf 899s range: 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s real w/ NA + NaN row (double) w/ na.rm = TRUE: 899s [,1] [,2] [,3] 899s [1,] NA NA NA 899s [2,] NaN NaN NaN 899s [3,] NA NA NA 899s [4,] NA NA NA 899s min: 899s num [1:4] Inf Inf Inf Inf 899s num [1:4] Inf Inf Inf Inf 899s num [1:4] Inf Inf Inf Inf 899s max: 899s num [1:4] -Inf -Inf -Inf -Inf 899s num [1:4] -Inf -Inf -Inf -Inf 899s num [1:4] -Inf -Inf -Inf -Inf 899s range: 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s num [1:4, 1:2] Inf Inf Inf Inf -Inf ... 899s > 899s 899s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 899s Copyright (C) 2024 The R Foundation for Statistical Computing 899s Platform: s390x-ibm-linux-gnu 899s 899s R is free software and comes with ABSOLUTELY NO WARRANTY. 899s You are welcome to redistribute it under certain conditions. 899s Type 'license()' or 'licence()' for distribution details. 899s 899s R is a collaborative project with many contributors. 899s Type 'contributors()' for more information and 899s 'citation()' on how to cite R or R packages in publications. 899s 899s Type 'demo()' for some demos, 'help()' for on-line help, or 899s 'help.start()' for an HTML browser interface to help. 899s Type 'q()' to quit R. 899s 899s > library("matrixStats") 899s > 899s > rowMins_R <- function(x, ..., useNames = NA) { 899s + suppressWarnings({ 899s + res <- apply(x, MARGIN = 1L, FUN = min, ...) 899s + }) 899s + if (is.na(useNames) || !useNames) names(res) <- NULL 899s + res 899s + } # rowMins_R() 899s > 899s > rowMaxs_R <- function(x, ..., useNames = NA) { 899s + suppressWarnings({ 899s + res <- apply(x, MARGIN = 1L, FUN = max, ...) 899s + }) 899s + if (is.na(useNames) || !useNames) names(res) <- NULL 899s + res 899s + } # rowMaxs_R() 899s > 899s > rowRanges_R <- function(x, ..., useNames = NA) { 899s + suppressWarnings({ 899s + ans <- t(apply(x, MARGIN = 1L, FUN = range, ...)) 899s + }) 899s + 899s + # Preserve rownames attribute 899s + dim <- c(dim(x)[1], 2L) 899s + if (!isTRUE(all.equal(dim(ans), dim))) { 899s + dim(ans) <- dim 899s + rownames <- rownames(x) 899s + if (!is.null(dimnames)) rownames(ans) <- rownames 899s + } 899s + if (is.na(useNames) || !useNames) dimnames(ans) <- NULL 899s + ans 899s + } # rowRanges_R() 899s > 899s > 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > # Subsetted tests 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > source("utils/validateIndicesFramework.R") 899s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 899s > storage.mode(x) <- "integer" 899s > 899s > # To check rownames/names attributes 899s > dimnames <- list(letters[1:6], LETTERS[1:6]) 899s > 899s > # Test with and without dimnames on x 899s > for (setDimnames in c(TRUE, FALSE)) { 899s + if (setDimnames) dimnames(x) <- dimnames 899s + else dimnames(x) <- NULL 899s + 899s + count <- 0L 899s + for (rows in index_cases) { 899s + for (cols in index_cases) { 899s + count <- count + 1L 899s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 899s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 899s + useNames <- useNames[count %% length(useNames) + 1] 899s + 899s + validateIndicesTestMatrix(x, rows, cols, 899s + ftest = rowRanges, fsure = rowRanges_R, 899s + na.rm = na.rm, useNames = useNames) 899s + validateIndicesTestMatrix(x, rows, cols, 899s + ftest = rowMins, fsure = rowMins_R, 899s + na.rm = na.rm, useNames = useNames) 899s + validateIndicesTestMatrix(x, rows, cols, 899s + ftest = rowMaxs, fsure = rowMaxs_R, 899s + na.rm = na.rm, useNames = useNames) 899s + 899s + validateIndicesTestMatrix(x, rows, cols, 899s + fcoltest = colRanges, fsure = rowRanges_R, 899s + na.rm = na.rm, useNames = useNames) 899s + validateIndicesTestMatrix(x, rows, cols, 899s + fcoltest = colMins, fsure = rowMins_R, 899s + na.rm = na.rm, useNames = useNames) 899s + validateIndicesTestMatrix(x, rows, cols, 899s + fcoltest = colMaxs, fsure = rowMaxs_R, 899s + na.rm = na.rm, useNames = useNames) 899s + } 899s + } 899s + } 899s > 899s 899s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 899s Copyright (C) 2024 The R Foundation for Statistical Computing 899s Platform: s390x-ibm-linux-gnu 899s 899s R is free software and comes with ABSOLUTELY NO WARRANTY. 899s You are welcome to redistribute it under certain conditions. 899s Type 'license()' or 'licence()' for distribution details. 899s 899s R is a collaborative project with many contributors. 899s Type 'contributors()' for more information and 899s 'citation()' on how to cite R or R packages in publications. 899s 899s Type 'demo()' for some demos, 'help()' for on-line help, or 899s 'help.start()' for an HTML browser interface to help. 899s Type 'q()' to quit R. 899s 899s > library("matrixStats") 899s > 899s > dense_rank <- function(x) match(x, table = sort(unique(x))) 899s > 899s > rowRanks_R <- function(x, ties.method, ..., useNames = NA) { 899s + if (ties.method == "dense") { 899s + res <- t(apply(x, MARGIN = 1L, FUN = dense_rank)) 899s + } else { 899s + res <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", ties.method = ties.method)) 899s + } 899s + 899s + # Preserve dimnames attribute? 899s + dim(res) <- dim(x) 899s + dimnames(res) <- if (isTRUE(useNames)) dimnames(x) else NULL 899s + 899s + res 899s + } 899s > 899s > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = NA) { 899s + if (ties.method == "dense") { 899s + res <- t(apply(x, MARGIN = 2L, FUN = dense_rank)) 899s + } else { 899s + res <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method)) 899s + } 899s + 899s + # Preserve dimnames attribute? 899s + tx <- t(x) 899s + dim(res) <- dim(tx) 899s + dimnames(res) <- if (isTRUE(useNames)) dimnames(tx) else NULL 899s + 899s + if (preserveShape) res <- t(res) 899s + res 899s + } 899s > 899s > set.seed(1) 899s > 899s > cat("Consistency checks:\n") 899s Consistency checks: 899s > xs <- vector("list", length = 4L) 899s > for (kk in 1:4) { 899s + 899s + # Simulate data in a matrix of any shape 899s + dim <- sample(40:80, size = 2L) 899s + n <- prod(dim) 899s + x <- rnorm(n, sd = 10) 899s + dim(x) <- dim 899s + 899s + # Add NAs? 899s + if ((kk %% 4) %in% c(3, 0)) { 899s + cat("Adding NAs\n") 899s + nna <- sample(n, size = 1L) 899s + x[sample(length(x), size = nna)] <- NA_real_ 899s + } 899s + 899s + # Integer or double? 899s + if ((kk %% 4) %in% c(2, 0)) { 899s + cat("Coercing to integers\n") 899s + storage.mode(x) <- "integer" 899s + } 899s + 899s + xs[[kk]] <- x 899s + } # for (kk ...) 899s Coercing to integers 899s Adding NAs 899s Adding NAs 899s Coercing to integers 899s > str(xs) 899s List of 4 899s $ : num [1:43, 1:78] 13.3 12.72 4.15 -15.4 -9.29 ... 899s $ : int [1:46, 1:61] 2 11 -16 -5 19 5 26 -13 1 -9 ... 899s $ : num [1:42, 1:47] NA -22.3 NA NA NA ... 899s $ : int [1:42, 1:78] NA NA NA NA NA NA NA NA NA NA ... 899s > 899s > for (kk in 1:4) { 899s + cat("Random test #", kk, "\n", sep = "") 899s + x <- xs[[kk]] 899s + tx <- t(x) 899s + 899s + for (ties in c("max", "min", "average", "first", "last", "dense")) { 899s + cat(sprintf("ties.method = %s\n", ties)) 899s + # rowRanks(): 899s + y1 <- matrixStats::rowRanks(x, ties.method = ties) 899s + if (ties != "last" || getRversion() >= "3.3.0") { 899s + y2 <- rowRanks_R(x, ties.method = ties) 899s + stopifnot(identical(y1, y2)) 899s + } 899s + 899s + y3 <- matrixStats::colRanks(tx, ties.method = ties) 899s + stopifnot(identical(y1, y3)) 899s + 899s + # colRanks(): 899s + y1 <- matrixStats::colRanks(x, ties.method = ties) 899s + if (ties != "last" || getRversion() >= "3.3.0") { 899s + y2 <- colRanks_R(x, ties.method = ties) 899s + stopifnot(identical(y1, y2)) 899s + } 899s + 899s + y3 <- matrixStats::rowRanks(tx, ties.method = ties) 899s + stopifnot(identical(y1, y3)) 899s + } 899s + } # for (kk ...) 899s Random test #1 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s Random test #2 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s Random test #3 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s Random test #4 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s > 899s > # Note, below we know ties.method %in% c("min", "max", "average") is correct 899s > 899s > cat("Consistency checks for random:\n") 899s Consistency checks for random: 899s > tolerance <- 0.1 899s > nsamples <- 10000 899s > for (kk in 1:4) { 899s + cat("Random test #", kk, "\n", sep = "") 899s + x <- xs[[kk]] 899s + tx <- t(x) 899s + 899s + for (ties in c("random")) { 899s + cat(sprintf("ties.method = %s\n", ties)) 899s + 899s + ## rowRanks(): 899s + y0 <- rowRanks_R(x, ties.method = ties) 899s + y1 <- matrixStats::rowRanks(x, ties.method = ties) 899s + 899s + ## Assert symmetric rank differences 899s + d <- y1 - y0 899s + stopifnot(all(rowSums(d) == 0, na.rm = TRUE)) 899s + 899s + ## Assert within [min, max] 899s + y2min <- matrixStats::rowRanks(x, ties.method = "min") 899s + y2max <- matrixStats::rowRanks(x, ties.method = "max") 899s + stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE)) 899s + ## Assert near average 899s + y1list <- replicate(nsamples, matrixStats::rowRanks(x, ties.method = ties), simplify = FALSE) 899s + y1mean <- Reduce(`+`, y1list) / nsamples 899s + y2avg <- matrixStats::rowRanks(x, ties.method = "average") 899s + stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE)) 899s + 899s + ## colRanks(): 899s + y0 <- colRanks_R(x, ties.method = ties) 899s + y1 <- matrixStats::colRanks(x, ties.method = ties) 899s + 899s + ## Assert symmetric rank differences 899s + d <- y1 - y0 899s + stopifnot(all(rowSums(d) == 0, na.rm = TRUE)) 899s + 899s + ## Assert within [min, max] 899s + y2min <- matrixStats::colRanks(x, ties.method = "min") 899s + y2max <- matrixStats::colRanks(x, ties.method = "max") 899s + stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE)) 899s + y1list <- replicate(nsamples, matrixStats::colRanks(x, ties.method = ties), simplify = FALSE) 899s + y1mean <- Reduce(`+`, y1list) / nsamples 899s + ## Assert near average 899s + y2avg <- matrixStats::colRanks(x, ties.method = "average") 899s + stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE)) 899s + } 899s + } # for (kk ...) 899s Random test #1 899s ties.method = random 899s Random test #2 899s ties.method = random 899s Random test #3 899s ties.method = random 899s Random test #4 899s ties.method = random 899s > 899s > 899s > ## Exception handling 899s > x <- matrix(1:12, nrow = 3L, ncol = 4L) 899s > y <- try(rowRanks(x, ties.method = "unknown"), silent = TRUE) 899s > stopifnot(inherits(y, "try-error")) 899s > 899s > y <- try(colRanks(x, ties.method = "unknown"), silent = TRUE) 899s > stopifnot(inherits(y, "try-error")) 899s > 899s > dimnames <- list(letters[1:3], LETTERS[1:4]) 899s > for (mode in c("integer", "double")){ 899s + storage.mode(x) <- mode 899s + # Test with and without dimnames on x 899s + for (setDimnames in c(TRUE, FALSE)) { 899s + if (setDimnames) dimnames(x) <- dimnames 899s + else dimnames(x) <- NULL 899s + # Check names attribute 899s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 899s + for (ties in c("max", "min", "average", "first", "last", "dense", "random")) { 899s + cat(sprintf("ties.method = %s\n", ties)) 899s + # rowRanks(): 899s + y1 <- matrixStats::rowRanks(x, ties.method = ties, useNames = useNames) 899s + if (ties != "last" || getRversion() >= "3.3.0") { 899s + y2 <- rowRanks_R(x, ties.method = ties, useNames = useNames) 899s + stopifnot(identical(y1, y2)) 899s + } 899s + 899s + y3 <- matrixStats::colRanks(t(x), ties.method = ties, useNames = useNames) 899s + stopifnot(identical(y1, y3)) 899s + 899s + # colRanks(): 899s + y1 <- matrixStats::colRanks(x, ties.method = ties, useNames = useNames) 899s + if (ties != "last" || getRversion() >= "3.3.0") { 899s + y2 <- colRanks_R(x, ties.method = ties, useNames = useNames) 899s + stopifnot(identical(y1, y2)) 899s + } 899s + 899s + y3 <- matrixStats::rowRanks(t(x), ties.method = ties, useNames = useNames) 899s + stopifnot(identical(y1, y3)) 899s + 899s + # Check preserveShape 899s + y1 <- matrixStats::colRanks(x, ties.method = ties, preserveShape = TRUE, useNames = useNames) 899s + if (ties != "last" || getRversion() >= "3.3.0") { 899s + y2 <- colRanks_R(x, ties.method = ties, preserveShape = TRUE, useNames = useNames) 899s + stopifnot(identical(y1, y2)) 899s + } 899s + } 899s + } 899s + } 899s + } 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s ties.method = random 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s ties.method = random 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s ties.method = random 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s ties.method = random 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s ties.method = random 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s ties.method = random 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s ties.method = random 899s ties.method = max 899s ties.method = min 899s ties.method = average 899s ties.method = first 899s ties.method = last 899s ties.method = dense 899s ties.method = random 899s > 899s 899s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 899s Copyright (C) 2024 The R Foundation for Statistical Computing 899s Platform: s390x-ibm-linux-gnu 899s 899s R is free software and comes with ABSOLUTELY NO WARRANTY. 899s You are welcome to redistribute it under certain conditions. 899s Type 'license()' or 'licence()' for distribution details. 899s 899s R is a collaborative project with many contributors. 899s Type 'contributors()' for more information and 899s 'citation()' on how to cite R or R packages in publications. 899s 899s Type 'demo()' for some demos, 'help()' for on-line help, or 899s 'help.start()' for an HTML browser interface to help. 899s Type 'q()' to quit R. 899s 899s > library("matrixStats") 899s > 899s > rowRanks_R <- function(x, ties.method = "average", ..., useNames = NA) { 899s + ans <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", 899s + ties.method = ties.method)) 899s + 899s + # Preserve dimnames attribute? 899s + dim(ans) <- dim(x) 899s + dimnames(ans) <- if (isTRUE(useNames)) dimnames(x) else NULL 899s + 899s + ans 899s + } 899s > 899s > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = NA) { 899s + ans <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method)) 899s + 899s + # Preserve dimnames attribute? 899s + tx <- t(x) 899s + dim(ans) <- dim(tx) 899s + dimnames(ans) <- if (isTRUE(useNames)) dimnames(tx) else NULL 899s + 899s + if (preserveShape) ans <- t(ans) 899s + ans 899s + } 899s > 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > # Subsetted tests 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > source("utils/validateIndicesFramework.R") 899s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 899s > storage.mode(x) <- "integer" 899s > 899s > # To check dimnames attribute 899s > dimnames <- list(letters[1:6], LETTERS[1:6]) 899s > 899s > colRanks_R_t <- function(x, rows, cols, ..., useNames = NA) { 899s + t(colRanks(t(x), rows = cols, cols = rows, preserveShape = TRUE, ..., useNames = useNames)) 899s + } 899s > 899s > # Test with and without dimnames on x 899s > for (setDimnames in c(TRUE, FALSE)) { 899s + if (setDimnames) dimnames(x) <- dimnames 899s + else dimnames(x) <- NULL 899s + 899s + count <- 0L 899s + for (rows in index_cases) { 899s + for (cols in index_cases) { 899s + count <- count + 1L 899s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 899s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 899s + useNames <- useNames[count %% length(useNames) + 1] 899s + 899s + validateIndicesTestMatrix(x, rows, cols, 899s + ftest = rowRanks, fsure = rowRanks_R, 899s + ties.method = "average", useNames = useNames) 899s + 899s + validateIndicesTestMatrix(x, rows, cols, 899s + ftest = colRanks_R_t, fsure = rowRanks_R, 899s + ties.method = "average", useNames = useNames) 899s + 899s + for (perserveShape in c(TRUE, FALSE)) { 899s + validateIndicesTestMatrix(x, rows, cols, 899s + ftest = colRanks, fsure = colRanks_R, 899s + ties.method = "average", perserveShape = perserveShape, 899s + useNames = useNames) 899s + } 899s + } 899s + } 899s + } 899s > 899s 899s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 899s Copyright (C) 2024 The R Foundation for Statistical Computing 899s Platform: s390x-ibm-linux-gnu 899s 899s R is free software and comes with ABSOLUTELY NO WARRANTY. 899s You are welcome to redistribute it under certain conditions. 899s Type 'license()' or 'licence()' for distribution details. 899s 899s R is a collaborative project with many contributors. 899s Type 'contributors()' for more information and 899s 'citation()' on how to cite R or R packages in publications. 899s 899s Type 'demo()' for some demos, 'help()' for on-line help, or 899s 'help.start()' for an HTML browser interface to help. 899s Type 'q()' to quit R. 899s 899s > library("matrixStats") 899s > 899s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 899s > options(matrixStats.center.onUse = "ignore") 899s > 899s > ## Create isFALSE() if running on an old version of R 899s > if (!exists("isFALSE", mode="function")) { 899s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 899s + } 899s > 899s > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 899s + suppressWarnings({ 899s + sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm) 899s + }) 899s + stopifnot(!any(is.infinite(sigma))) 899s + 899s + # Keep naming support consistency same as rowSds() 899s + if (is.null(center) || ncol(x) <= 1L) { 899s + if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL 899s + } 899s + else if (isFALSE(useNames)) names(sigma) <- NULL 899s + sigma 899s + } 899s > 899s > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 899s + suppressWarnings({ 899s + sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm) 899s + }) 899s + stopifnot(!any(is.infinite(sigma))) 899s + 899s + # Keep naming support consistency same as colSds() 899s + if (is.null(center) || nrow(x) <= 1L) { 899s + if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL 899s + } 899s + if (isFALSE(useNames)) names(sigma) <- NULL 899s + sigma 899s + } 899s > 899s > 899s > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 899s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 899s + sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 899s + stopifnot(!any(is.infinite(sigma))) 899s + sigma 899s + } 899s > 899s > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 899s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 899s + sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 899s + stopifnot(!any(is.infinite(sigma))) 899s + sigma 899s + } 899s > 899s > 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > # With and without some NAs 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > for (mode in c("integer", "double")) { 899s + for (add_na in c(FALSE, TRUE)) { 899s + cat("add_na = ", add_na, "\n", sep = "") 899s + 899s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 899s + if (add_na) { 899s + x[3:7, c(2, 4)] <- NA_real_ 899s + } 899s + cat("mode: ", mode, "\n", sep = "") 899s + storage.mode(x) <- mode 899s + str(x) 899s + 899s + # To check names attribute 899s + dimnames <- list(letters[1:10], LETTERS[1:5]) 899s + 899s + # Test with and without dimnames on x 899s + for (setDimnames in c(TRUE, FALSE)) { 899s + if (setDimnames) dimnames(x) <- dimnames 899s + else dimnames(x) <- NULL 899s + # Row/column ranges 899s + for (na.rm in c(FALSE, TRUE)) { 899s + # Check names attribute 899s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 899s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 899s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 899s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 899s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 899s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 899s + stopifnot(all.equal(r1, r2)) 899s + stopifnot(all.equal(r1, r0)) 899s + stopifnot(all.equal(r2, r0)) 899s + stopifnot(all.equal(r1b, r2b)) 899s + stopifnot( 899s + !any(is.infinite(r1)), 899s + !any(is.infinite(r2)), 899s + !any(is.infinite(r1b)), 899s + !any(is.infinite(r2b)) 899s + ) 899s + } 899s + } 899s + } 899s + } # for (add_na ...) 899s + } 899s add_na = FALSE 899s mode: integer 899s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 899s add_na = TRUE 899s mode: integer 899s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 899s add_na = FALSE 899s mode: double 899s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 899s add_na = TRUE 899s mode: double 899s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 899s > 899s > 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > # All NAs 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > for (mode in c("integer", "double")) { 899s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 899s + cat("mode: ", mode, "\n", sep = "") 899s + storage.mode(x) <- mode 899s + str(x) 899s + 899s + # Test with and without dimnames on x 899s + for (setDimnames in c(TRUE, FALSE)) { 899s + if (setDimnames) dimnames(x) <- dimnames 899s + else dimnames(x) <- NULL 899s + # Row/column ranges 899s + for (na.rm in c(FALSE, TRUE)) { 899s + # Check names attribute 899s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 899s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 899s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 899s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 899s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 899s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 899s + stopifnot(all.equal(r1, r2)) 899s + stopifnot(all.equal(r1, r0)) 899s + stopifnot(all.equal(r2, r0)) 899s + stopifnot(all.equal(r1b, r2b)) 899s + stopifnot( 899s + !any(is.infinite(r1)), 899s + !any(is.infinite(r2)), 899s + !any(is.infinite(r1b)), 899s + !any(is.infinite(r2b)) 899s + ) 899s + } 899s + } 899s + } 899s + } 899s mode: integer 899s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 899s mode: double 899s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 899s > 899s > 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > # A 1x1 matrix 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > x <- matrix(0, nrow = 1L, ncol = 1L) 899s > dimnames <- list("a", "A") 899s > for (na.rm in c(FALSE, TRUE)) { 899s + cat("na.rm = ", na.rm, "\n", sep = "") 899s + 899s + # Test with and without dimnames on x 899s + for (setDimnames in c(TRUE, FALSE)) { 899s + if (setDimnames) dimnames(x) <- dimnames 899s + else dimnames(x) <- NULL 899s + # Row/column ranges 899s + for (na.rm in c(FALSE, TRUE)) { 899s + # Check names attribute 899s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 899s + r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames) 899s + r1 <- rowSds(x, na.rm = na.rm, useNames = useNames) 899s + r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames) 899s + r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames) 899s + r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames) 899s + stopifnot(all.equal(r1, r2)) 899s + stopifnot(all.equal(r1, r0)) 899s + stopifnot(all.equal(r2, r0)) 899s + stopifnot(all.equal(r1b, r2b)) 899s + stopifnot( 899s + !any(is.infinite(r1)), 899s + !any(is.infinite(r2)), 899s + !any(is.infinite(r1b)), 899s + !any(is.infinite(r2b)) 899s + ) 899s + } 899s + } 899s + } 899s + } 899s na.rm = FALSE 899s na.rm = TRUE 899s > 899s 899s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 899s Copyright (C) 2024 The R Foundation for Statistical Computing 899s Platform: s390x-ibm-linux-gnu 899s 899s R is free software and comes with ABSOLUTELY NO WARRANTY. 899s You are welcome to redistribute it under certain conditions. 899s Type 'license()' or 'licence()' for distribution details. 899s 899s R is a collaborative project with many contributors. 899s Type 'contributors()' for more information and 899s 'citation()' on how to cite R or R packages in publications. 899s 899s Type 'demo()' for some demos, 'help()' for on-line help, or 899s 'help.start()' for an HTML browser interface to help. 899s Type 'q()' to quit R. 899s 899s > library("matrixStats") 899s > 899s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 899s > options(matrixStats.center.onUse = "ignore") 899s > 899s > ## Create isFALSE() if running on an old version of R 899s > if (!exists("isFALSE", mode="function")) { 899s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 899s + } 899s > 899s > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 899s + suppressWarnings({ 899s + sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm) 899s + }) 899s + stopifnot(!any(is.infinite(sigma))) 899s + 899s + # Keep naming support consistency same as rowSds() 899s + if (is.null(center) || ncol(x) <= 1L) { 899s + if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL 899s + } 899s + else if (isFALSE(useNames)) names(sigma) <- NULL 899s + sigma 899s + } 899s > 899s > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 899s + suppressWarnings({ 899s + sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm) 899s + }) 899s + stopifnot(!any(is.infinite(sigma))) 899s + 899s + # Keep naming support consistency same as colSds() 899s + if (is.null(center) || nrow(x) <= 1L) { 899s + if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL 899s + } 899s + else if (isFALSE(useNames)) names(sigma) <- NULL 899s + sigma 899s + } 899s > 899s > 899s > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 899s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 899s + sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 899s + stopifnot(!any(is.infinite(sigma))) 899s + sigma 899s + } 899s > 899s > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 899s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 899s + sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 899s + stopifnot(!any(is.infinite(sigma))) 899s + sigma 899s + } 899s > 899s > 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > # Subsetted tests 899s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 899s > source("utils/validateIndicesFramework.R") 899s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 899s > storage.mode(x) <- "integer" 899s > 899s > # To check names attribute 899s > dimnames <- list(letters[1:6], LETTERS[1:6]) 899s > 899s > # Test with and without dimnames on x 899s > for (setDimnames in c(TRUE, FALSE)) { 899s + if (setDimnames) dimnames(x) <- dimnames 899s + else dimnames(x) <- NULL 899s + 899s + count <- 0L 899s + for (rows in index_cases) { 899s + for (cols in index_cases) { 899s + count <- count + 1L 899s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 899s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 899s + useNames <- useNames[count %% length(useNames) + 1] 899s + 899s + validateIndicesTestMatrix(x, rows, cols, 899s + ftest = rowSds, fsure = rowSds_R, 899s + na.rm = na.rm, useNames = useNames) 899s + validateIndicesTestMatrix(x, rows, cols, 899s + ftest = rowSds_center, fsure = rowSds_R, 899s + na.rm = na.rm, center = TRUE, useNames = useNames) 899s + 899s + validateIndicesTestMatrix(x, rows, cols, 899s + fcoltest = colSds, fsure = rowSds_R, 899s + na.rm = na.rm, useNames = useNames) 899s + validateIndicesTestMatrix(x, rows, cols, 899s + fcoltest = colSds_center, fsure = rowSds_R, 899s + na.rm = na.rm, center = TRUE, useNames = useNames) 899s + } 899s + } 899s + } 900s > 901s 901s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 901s Copyright (C) 2024 The R Foundation for Statistical Computing 901s Platform: s390x-ibm-linux-gnu 901s 901s R is free software and comes with ABSOLUTELY NO WARRANTY. 901s You are welcome to redistribute it under certain conditions. 901s Type 'license()' or 'licence()' for distribution details. 901s 901s R is a collaborative project with many contributors. 901s Type 'contributors()' for more information and 901s 'citation()' on how to cite R or R packages in publications. 901s 901s Type 'demo()' for some demos, 'help()' for on-line help, or 901s 'help.start()' for an HTML browser interface to help. 901s Type 'q()' to quit R. 901s 901s > library("matrixStats") 901s > 901s > rowSums2_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 901s + ## FIXME: sum() may overflow for integers, whereas 901s + ## base::rowSums() doesn't. What should rowSums2() do? 901s + ## apply(x, MARGIN = 1L, FUN = sum, na.rm = na.rm) 901s + res <- rowSums(x, na.rm = na.rm) 901s + if (is.na(useNames) || !useNames) names(res) <- NULL 901s + res 901s + } 901s > 901s > colSums2_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 901s + ## FIXME: sum() may overflow for integers, whereas 901s + ## base::colSums() doesn't. What should colSums2() do? 901s + ## apply(x, MARGIN = 2L, FUN = sum, na.rm = na.rm) 901s + res <- colSums(x, na.rm = na.rm) 901s + if (is.na(useNames) || !useNames) names(res) <- NULL 901s + res 901s + } 901s > 901s > for (mode in c("integer", "logical", "double")) { 901s + x <- matrix(-4:4, nrow = 3, ncol = 3) 901s + storage.mode(x) <- mode 901s + if (mode == "double") x <- x + 0.1 901s + 901s + # To check names attribute 901s + dimnames <- list(letters[1:3], LETTERS[1:3]) 901s + 901s + # Test with and without dimnames on x 901s + for (setDimnames in c(TRUE, FALSE)) { 901s + if (setDimnames) dimnames(x) <- dimnames 901s + else dimnames(x) <- NULL 901s + # Check names attribute 901s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 901s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + 901s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + } 901s + } 901s + } 901s > 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > # Special case: Single-element matrix 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > cat("Special case: Single-element matrix:\n") 901s Special case: Single-element matrix: 901s > for (mode in c("integer", "logical", "double")) { 901s + x <- matrix(1, nrow = 1, ncol = 1) 901s + storage.mode(x) <- mode 901s + 901s + # To check names attribute 901s + dimnames <- list("a", "A") 901s + 901s + # Test with and without dimnames on x 901s + for (setDimnames in c(TRUE, FALSE)) { 901s + if (setDimnames) dimnames(x) <- dimnames 901s + else dimnames(x) <- NULL 901s + # Check names attribute 901s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 901s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + 901s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + } 901s + } 901s + } 901s > 901s > 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > # Special case: Empty matrix 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > cat("Special case: Empty matrix:\n") 901s Special case: Empty matrix: 901s > for (mode in c("integer", "logical", "double")) { 901s + x <- matrix(integer(0), nrow = 0, ncol = 0) 901s + storage.mode(x) <- mode 901s + 901s + y0 <- rowSums2_R(x, na.rm = FALSE) 901s + y1 <- rowSums2(x, na.rm = FALSE) 901s + stopifnot(all.equal(y1, y0)) 901s + 901s + y0 <- colSums2_R(x, na.rm = FALSE) 901s + y1 <- colSums2(x, na.rm = FALSE) 901s + stopifnot(all.equal(y1, y0)) 901s + } 901s > 901s > 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > # Special case: All NAs 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > cat("Special case: All NAs:\n") 901s Special case: All NAs: 901s > for (mode in c("integer", "logical", "double")) { 901s + x <- matrix(NA_integer_, nrow = 3, ncol = 3) 901s + storage.mode(x) <- mode 901s + 901s + # To check names attribute 901s + dimnames <- list(letters[1:3], LETTERS[1:3]) 901s + 901s + # Test with and without dimnames on x 901s + for (setDimnames in c(TRUE, FALSE)) { 901s + if (setDimnames) dimnames(x) <- dimnames 901s + else dimnames(x) <- NULL 901s + # Check names attribute 901s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 901s + y0 <- rowSums2_R(x, na.rm = TRUE, useNames = useNames) 901s + y1 <- rowSums2(x, na.rm = TRUE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + 901s + y0 <- colSums2_R(x, na.rm = TRUE, useNames = useNames) 901s + y1 <- colSums2(x, na.rm = TRUE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + } 901s + } 901s + } 901s > 901s > 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > # Special case: All NaNs 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > cat("Special case: All NaNs:\n") 901s Special case: All NaNs: 901s > x <- matrix(NA_real_, nrow = 3, ncol = 3) 901s > 901s > # Test with and without dimnames on x 901s > for (setDimnames in c(TRUE, FALSE)) { 901s + if (setDimnames) dimnames(x) <- dimnames 901s + else dimnames(x) <- NULL 901s + # Check names attribute 901s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 901s + y0 <- rowSums2_R(x, na.rm = TRUE, useNames = useNames) 901s + y1 <- rowSums2(x, na.rm = TRUE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + 901s + y0 <- colSums2_R(x, na.rm = TRUE, useNames = useNames) 901s + y1 <- colSums2(x, na.rm = TRUE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + } 901s + } 901s > 901s > 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > # Special case: All Infs 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > cat("Special case: All Infs:\n") 901s Special case: All Infs: 901s > x <- matrix(Inf, nrow = 3, ncol = 3) 901s > 901s > # Test with and without dimnames on x 901s > for (setDimnames in c(TRUE, FALSE)) { 901s + if (setDimnames) dimnames(x) <- dimnames 901s + else dimnames(x) <- NULL 901s + # Check names attribute 901s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 901s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + 901s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + } 901s + } 901s > 901s > 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > # Special case: All -Infs 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > cat("Special case: All -Infs:\n") 901s Special case: All -Infs: 901s > x <- matrix(-Inf, nrow = 3, ncol = 3) 901s > 901s > # Test with and without dimnames on x 901s > for (setDimnames in c(TRUE, FALSE)) { 901s + if (setDimnames) dimnames(x) <- dimnames 901s + else dimnames(x) <- NULL 901s + # Check names attribute 901s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 901s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + 901s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + } 901s + } 901s > 901s > 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > # Special case: Infs and -Infs 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > cat("Special case: Infs and -Infs:\n") 901s Special case: Infs and -Infs: 901s > x <- matrix(c(-Inf, +Inf), nrow = 4, ncol = 4) 901s > 901s > # To check names attribute 901s > dimnames <- list(letters[1:4], LETTERS[1:4]) 901s > 901s > # Test with and without dimnames on x 901s > for (setDimnames in c(TRUE, FALSE)) { 901s + if (setDimnames) dimnames(x) <- dimnames 901s + else dimnames(x) <- NULL 901s + # Check names attribute 901s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 901s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + 901s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + } 901s + } 901s > 901s > 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > # Special case: NaNs and NAs 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > cat("Special case: Infs and -Infs:\n") 901s Special case: Infs and -Infs: 901s > x <- matrix(c(NaN, NA_real_), nrow = 4, ncol = 4) 901s > 901s > y0 <- rowSums(x, na.rm = FALSE) 901s > str(y0) 901s num [1:4] NaN NA NaN NA 901s > stopifnot(all(is.na(y0)), length(unique(y0)) >= 1L) 901s > y1 <- rowSums2(x, na.rm = FALSE) 901s > str(y0) 901s num [1:4] NaN NA NaN NA 901s > stopifnot(all(is.na(y1)), length(unique(y1)) >= 1L) 901s > stopifnot(all.equal(y1, y0)) 901s > 901s > y0 <- colSums(x, na.rm = FALSE) 901s > stopifnot(all(is.na(y0)), length(unique(y0)) == 1L) 901s > y1 <- colSums2(x, na.rm = FALSE) 901s > stopifnot(all(is.na(y1)), length(unique(y1)) == 1L) 901s > ## NOTE, due to compiler optimization, it is not guaranteed that NA is 901s > ## returned here (as one would expect). NaN might very well be returned, 901s > ## when both NA and NaN are involved. This is an accepted feature in R, 901s > ## which is documented in help("is.nan"). See also 901s > ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 901s > ## Thus, we cannot guarantee that y1 is identical to y0. 901s > 901s > 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > # Special case: Integer overflow with ties 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > cat("Special case: Integer overflow with ties:\n") 901s Special case: Integer overflow with ties: 901s > x <- matrix(.Machine$integer.max, nrow = 4, ncol = 4) 901s > 901s > # Test with and without dimnames on x 901s > for (setDimnames in c(TRUE, FALSE)) { 901s + if (setDimnames) dimnames(x) <- dimnames 901s + else dimnames(x) <- NULL 901s + # Check names attribute 901s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 901s + y0 <- rowSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- rowSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + 901s + y0 <- colSums2_R(x, na.rm = FALSE, useNames = useNames) 901s + y1 <- colSums2(x, na.rm = FALSE, useNames = useNames) 901s + stopifnot(all.equal(y1, y0)) 901s + } 901s + } 901s > 901s > 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > # Consistency checks 901s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 901s > set.seed(1) 901s > 901s > cat("Consistency checks:\n") 901s Consistency checks: 901s > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 4L else 20L 901s > for (kk in seq_len(n_sims)) { 901s + cat("Random test #", kk, "\n", sep = "") 901s + 901s + # Simulate data in a matrix of any shape 901s + dim <- sample(50:200, size = 2) 901s + n <- prod(dim) 901s + x <- rnorm(n, sd = 100) 901s + dim(x) <- dim 901s + 901s + # Add NAs? 901s + if ((kk %% 4) %in% c(3, 0)) { 901s + cat("Adding NAs\n") 901s + nna <- sample(n, size = 1) 901s + na_values <- c(NA_real_, NaN) 901s + t <- sample(na_values, size = nna, replace = TRUE) 901s + x[sample(length(x), size = nna)] <- t 901s + } 901s + 901s + # Mode? 901s + modes <- "double" 901s + if ((kk %% 4) %in% c(2, 0)) { 901s + modes <- c("integer", "logical") 901s + } 901s + 901s + for (mode in modes) { 901s + if (mode != "double") { 901s + cat(sprintf("Coercing from %s to %s\n", storage.mode(x), mode)) 901s + storage.mode(x) <- mode 901s + } 901s + 901s + na.rm <- sample(c(TRUE, FALSE), size = 1) 901s + 901s + # rowSums2(): 901s + y0 <- rowSums2_R(x, na.rm = na.rm) 901s + y1 <- rowSums2(x, na.rm = na.rm) 901s + stopifnot(all.equal(y1, y0)) 901s + y2 <- colSums2(t(x), na.rm = na.rm) 901s + stopifnot(all.equal(y2, y0)) 901s + 901s + # colSums2(): 901s + y0 <- colSums2_R(x, na.rm = na.rm) 901s + y1 <- colSums2(x, na.rm = na.rm) 901s + stopifnot(all.equal(y1, y0)) 901s + y2 <- rowSums2(t(x), na.rm = na.rm) 901s + stopifnot(all.equal(y2, y0)) 901s + } 901s + } # for (kk ...) 901s Random test #1 901s Random test #2 901s Coercing from double to integer 901s Coercing from integer to logical 901s Random test #3 901s Adding NAs 901s Random test #4 901s Adding NAs 901s Coercing from double to integer 901s Coercing from integer to logical 901s Random test #5 901s Random test #6 901s Coercing from double to integer 901s Coercing from integer to logical 901s Random test #7 901s Adding NAs 901s Random test #8 901s Adding NAs 901s Coercing from double to integer 901s Coercing from integer to logical 901s Random test #9 901s Random test #10 901s Coercing from double to integer 901s Coercing from integer to logical 901s Random test #11 901s Adding NAs 901s Random test #12 901s Adding NAs 901s Coercing from double to integer 901s Coercing from integer to logical 901s Random test #13 901s Random test #14 901s Coercing from double to integer 901s Coercing from integer to logical 901s Random test #15 901s Adding NAs 901s Random test #16 901s Adding NAs 901s Coercing from double to integer 901s Coercing from integer to logical 901s Random test #17 901s Random test #18 901s Coercing from double to integer 901s Coercing from integer to logical 901s Random test #19 901s Adding NAs 901s Random test #20 901s Adding NAs 901s Coercing from double to integer 901s Coercing from integer to logical 901s > 901s 901s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 901s Copyright (C) 2024 The R Foundation for Statistical Computing 901s Platform: s390x-ibm-linux-gnu 901s 901s R is free software and comes with ABSOLUTELY NO WARRANTY. 901s You are welcome to redistribute it under certain conditions. 901s Type 'license()' or 'licence()' for distribution details. 901s 901s R is a collaborative project with many contributors. 901s Type 'contributors()' for more information and 901s 'citation()' on how to cite R or R packages in publications. 901s 901s Type 'demo()' for some demos, 'help()' for on-line help, or 901s 'help.start()' for an HTML browser interface to help. 901s Type 'q()' to quit R. 901s 902s > library("matrixStats") 902s > 902s > rowSums2_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 902s + ## FIXME: sum() may overflow for integers, whereas 902s + ## base::rowSums() doesn't. What should rowSums2() do? 902s + ## apply(x, MARGIN = 1L, FUN = sum, na.rm = na.rm) 902s + res <- rowSums(x, na.rm = na.rm) 902s + if (is.na(useNames) || !useNames) names(res) <- NULL 902s + res 902s + } 902s > 902s > colSums2_R <- function(x, na.rm = FALSE, ..., useNames = NA) { 902s + ## FIXME: sum() may overflow for integers, whereas 902s + ## base::colSums() doesn't. What should colSums2() do? 902s + ## apply(x, MARGIN = 2L, FUN = sum, na.rm = na.rm) 902s + res <- colSums(x, na.rm = na.rm) 902s + if (is.na(useNames) || !useNames) names(res) <- NULL 902s + res 902s + } 902s > 902s > 902s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 902s > # Subsetted tests 902s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 902s > source("utils/validateIndicesFramework.R") 902s > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6) 902s > storage.mode(x) <- "integer" 902s > 902s > # To check names attribute 902s > dimnames <- list(letters[1:6], LETTERS[1:6]) 902s > 902s > # Test with and without dimnames on x 902s > for (setDimnames in c(TRUE, FALSE)) { 902s + if (setDimnames) dimnames(x) <- dimnames 902s + else dimnames(x) <- NULL 902s + for (rows in index_cases) { 902s + for (cols in index_cases) { 902s + for (na.rm in c(TRUE, FALSE)) { 902s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 902s + validateIndicesTestMatrix(x, rows, cols, 902s + ftest = rowSums2, fsure = rowSums2_R, 902s + na.rm = na.rm, useNames = useNames) 902s + validateIndicesTestMatrix(x, rows, cols, 902s + fcoltest = colSums2, fsure = rowSums2_R, 902s + na.rm = na.rm, useNames = useNames) 902s + } 902s + } 902s + } 902s + } 902s + } 903s > 903s 903s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 903s Copyright (C) 2024 The R Foundation for Statistical Computing 903s Platform: s390x-ibm-linux-gnu 903s 903s R is free software and comes with ABSOLUTELY NO WARRANTY. 903s You are welcome to redistribute it under certain conditions. 903s Type 'license()' or 'licence()' for distribution details. 903s 903s R is a collaborative project with many contributors. 903s Type 'contributors()' for more information and 903s 'citation()' on how to cite R or R packages in publications. 903s 903s Type 'demo()' for some demos, 'help()' for on-line help, or 903s 'help.start()' for an HTML browser interface to help. 903s Type 'q()' to quit R. 903s 903s > library("matrixStats") 903s > 903s > nrow <- 6L 903s > ncol <- 5L 903s > data <- matrix(0:4, nrow = nrow, ncol = ncol) 903s > 903s > # To check names attribute 903s > dimnames <- list(letters[1:6], LETTERS[1:5]) 903s > 903s > modes <- c("integer", "logical", "raw") 903s > for (mode in modes) { 903s + cat(sprintf("Mode: %s...\n", mode)) 903s + 903s + x <- data 903s + if (mode == "logical") x <- x - 2L 903s + if (mode != "raw") x[c(2,5,7)] <- NA_integer_ 903s + storage.mode(x) <- mode 903s + print(x) 903s + 903s + unique_values <- unique(as.vector(x)) 903s + nbr_of_unique_values <- length(unique_values) 903s + 903s + y <- rowTabulates(x) 903s + print(y) 903s + stopifnot( 903s + identical(dim(y), c(nrow, nbr_of_unique_values)), 903s + all(y >= 0) 903s + ) 903s + if (mode != "raw") { 903s + y0 <- t(table(x, row(x), useNA = "always")[, seq_len(nrow(x))]) 903s + stopifnot(all(y == y0)) 903s + } 903s + # Check names attribute 903s + dimnames(x) <- dimnames 903s + y1 <- rowTabulates(x, useNames = FALSE) 903s + stopifnot(all.equal(y1, y)) 903s + if (!matrixStats:::isUseNamesNADefunct()) { 903s + y2 <- rowTabulates(x, useNames = NA) 903s + stopifnot(all.equal(y2, y)) 903s + } 903s + y <- rowTabulates(x, useNames = TRUE) 903s + stopifnot(identical(rownames(y), rownames(x))) 903s + dimnames(x) <- NULL 903s + 903s + y <- colTabulates(x) 903s + print(y) 903s + stopifnot( 903s + identical(dim(y), c(ncol, nbr_of_unique_values)), 903s + all(y >= 0) 903s + ) 903s + if (mode != "raw") { 903s + y0 <- t(table(x, col(x), useNA = "always")[, seq_len(ncol(x))]) 903s + stopifnot(all(y == y0)) 903s + } 903s + # Check names attribute 903s + dimnames(x) <- dimnames 903s + y1 <- colTabulates(x, useNames = FALSE) 903s + stopifnot(all.equal(y1, y)) 903s + if (!matrixStats:::isUseNamesNADefunct()) { 903s + y2 <- colTabulates(x, useNames = NA) 903s + stopifnot(all.equal(y2, y)) 903s + } 903s + y <- colTabulates(x, useNames = TRUE) 903s + stopifnot(identical(rownames(y), colnames(x))) 903s + dimnames(x) <- NULL 903s + 903s + # Count only certain values 903s + if (mode == "integer") { 903s + subset <- c(0:2, NA_integer_) 903s + } else if (mode == "logical") { 903s + subset <- c(TRUE, FALSE, NA) 903s + } else { 903s + subset <- c(0:2) 903s + } 903s + y <- rowTabulates(x, values = subset) 903s + print(y) 903s + stopifnot(identical(dim(y), c(nrow, length(subset)))) 903s + # Check names attribute 903s + dimnames(x) <- dimnames 903s + y1 <- rowTabulates(x, values = subset, useNames = FALSE) 903s + stopifnot(all.equal(y1, y)) 903s + if (!matrixStats:::isUseNamesNADefunct()) { 903s + y2 <- rowTabulates(x, values = subset, useNames = NA) 903s + stopifnot(all.equal(y2, y)) 903s + } 903s + y <- rowTabulates(x, values = subset, useNames = TRUE) 903s + stopifnot(identical(rownames(y), rownames(x))) 903s + dimnames(x) <- NULL 903s + 903s + y <- colTabulates(x, values = subset) 903s + print(y) 903s + stopifnot(identical(dim(y), c(ncol, length(subset)))) 903s + # Check names attribute 903s + dimnames(x) <- dimnames 903s + y1 <- colTabulates(x, values = subset, useNames = FALSE) 903s + stopifnot(all.equal(y1, y)) 903s + if (!matrixStats:::isUseNamesNADefunct()) { 903s + y2 <- colTabulates(x, values = subset, useNames = NA) 903s + stopifnot(all.equal(y2, y)) 903s + } 903s + y <- colTabulates(x, values = subset, useNames = TRUE) 903s + stopifnot(identical(rownames(y), colnames(x))) 903s + dimnames(x) <- NULL 903s + 903s + # Raw 903s + if (mode %in% c("integer", "raw")) { 903s + subset <- c(0:2) 903s + 903s + y <- rowTabulates(x, values = as.raw(subset)) 903s + print(y) 903s + stopifnot(identical(dim(y), c(nrow, length(subset)))) 903s + # Check names attribute 903s + dimnames(x) <- dimnames 903s + y1 <- rowTabulates(x, values = as.raw(subset), useNames = FALSE) 903s + stopifnot(all.equal(y1, y)) 903s + if (!matrixStats:::isUseNamesNADefunct()) { 903s + y2 <- rowTabulates(x, values = as.raw(subset), useNames = NA) 903s + stopifnot(all.equal(y2, y)) 903s + } 903s + y3 <- rowTabulates(x, values = as.raw(subset), useNames = TRUE) 903s + stopifnot(identical(rownames(y3), rownames(x))) 903s + dimnames(x) <- NULL 903s + 903s + y2 <- colTabulates(t(x), values = as.raw(subset)) 903s + print(y2) 903s + stopifnot( 903s + identical(dim(y2), c(nrow, length(subset))), 903s + identical(y2, y) 903s + ) 903s + # Check names attribute 903s + dimnames(x) <- dimnames 903s + y1 <- colTabulates(t(x), values = as.raw(subset), useNames = FALSE) 903s + stopifnot(all.equal(y1, y)) 903s + if (!matrixStats:::isUseNamesNADefunct()) { 903s + y2 <- colTabulates(t(x), values = as.raw(subset), useNames = NA) 903s + stopifnot(all.equal(y2, y)) 903s + } 903s + y <- colTabulates(t(x), values = as.raw(subset), useNames = TRUE) 903s + stopifnot(identical(rownames(y), colnames(t(x)))) 903s + dimnames(x) <- NULL 903s + } 903s + 903s + cat(sprintf("Mode: %s...done\n", mode)) 903s + } # for (mode ...) 904s Mode: integer... 904s [,1] [,2] [,3] [,4] [,5] 904s [1,] 0 NA 2 3 4 904s [2,] NA 2 3 4 0 904s [3,] 2 3 4 0 1 904s [4,] 3 4 0 1 2 904s [5,] NA 0 1 2 3 904s [6,] 0 1 2 3 4 904s 0 1 2 3 4 904s [1,] 1 0 1 1 1 1 904s [2,] 1 0 1 1 1 1 904s [3,] 1 1 1 1 1 0 904s [4,] 1 1 1 1 1 0 904s [5,] 1 1 1 1 0 1 904s [6,] 1 1 1 1 1 0 904s 0 1 2 3 4 904s [1,] 2 0 1 1 0 2 904s [2,] 1 1 1 1 1 1 904s [3,] 1 1 2 1 1 0 904s [4,] 1 1 1 2 1 0 904s [5,] 1 1 1 1 2 0 904s 0 1 2 904s [1,] 1 0 1 1 904s [2,] 1 0 1 1 904s [3,] 1 1 1 0 904s [4,] 1 1 1 0 904s [5,] 1 1 1 1 904s [6,] 1 1 1 0 904s 0 1 2 904s [1,] 2 0 1 2 904s [2,] 1 1 1 1 904s [3,] 1 1 2 0 904s [4,] 1 1 1 0 904s [5,] 1 1 1 0 904s 0x0 0x1 0x2 904s [1,] 1 0 1 904s [2,] 1 0 1 904s [3,] 1 1 1 904s [4,] 1 1 1 904s [5,] 1 1 1 904s [6,] 1 1 1 904s 0x0 0x1 0x2 904s [1,] 1 0 1 904s [2,] 1 0 1 904s [3,] 1 1 1 904s [4,] 1 1 1 904s [5,] 1 1 1 904s [6,] 1 1 1 904s Mode: integer...done 904s Mode: logical... 904s [,1] [,2] [,3] [,4] [,5] 904s [1,] TRUE NA FALSE TRUE TRUE 904s [2,] NA FALSE TRUE TRUE TRUE 904s [3,] FALSE TRUE TRUE TRUE TRUE 904s [4,] TRUE TRUE TRUE TRUE FALSE 904s [5,] NA TRUE TRUE FALSE TRUE 904s [6,] TRUE TRUE FALSE TRUE TRUE 904s FALSE TRUE 904s [1,] 1 3 1 904s [2,] 1 3 1 904s [3,] 1 4 0 904s [4,] 1 4 0 904s [5,] 1 3 1 904s [6,] 1 4 0 904s FALSE TRUE 904s [1,] 1 3 2 904s [2,] 1 4 1 904s [3,] 2 4 0 904s [4,] 1 5 0 904s [5,] 1 5 0 904s TRUE FALSE 904s [1,] 3 1 1 904s [2,] 3 1 1 904s [3,] 4 1 0 904s [4,] 4 1 0 904s [5,] 3 1 1 904s [6,] 4 1 0 904s TRUE FALSE 904s [1,] 3 1 2 904s [2,] 4 1 1 904s [3,] 4 2 0 904s [4,] 5 1 0 904s [5,] 5 1 0 904s Mode: logical...done 904s Mode: raw... 904s [,1] [,2] [,3] [,4] [,5] 904s [1,] 00 01 02 03 04 904s [2,] 01 02 03 04 00 904s [3,] 02 03 04 00 01 904s [4,] 03 04 00 01 02 904s [5,] 04 00 01 02 03 904s [6,] 00 01 02 03 04 904s 0x0 0x1 0x2 0x3 0x4 904s [1,] 1 1 1 1 1 904s [2,] 1 1 1 1 1 904s [3,] 1 1 1 1 1 904s [4,] 1 1 1 1 1 904s [5,] 1 1 1 1 1 904s [6,] 1 1 1 1 1 904s 0x0 0x1 0x2 0x3 0x4 904s [1,] 2 1 1 1 1 904s [2,] 1 2 1 1 1 904s [3,] 1 1 2 1 1 904s [4,] 1 1 1 2 1 904s [5,] 1 1 1 1 2 904s 0 1 2 904s [1,] 1 1 1 904s [2,] 1 1 1 904s [3,] 1 1 1 904s [4,] 1 1 1 904s [5,] 1 1 1 904s [6,] 1 1 1 904s 0 1 2 904s [1,] 2 1 1 904s [2,] 1 2 1 904s [3,] 1 1 2 904s [4,] 1 1 1 904s [5,] 1 1 1 904s 0x0 0x1 0x2 904s [1,] 1 1 1 904s [2,] 1 1 1 904s [3,] 1 1 1 904s [4,] 1 1 1 904s [5,] 1 1 1 904s [6,] 1 1 1 904s 0x0 0x1 0x2 904s [1,] 1 1 1 904s [2,] 1 1 1 904s [3,] 1 1 1 904s [4,] 1 1 1 904s [5,] 1 1 1 904s [6,] 1 1 1 904s Mode: raw...done 904s > 904s 904s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 904s Copyright (C) 2024 The R Foundation for Statistical Computing 904s Platform: s390x-ibm-linux-gnu 904s 904s R is free software and comes with ABSOLUTELY NO WARRANTY. 904s You are welcome to redistribute it under certain conditions. 904s Type 'license()' or 'licence()' for distribution details. 904s 904s R is a collaborative project with many contributors. 904s Type 'contributors()' for more information and 904s 'citation()' on how to cite R or R packages in publications. 904s 904s Type 'demo()' for some demos, 'help()' for on-line help, or 904s 'help.start()' for an HTML browser interface to help. 904s Type 'q()' to quit R. 904s 904s > library("matrixStats") 904s > 904s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 904s > # Subsetted tests 904s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 904s > source("utils/validateIndicesFramework.R") 904s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 904s > storage.mode(x) <- "integer" 904s > 904s > # To check names attribute 904s > dimnames <- list(letters[1:6], LETTERS[1:6]) 904s > 904s > # Test with and without dimnames on x 904s > for (setDimnames in c(TRUE, FALSE)) { 904s + if (setDimnames) dimnames(x) <- dimnames 904s + else dimnames(x) <- NULL 904s + 904s + count <- 0L 904s + for (rows in index_cases) { 904s + for (cols in index_cases) { 904s + count <- count + 1L 904s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 904s + useNames <- useNames[count %% length(useNames) + 1] 904s + 904s + validateIndicesTestMatrix(x, rows, cols, 904s + ftest = rowTabulates, fsure = rowTabulates, useNames = useNames) 904s + validateIndicesTestMatrix(x, rows, cols, 904s + ftest = rowTabulates, fsure = rowTabulates, 904s + values = 1:3, useNames = useNames) 904s + 904s + validateIndicesTestMatrix(x, rows, cols, 904s + ftest = colTabulates, fsure = colTabulates, useNames = useNames) 904s + validateIndicesTestMatrix(x, rows, cols, 904s + ftest = colTabulates, fsure = colTabulates, 904s + values = 1:3, useNames = useNames) 904s + } 904s + } 904s + } 906s > 906s 906s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 906s Copyright (C) 2024 The R Foundation for Statistical Computing 906s Platform: s390x-ibm-linux-gnu 906s 906s R is free software and comes with ABSOLUTELY NO WARRANTY. 906s You are welcome to redistribute it under certain conditions. 906s Type 'license()' or 'licence()' for distribution details. 906s 906s R is a collaborative project with many contributors. 906s Type 'contributors()' for more information and 906s 'citation()' on how to cite R or R packages in publications. 906s 906s Type 'demo()' for some demos, 'help()' for on-line help, or 906s 'help.start()' for an HTML browser interface to help. 906s Type 'q()' to quit R. 906s 906s > library("matrixStats") 906s > 906s > fcns <- list( 906s + rowVarDiffs = list(rowVarDiffs, colVarDiffs), 906s + rowSdDiffs = list(rowSdDiffs, colSdDiffs), 906s + rowMadDiffs = list(rowMadDiffs, colMadDiffs), 906s + rowIQRDiffs = list(rowIQRDiffs, colIQRDiffs) 906s + ) 906s > 906s > for (fcn in names(fcns)) { 906s + cat(sprintf("%s()...\n", fcn)) 906s + row_fcn <- fcns[[fcn]][[1L]] 906s + col_fcn <- fcns[[fcn]][[2L]] 906s + 906s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 906s + # With and without some NAs 906s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 906s + for (mode in c("integer", "double")) { 906s + for (add_na in c(FALSE, TRUE)) { 906s + cat("add_na = ", add_na, "\n", sep = "") 906s + 906s + x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L) 906s + if (add_na) { 906s + x[3:7, c(2, 4)] <- NA_real_ 906s + } 906s + cat("mode: ", mode, "\n", sep = "") 906s + storage.mode(x) <- mode 906s + str(x) 906s + 906s + # To check names attribute 906s + dimnames <- list(letters[1:10], LETTERS[1:5]) 906s + 906s + # Test with and without dimnames on x 906s + for (setDimnames in c(TRUE, FALSE)) { 906s + if (setDimnames) dimnames(x) <- dimnames 906s + else dimnames(x) <- NULL 906s + # Row/column ranges 906s + for (na.rm in c(FALSE, TRUE)) { 906s + # Check names attribute 906s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 906s + cat("na.rm = ", na.rm, "\n", sep = "") 906s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 906s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 906s + stopifnot(all.equal(r1, r2)) 906s + } 906s + } 906s + } 906s + } # for (add_na ...) 906s + } 906s + 906s + 906s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 906s + # All NAs 906s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 906s + for (mode in c("integer", "double")) { 906s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 906s + cat("mode: ", mode, "\n", sep = "") 906s + storage.mode(x) <- mode 906s + str(x) 906s + 906s + # Test with and without dimnames on x 906s + for (setDimnames in c(TRUE, FALSE)) { 906s + if (setDimnames) dimnames(x) <- dimnames 906s + else dimnames(x) <- NULL 906s + # Row/column ranges 906s + for (na.rm in c(FALSE, TRUE)) { 906s + # Check names attribute 906s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 906s + cat("na.rm = ", na.rm, "\n", sep = "") 906s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 906s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 906s + stopifnot(all.equal(r1, r2)) 906s + } 906s + } 906s + } 906s + } 906s + 906s + 906s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 906s + # A 1x1 matrix 906s + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 906s + x <- matrix(0, nrow = 1L, ncol = 1L) 906s + dimnames <- list("a", "A") 906s + # Test with and without dimnames on x 906s + for (setDimnames in c(TRUE, FALSE)) { 906s + if (setDimnames) dimnames(x) <- dimnames 906s + else dimnames(x) <- NULL 906s + # Row/column ranges 906s + for (na.rm in c(FALSE, TRUE)) { 906s + # Check names attribute 906s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 906s + cat("na.rm = ", na.rm, "\n", sep = "") 906s + r1 <- row_fcn(x, na.rm = na.rm, useNames = useNames) 906s + r2 <- col_fcn(t(x), na.rm = na.rm, useNames = useNames) 906s + stopifnot(all.equal(r1, r2)) 906s + } 906s + } 906s + } 906s + 906s + cat(sprintf("%s()...DONE\n", fcn)) 906s + } # for (fcn ...) 907s rowVarDiffs()... 907s add_na = FALSE 907s mode: integer 907s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = TRUE 907s mode: integer 907s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = FALSE 907s mode: double 907s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = TRUE 907s mode: double 907s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s mode: integer 907s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s mode: double 907s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s rowVarDiffs()...DONE 907s rowSdDiffs()... 907s add_na = FALSE 907s mode: integer 907s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = TRUE 907s mode: integer 907s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = FALSE 907s mode: double 907s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = TRUE 907s mode: double 907s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s mode: integer 907s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s mode: double 907s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s rowSdDiffs()...DONE 907s rowMadDiffs()... 907s add_na = FALSE 907s mode: integer 907s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = TRUE 907s mode: integer 907s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = FALSE 907s mode: double 907s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = TRUE 907s mode: double 907s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s mode: integer 907s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s mode: double 907s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s rowMadDiffs()...DONE 907s rowIQRDiffs()... 907s add_na = FALSE 907s mode: integer 907s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = TRUE 907s mode: integer 907s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = FALSE 907s mode: double 907s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s add_na = TRUE 907s mode: double 907s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s mode: integer 907s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s mode: double 907s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s na.rm = FALSE 907s na.rm = FALSE 907s na.rm = TRUE 907s na.rm = TRUE 907s rowIQRDiffs()...DONE 907s > 907s 907s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 907s Copyright (C) 2024 The R Foundation for Statistical Computing 907s Platform: s390x-ibm-linux-gnu 907s 907s R is free software and comes with ABSOLUTELY NO WARRANTY. 907s You are welcome to redistribute it under certain conditions. 907s Type 'license()' or 'licence()' for distribution details. 907s 907s R is a collaborative project with many contributors. 907s Type 'contributors()' for more information and 907s 'citation()' on how to cite R or R packages in publications. 907s 907s Type 'demo()' for some demos, 'help()' for on-line help, or 907s 'help.start()' for an HTML browser interface to help. 907s Type 'q()' to quit R. 907s 907s > library("matrixStats") 907s > 907s > fcns <- list( 907s + madDiff = c(rowMadDiffs, colMadDiffs), 907s + iqrDiff = c(rowIQRDiffs, colIQRDiffs) 907s + ) 907s > 907s > 907s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 907s > # Subsetted tests 907s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 907s > source("utils/validateIndicesFramework.R") 907s > # To check names attribute 907s > dimnames <- list(letters[1:6], LETTERS[1:6]) 907s > trim <- runif(1, min = 0, max = 0.5) 907s > for (fcn in names(fcns)) { 907s + cat(sprintf("subsetted tests on %s()...\n", fcn)) 907s + row_fcn <- fcns[[fcn]][[1L]] 907s + col_fcn <- fcns[[fcn]][[2L]] 907s + 907s + for (mode in c("numeric", "integer")) { 907s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 907s + storage.mode(x) <- mode 907s + if (mode == "numeric") x[1:2, 3:4] <- Inf 907s + 907s + # Test with and without dimnames on x 907s + for (setDimnames in c(TRUE, FALSE)) { 907s + if (setDimnames) dimnames(x) <- dimnames 907s + else dimnames(x) <- NULL 907s + 907s + count <- 0L 907s + for (diff in 1:2) { 907s + for (rows in index_cases) { 907s + for (cols in index_cases) { 907s + count <- count + 1L 907s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 907s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 907s + useNames <- useNames[count %% length(useNames) + 1] 907s + validateIndicesTestMatrix(x, rows, cols, 907s + ftest = row_fcn, fsure = row_fcn, 907s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 907s + validateIndicesTestMatrix(x, rows, cols, 907s + fcoltest = col_fcn, fsure = row_fcn, 907s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 907s + } 907s + } 907s + } 907s + } 907s + } 907s + cat(sprintf("%s()...DONE\n", fcn)) 907s + } 907s subsetted tests on madDiff()... 910s madDiff()...DONE 910s subsetted tests on iqrDiff()... 913s iqrDiff()...DONE 913s > 913s 913s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 913s Copyright (C) 2024 The R Foundation for Statistical Computing 913s Platform: s390x-ibm-linux-gnu 913s 913s R is free software and comes with ABSOLUTELY NO WARRANTY. 913s You are welcome to redistribute it under certain conditions. 913s Type 'license()' or 'licence()' for distribution details. 913s 913s R is a collaborative project with many contributors. 913s Type 'contributors()' for more information and 913s 'citation()' on how to cite R or R packages in publications. 913s 913s Type 'demo()' for some demos, 'help()' for on-line help, or 913s 'help.start()' for an HTML browser interface to help. 913s Type 'q()' to quit R. 913s 914s > library("matrixStats") 914s > 914s > fcns <- list( 914s + varDiff = c(rowVarDiffs, colVarDiffs), 914s + sdDiff = c(rowSdDiffs, colSdDiffs) 914s + ) 914s > 914s > 914s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 914s > # Subsetted tests 914s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 914s > source("utils/validateIndicesFramework.R") 914s > # To check names attribute 914s > dimnames <- list(letters[1:6], LETTERS[1:6]) 914s > trim <- runif(1, min = 0, max = 0.5) 914s > for (fcn in names(fcns)) { 914s + cat(sprintf("subsetted tests on %s()...\n", fcn)) 914s + row_fcn <- fcns[[fcn]][[1L]] 914s + col_fcn <- fcns[[fcn]][[2L]] 914s + 914s + for (mode in c("numeric", "integer")) { 914s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 914s + storage.mode(x) <- mode 914s + if (mode == "numeric") x[1:2, 3:4] <- Inf 914s + 914s + # Test with and without dimnames on x 914s + for (setDimnames in c(TRUE, FALSE)) { 914s + if (setDimnames) dimnames(x) <- dimnames 914s + else dimnames(x) <- NULL 914s + 914s + count <- 0L 914s + for (diff in 1:2) { 914s + for (rows in index_cases) { 914s + for (cols in index_cases) { 914s + count <- count + 1L 914s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 914s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 914s + useNames <- useNames[count %% length(useNames) + 1] 914s + 914s + validateIndicesTestMatrix(x, rows, cols, 914s + ftest = row_fcn, fsure = row_fcn, 914s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 914s + validateIndicesTestMatrix(x, rows, cols, 914s + fcoltest = col_fcn, fsure = row_fcn, 914s + na.rm = na.rm, diff = diff, trim = trim, useNames = useNames) 914s + } 914s + } 914s + } 914s + } 914s + } 914s + cat(sprintf("%s()...DONE\n", fcn)) 914s + } 914s subsetted tests on varDiff()... 916s varDiff()...DONE 916s subsetted tests on sdDiff()... 918s sdDiff()...DONE 918s > 918s 918s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 918s Copyright (C) 2024 The R Foundation for Statistical Computing 918s Platform: s390x-ibm-linux-gnu 918s 918s R is free software and comes with ABSOLUTELY NO WARRANTY. 918s You are welcome to redistribute it under certain conditions. 918s Type 'license()' or 'licence()' for distribution details. 918s 918s R is a collaborative project with many contributors. 918s Type 'contributors()' for more information and 918s 'citation()' on how to cite R or R packages in publications. 918s 918s Type 'demo()' for some demos, 'help()' for on-line help, or 918s 'help.start()' for an HTML browser interface to help. 918s Type 'q()' to quit R. 918s 918s > library("matrixStats") 918s > 918s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 918s > options(matrixStats.center.onUse = "ignore") 918s > options(matrixStats.vars.formula.freq = Inf) 918s > 918s > ## Create isFALSE() if running on an old version of R 918s > if (!exists("isFALSE", mode="function")) { 918s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 918s + } 919s > 919s > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 919s + suppressWarnings({ 919s + res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm) 919s + }) 919s + stopifnot(!any(is.infinite(res))) 919s + 919s + # Keep naming support consistency same as rowVars() 919s + if (is.null(center) || ncol(x) <= 1L) { 919s + if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL 919s + } 919s + else if (isFALSE(useNames)) names(res) <- NULL 919s + res 919s + } 919s > 919s > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 919s + suppressWarnings({ 919s + res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm) 919s + }) 919s + stopifnot(!any(is.infinite(res))) 919s + 919s + # Keep naming support consistency same as colVars() 919s + if (is.null(center) || ncol(x) <= 1L) { 919s + if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL 919s + } 919s + else if (isFALSE(useNames)) names(res) <- NULL 919s + res 919s + } 919s > 919s > 919s > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 919s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 919s + res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 919s + stopifnot(!any(is.infinite(res))) 919s + res 919s + } 919s > 919s > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 919s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 919s + res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 919s + stopifnot(!any(is.infinite(res))) 919s + res 919s + } 919s > 919s > rowVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = NA) { 919s + x <- sweep(x, MARGIN = 1, STATS = as.array(center), FUN = "-") 919s + x[is.infinite(center), ] <- NaN 919s + res <- rowVars(x, rows = rows, cols = cols, center = rep(0, times = nrow(x)), na.rm = na.rm, useNames = useNames) 919s + stopifnot(!any(is.infinite(res))) 919s + res 919s + } 919s > 919s > colVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = NA) { 919s + x <- sweep(x, MARGIN = 2, STATS = as.array(center), FUN = "-") 919s + x[, is.infinite(center)] <- NaN 919s + res <- colVars(x, rows = rows, cols = cols, center = rep(0, times = ncol(x)), na.rm = na.rm, useNames = useNames) 919s + stopifnot(!any(is.infinite(res))) 919s + res 919s + } 919s > 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > # With and without some NAs or Infs 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > for (mode in c("integer", "double")) { 919s + if (mode == "integer") { 919s + specials <- c(0L, NA_integer_) 919s + delta <- 0L 919s + } else { 919s + specials <- c(0, NA_real_, Inf) 919s + delta <- 0.1 919s + } 919s + 919s + for (special in specials) { 919s + cat("special = ", special, "\n", sep = "") 919s + x <- matrix(1:50 + delta, nrow = 10L, ncol = 5L) 919s + x[3:7, c(2, 4)] <- special 919s + cat("mode: ", mode, "\n", sep = "") 919s + str(x) 919s + stopifnot(storage.mode(x) == mode) 919s + 919s + # To check names attribute 919s + dimnames <- list(letters[1:10], LETTERS[1:5]) 919s + 919s + # Test with and without dimnames on x 919s + for (setDimnames in c(TRUE, FALSE)) { 919s + if (setDimnames) dimnames(x) <- dimnames 919s + else dimnames(x) <- NULL 919s + # Row/column variance 919s + for (na.rm in c(FALSE, TRUE)) { 919s + # Check names attribute 919s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 919s + cat("na.rm = ", na.rm, "\n", sep = "") 919s + center <- rowMeans(x, na.rm = na.rm) 919s + 919s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 919s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 919s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 919s + r1c <- rowVars(x, center = center, na.rm = na.rm, useNames = useNames) 919s + 919s + tx <- t(x) 919s + r2 <- colVars(tx, na.rm = na.rm, useNames = useNames) 919s + r2b <- colVars_center(tx, na.rm = na.rm, useNames = useNames) 919s + r2c <- colVars(tx, center = center, na.rm = na.rm, useNames = useNames) 919s + tx <- NULL 919s + 919s + stopifnot(all.equal(r1, r2)) 919s + stopifnot(all.equal(r1, r0)) 919s + stopifnot(all.equal(r1b, r1c)) 919s + stopifnot(all.equal(r2, r0)) 919s + stopifnot(all.equal(r2b, r2c)) 919s + 919s + center <- colMeans(x, na.rm = na.rm) 919s + 919s + r3 <- colVars(x, center = center, na.rm = na.rm, useNames = useNames) 919s + r3b <- colVars_center_naive(x, center = center, na.rm = na.rm, useNames = useNames) 919s + r3c <- rowVars(t(x), center = center, na.rm = na.rm, useNames = useNames) 919s + r3d <- rowVars_center_naive(t(x), center = center, na.rm = na.rm, useNames = useNames) 919s + stopifnot(all.equal(r3b, r3)) 919s + stopifnot(all.equal(r3c, r3)) 919s + stopifnot(all.equal(r3d, r3)) 919s + 919s + stopifnot( 919s + !any(is.infinite(r0)), 919s + !any(is.infinite(r1)), 919s + !any(is.infinite(r2)), 919s + !any(is.infinite(r3)), 919s + !any(is.infinite(r1b)), 919s + !any(is.infinite(r1c)), 919s + !any(is.infinite(r2b)), 919s + !any(is.infinite(r2c)), 919s + !any(is.infinite(r3b)), 919s + !any(is.infinite(r3c)), 919s + !any(is.infinite(r3d)) 919s + ) 919s + } 919s + } 919s + } 919s + } # for (special ...) 919s + } 919s special = 0 919s mode: integer 919s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s special = NA 919s mode: integer 919s int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ... 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s special = 0 919s mode: double 919s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s special = NA 919s mode: double 919s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s special = Inf 919s mode: double 919s num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ... 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s > 919s > 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > # All NAs 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > for (mode in c("integer", "double")) { 919s + x <- matrix(NA_real_, nrow = 10L, ncol = 5L) 919s + cat("mode: ", mode, "\n", sep = "") 919s + storage.mode(x) <- mode 919s + str(x) 919s + 919s + # Test with and without dimnames on x 919s + for (setDimnames in c(TRUE, FALSE)) { 919s + if (setDimnames) dimnames(x) <- dimnames 919s + else dimnames(x) <- NULL 919s + # Row/column variance 919s + for (na.rm in c(FALSE, TRUE)) { 919s + # Check names attribute 919s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 919s + cat("na.rm = ", na.rm, "\n", sep = "") 919s + 919s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 919s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 919s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 919s + r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames) 919s + r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames) 919s + stopifnot(all.equal(r1, r2)) 919s + stopifnot(all.equal(r1, r0)) 919s + stopifnot(all.equal(r2, r0)) 919s + stopifnot(all.equal(r1b, r2b)) 919s + stopifnot( 919s + !any(is.infinite(r0)), 919s + !any(is.infinite(r1)), 919s + !any(is.infinite(r2)), 919s + !any(is.infinite(r1b)), 919s + !any(is.infinite(r2b)) 919s + ) 919s + } 919s + } 919s + } 919s + } 919s mode: integer 919s int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s mode: double 919s num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ... 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s > 919s > 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > # A 1x1 matrix 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > x <- matrix(0, nrow = 1L, ncol = 1L) 919s > dimnames <- list("a", "A") 919s > # Test with and without dimnames on x 919s > for (setDimnames in c(TRUE, FALSE)) { 919s + if (setDimnames) dimnames(x) <- dimnames 919s + else dimnames(x) <- NULL 919s + # Row/column variance 919s + for (na.rm in c(FALSE, TRUE)) { 919s + # Check names attribute 919s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 919s + cat("na.rm = ", na.rm, "\n", sep = "") 919s + 919s + r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames) 919s + r1 <- rowVars(x, na.rm = na.rm, useNames = useNames) 919s + r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames) 919s + r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames) 919s + r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames) 919s + stopifnot(all.equal(r1, r2)) 919s + stopifnot(all.equal(r1, r0)) 919s + stopifnot(all.equal(r2, r0)) 919s + stopifnot(all.equal(r1b, r2b)) 919s + stopifnot( 919s + !any(is.infinite(r0)), 919s + !any(is.infinite(r1)), 919s + !any(is.infinite(r2)), 919s + !any(is.infinite(r1b)), 919s + !any(is.infinite(r2b)) 919s + ) 919s + } 919s + } 919s + } 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s na.rm = FALSE 919s na.rm = FALSE 919s na.rm = TRUE 919s na.rm = TRUE 919s > 919s > 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > # center and .dim 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > m <- matrix(1:12, nrow = 3L, ncol = 4L) 919s > a <- array(m, dim = c(3, 2, 2)) 919s > stopifnot(prod(dim(a)) == prod(dim(m))) 919s > 919s > y0 <- rowVars(m, dim. = dim(m)) 919s > print(y0) 919s [1] 15 15 15 919s > y1 <- rowVars(a, dim. = dim(m)) 919s > print(y1) 919s [1] 15 15 15 919s > stopifnot(identical(y1, y0)) 919s > stopifnot( 919s + !any(is.infinite(y0)), 919s + !any(is.infinite(y1)) 919s + ) 919s > 919s > mu <- rowMeans(m) 919s > y0 <- rowVars(m, center = mu, dim. = dim(m)) 919s > print(y0) 919s [1] 15 15 15 919s > y1 <- rowVars(a, center = mu, dim. = dim(m)) 919s > print(y1) 919s [1] 15 15 15 919s > stopifnot(identical(y1, y0)) 919s > stopifnot( 919s + !any(is.infinite(y0)), 919s + !any(is.infinite(y1)) 919s + ) 919s > 919s > 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > # Corner cases 919s > # https://github.com/HenrikBengtsson/matrixStats/issues/195 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > x <- matrix(c(1,2,3,4), nrow = 2L, ncol = 2L) 919s > x[1,1] <- NA_real_ 919s > x[1,2] <- Inf 919s > 919s > center <- colMeans2(x, na.rm = TRUE) 919s > y <- colVars(x, center = center, na.rm = TRUE) 919s > stopifnot(!any(is.infinite(y))) 919s > 919s > x <- t(x) 919s > center <- rowMeans2(x, na.rm = TRUE) 919s > y <- rowVars(x, center = center, na.rm = TRUE) 919s > stopifnot(!any(is.infinite(y))) 919s > 919s 919s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 919s Copyright (C) 2024 The R Foundation for Statistical Computing 919s Platform: s390x-ibm-linux-gnu 919s 919s R is free software and comes with ABSOLUTELY NO WARRANTY. 919s You are welcome to redistribute it under certain conditions. 919s Type 'license()' or 'licence()' for distribution details. 919s 919s R is a collaborative project with many contributors. 919s Type 'contributors()' for more information and 919s 'citation()' on how to cite R or R packages in publications. 919s 919s Type 'demo()' for some demos, 'help()' for on-line help, or 919s 'help.start()' for an HTML browser interface to help. 919s Type 'q()' to quit R. 919s 919s > library("matrixStats") 919s > 919s > ## Always allow testing of the 'center' argument (as long as it's not defunct) 919s > options(matrixStats.center.onUse = "ignore") 919s > 919s > ## Create isFALSE() if running on an old version of R 919s > if (!exists("isFALSE", mode="function")) { 919s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 919s + } 919s > 919s > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 919s + suppressWarnings({ 919s + res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm) 919s + }) 919s + stopifnot(!any(is.infinite(res))) 919s + 919s + # Keep naming support consistency same as rowVars() 919s + if (is.null(center) || ncol(x) <= 1L) { 919s + if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL 919s + } 919s + else if (isFALSE(useNames)) names(res) <- NULL 919s + res 919s + } 919s > 919s > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) { 919s + suppressWarnings({ 919s + res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm) 919s + }) 919s + stopifnot(!any(is.infinite(res))) 919s + 919s + # Keep naming support consistency same as colVars() 919s + if (is.null(center) || nrow(x) <= 1L) { 919s + if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL 919s + } 919s + else if (isFALSE(useNames)) names(res) <- NULL 919s + res 919s + } 919s > 919s > 919s > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 919s + center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE) 919s + res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 919s + stopifnot(!any(is.infinite(res))) 919s + res 919s + } 919s > 919s > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) { 919s + center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE) 919s + res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames) 919s + stopifnot(!any(is.infinite(res))) 919s + res 919s + } 919s > 919s > 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > # Subsetted tests 919s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 919s > source("utils/validateIndicesFramework.R") 919s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 919s > storage.mode(x) <- "integer" 919s > 919s > # To check names attribute 919s > dimnames <- list(letters[1:6], LETTERS[1:6]) 919s > 919s > # Test with and without dimnames on x 919s > for (setDimnames in c(TRUE, FALSE)) { 919s + if (setDimnames) dimnames(x) <- dimnames 919s + else dimnames(x) <- NULL 919s + 919s + count <- 0L 919s + for (rows in index_cases) { 919s + for (cols in index_cases) { 919s + count <- count + 1L 919s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 919s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 919s + useNames <- useNames[count %% length(useNames) + 1] 919s + 919s + validateIndicesTestMatrix(x, rows, cols, 919s + ftest = rowVars, fsure = rowVars_R, 919s + na.rm = na.rm, useNames = useNames) 919s + validateIndicesTestMatrix(x, rows, cols, 919s + ftest = rowVars_center, fsure = rowVars_R, 919s + na.rm = na.rm, center = TRUE, useNames = useNames) 919s + 919s + validateIndicesTestMatrix(x, rows, cols, 919s + fcoltest = colVars, fsure = rowVars_R, 919s + na.rm = na.rm, useNames = useNames) 919s + validateIndicesTestMatrix(x, rows, cols, 919s + fcoltest = colVars_center, fsure = rowVars_R, 919s + na.rm = na.rm, center = TRUE, useNames = useNames) 919s + } 919s + } 919s + } 920s > 920s 920s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 920s Copyright (C) 2024 The R Foundation for Statistical Computing 920s Platform: s390x-ibm-linux-gnu 920s 920s R is free software and comes with ABSOLUTELY NO WARRANTY. 920s You are welcome to redistribute it under certain conditions. 920s Type 'license()' or 'licence()' for distribution details. 920s 920s R is a collaborative project with many contributors. 920s Type 'contributors()' for more information and 920s 'citation()' on how to cite R or R packages in publications. 920s 920s Type 'demo()' for some demos, 'help()' for on-line help, or 920s 'help.start()' for an HTML browser interface to help. 920s Type 'q()' to quit R. 920s 920s > library("matrixStats") 920s > 920s > ## Create isFALSE() if running on an old version of R 920s > if (!exists("isFALSE", mode="function")) { 920s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 920s + } 920s > 920s > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 920s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 920s + 920s + # Keep naming support consistency same as rowWeightedMeans() 920s + idxs <- which(is.na(w) | w != 0) 920s + nw <- length(idxs) 920s + if (na.rm) na.rm <- anyMissing(x) 920s + if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) { 920s + if (is.na(useNames) || !useNames) names(res) <- NULL 920s + } 920s + else if (isFALSE(useNames)) names(res) <- NULL 920s + 920s + res 920s + } 920s > 920s > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 920s + res <- apply(x, MARGIN = 2L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 920s + 920s + # Keep naming support consistency same as colWeightedMeans() 920s + idxs <- which(is.na(w) | w != 0) 920s + nw <- length(idxs) 920s + if (!is.null(w) && nw == 0L) { 920s + if (is.na(useNames) || !useNames) names(res) <- NULL 920s + } 920s + else if (isFALSE(useNames)) names(res) <- NULL 920s + 920s + res 920s + } 920s > 920s > set.seed(1) 920s > 920s > x <- matrix(rnorm(20), nrow = 5, ncol = 4) 920s > print(x) 920s [,1] [,2] [,3] [,4] 920s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 920s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 920s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 920s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 920s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 920s > 920s > # To check names attribute 920s > dimnames <- list(letters[1:5], LETTERS[1:4]) 920s > 920s > # Non-weighted row averages 920s > x_est0 <- rowMeans(x) 920s > x_est1 <- rowWeightedMeans(x) 920s > print(x_est1) 920s [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > x_est2 <- colWeightedMeans(t(x)) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > # Check names attribute 920s > dimnames(x) <- dimnames 920s > x_est1 <- rowWeightedMeans(x, useNames = FALSE) 920s > x_est2 <- colWeightedMeans(t(x), useNames = FALSE) 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > x_est0 <- rowMeans(x) 920s > x_est1 <- rowWeightedMeans(x, useNames = TRUE) 920s > x_est2 <- colWeightedMeans(t(x), useNames = TRUE) 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > dimnames(x) <- NULL 920s > 920s > 920s > # Weighted row averages (uniform weights) 920s > w <- rep(2.5, times = ncol(x)) 920s > x_est0 <- rowMeans(x) 920s > x_est1 <- rowWeightedMeans(x, w = w) 920s > print(x_est1) 920s [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > x_est2 <- colWeightedMeans(t(x), w = w) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > # Test with and without dimnames on x 920s > for (setDimnames in c(TRUE, FALSE)) { 920s + if (setDimnames) dimnames(x) <- dimnames 920s + else dimnames(x) <- NULL 920s + # Check names attribute 920s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 920s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 920s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 920s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + } 920s + } 920s > 920s > 920s > # Weighted row averages (excluding some columns) 920s > w <- c(1, 1, 0, 1) 920s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 920s > x_est1 <- rowWeightedMeans(x, w = w) 920s > print(x_est1) 920s [1] -0.4972853 0.2182940 0.2821774 0.9974278 0.2060069 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > x_est2 <- colWeightedMeans(t(x), w = w) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > # Test with and without dimnames on x 920s > for (setDimnames in c(TRUE, FALSE)) { 920s + if (setDimnames) dimnames(x) <- dimnames 920s + else dimnames(x) <- NULL 920s + # Check names attribute 920s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 920s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 920s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 920s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + } 920s + } 920s > 920s > 920s > # Weighted row averages (excluding some columns) 920s > w <- c(0, 1, 0, 0) 920s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 920s > x_est1 <- rowWeightedMeans(x, w = w) 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > x_est2 <- colWeightedMeans(t(x), w = w) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > # Test with and without dimnames on x 920s > for (setDimnames in c(TRUE, FALSE)) { 920s + if (setDimnames) dimnames(x) <- dimnames 920s + else dimnames(x) <- NULL 920s + # Check names attribute 920s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 920s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 920s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 920s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + } 920s + } 920s > 920s > 920s > # Weighted row averages (all zero weights) 920s > w <- c(0, 0, 0, 0) 920s > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE]) 920s > x_est1 <- rowWeightedMeans(x, w = w) 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > x_est2 <- colWeightedMeans(t(x), w = w) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > # Test with and without dimnames on x 920s > for (setDimnames in c(TRUE, FALSE)) { 920s + if (setDimnames) dimnames(x) <- dimnames 920s + else dimnames(x) <- NULL 920s + # Check names attribute 920s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 920s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 920s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 920s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + } 920s + } 920s > 920s > 920s > # Weighted averages by rows and columns 920s > w <- 1:4 920s > x_est1 <- rowWeightedMeans(x, w = w) 920s > print(x_est1) 920s [1] 0.20882185 0.22632701 0.25526439 -0.06123714 0.54691290 920s > x_est2 <- colWeightedMeans(t(x), w = w) 920s > stopifnot(all.equal(x_est2, x_est1)) 920s > # Test with and without dimnames on x 920s > for (setDimnames in c(TRUE, FALSE)) { 920s + if (setDimnames) dimnames(x) <- dimnames 920s + else dimnames(x) <- NULL 920s + # Check names attribute 920s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 920s + x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames) 920s + x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames) 920s + x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + } 920s + } 920s > 920s > 920s > x[sample(length(x), size = 0.3 * length(x))] <- NA 920s > print(x) 920s [,1] [,2] [,3] [,4] 920s [1,] -0.6264538 NA 1.5117812 -0.04493361 920s [2,] 0.1836433 NA NA -0.01619026 920s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 920s [4,] 1.5952808 NA -2.2146999 0.82122120 920s [5,] 0.3295078 NA NA 0.59390132 920s > 920s > # Non-weighted row averages with missing values 920s > x_est0 <- rowMeans(x, na.rm = TRUE) 920s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE) 920s > print(x_est1) 920s [1] 0.28013125 0.08372653 0.05632293 0.06726737 0.46170455 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > # Check names attribute 920s > dimnames(x) <- dimnames 920s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = FALSE) 920s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = FALSE) 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > x_est0 <- rowMeans(x, na.rm = TRUE) 920s > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = TRUE) 920s > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = TRUE) 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > dimnames(x) <- NULL 920s > 920s > 920s > # Weighted row averages with missing values 920s > x_est0 <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = TRUE) 920s > print(x_est0) 920s [1] 0.46614441 0.02377645 0.25526439 -0.22049176 0.54102261 920s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 920s > print(x_est1) 920s [1] 0.46614441 0.02377645 0.25526439 -0.22049176 0.54102261 920s > stopifnot(all.equal(x_est1, x_est0)) 920s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 920s > stopifnot(all.equal(x_est2, x_est0)) 920s > # Test with and without dimnames on x 920s > for (setDimnames in c(TRUE, FALSE)) { 920s + if (setDimnames) dimnames(x) <- dimnames 920s + else dimnames(x) <- NULL 920s + # Check names attribute 920s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 920s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 920s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 920s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + } 920s + } 920s > 920s > 920s > # Weighted averages by rows and columns 920s > w <- 1:4 920s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 920s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 920s > stopifnot(all.equal(x_est2, x_est1)) 920s > # Test with and without dimnames on x 920s > for (setDimnames in c(TRUE, FALSE)) { 920s + if (setDimnames) dimnames(x) <- dimnames 920s + else dimnames(x) <- NULL 920s + # Check names attribute 920s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 920s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 920s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 920s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + } 920s + } 920s > 920s > 920s > # w contains missing value 920s > w[1] <- NA_integer_ 920s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE) 920s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE) 920s > stopifnot(all.equal(x_est2, x_est1)) 920s > # Test with and without dimnames on x 920s > for (setDimnames in c(TRUE, FALSE)) { 920s + if (setDimnames) dimnames(x) <- dimnames 920s + else dimnames(x) <- NULL 920s + # Check names attribute 920s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 920s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames) 920s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 920s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + } 920s + } 920s > 920s > x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE) 920s > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = FALSE) 920s > stopifnot(all.equal(x_est2, x_est1)) 920s > # Test with and without dimnames on x 920s > for (setDimnames in c(TRUE, FALSE)) { 920s + if (setDimnames) dimnames(x) <- dimnames 920s + else dimnames(x) <- NULL 920s + # Check names attribute 920s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 920s + x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = FALSE, useNames = useNames) 920s + x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = FALSE, useNames = useNames) 920s + x_est1 <- colWeightedMeans(t(x), w = w, na.rm = FALSE, useNames = useNames) 920s + stopifnot(all.equal(x_est1, x_est0)) 920s + } 920s + } 920s > 920s 920s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 920s Copyright (C) 2024 The R Foundation for Statistical Computing 920s Platform: s390x-ibm-linux-gnu 920s 920s R is free software and comes with ABSOLUTELY NO WARRANTY. 920s You are welcome to redistribute it under certain conditions. 920s Type 'license()' or 'licence()' for distribution details. 920s 920s R is a collaborative project with many contributors. 920s Type 'contributors()' for more information and 920s 'citation()' on how to cite R or R packages in publications. 920s 920s Type 'demo()' for some demos, 'help()' for on-line help, or 920s 'help.start()' for an HTML browser interface to help. 920s Type 'q()' to quit R. 920s 920s > library("matrixStats") 920s > 920s > ## Create isFALSE() if running on an old version of R 920s > if (!exists("isFALSE", mode="function")) { 920s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 920s + } 920s > 920s > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 920s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 920s + 920s + # Keep naming support consistency same as rowWeightedMeans() 920s + idxs <- which(is.na(w) | w != 0) 920s + nw <- length(idxs) 920s + if (na.rm) na.rm <- anyMissing(x) 920s + if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) { 920s + if (is.na(useNames) || !useNames) names(res) <- NULL 920s + } 920s + else if (isFALSE(useNames)) names(res) <- NULL 920s + 920s + res 920s + } 920s > 920s > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 920s + res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...) 920s + 920s + # Keep naming support consistency same as colWeightedMeans() 920s + idxs <- which(is.na(w) | w != 0) 920s + nw <- length(idxs) 920s + if (!is.null(w) && nw == 0L) { 920s + if (is.na(useNames) || !useNames) names(res) <- NULL 920s + } 920s + else if (isFALSE(useNames)) names(res) <- NULL 920s + 920s + res 920s + } 920s > 920s > 920s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 920s > # Subsetted tests 920s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 920s > source("utils/validateIndicesFramework.R") 920s > # To check names attribute 920s > dimnames <- list(letters[1:6], LETTERS[1:6]) 920s > for (mode in c("numeric", "integer", "logical")) { 920s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 920s + w <- runif(6, min = 0, max = 6) 920s + storage.mode(x) <- mode 920s + storage.mode(w) <- if (mode == "logical") "integer" else mode 920s + if (mode == "numeric") w[1] <- Inf 920s + 920s + # Test with and without dimnames on x 920s + for (setDimnames in c(TRUE, FALSE)) { 920s + if (setDimnames) dimnames(x) <- dimnames 920s + else dimnames(x) <- NULL 920s + 920s + count <- 0L 920s + for (rows in index_cases) { 920s + for (cols in index_cases) { 920s + count <- count + 1L 920s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 920s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 920s + useNames <- useNames[count %% length(useNames) + 1] 920s + 920s + validateIndicesTestMatrix_w(x, w, rows, cols, 920s + ftest = rowWeightedMeans, fsure = rowWeightedMeans_R, 920s + na.rm = na.rm, useNames = useNames) 920s + validateIndicesTestMatrix_w(x, w, rows, cols, 920s + fcoltest = colWeightedMeans, fsure = colWeightedMeans_R, 920s + na.rm = na.rm, useNames = useNames) 920s + } 920s + } 920s + } 920s + } 922s > 922s 922s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 922s Copyright (C) 2024 The R Foundation for Statistical Computing 922s Platform: s390x-ibm-linux-gnu 922s 922s R is free software and comes with ABSOLUTELY NO WARRANTY. 922s You are welcome to redistribute it under certain conditions. 922s Type 'license()' or 'licence()' for distribution details. 922s 922s R is a collaborative project with many contributors. 922s Type 'contributors()' for more information and 922s 'citation()' on how to cite R or R packages in publications. 922s 922s Type 'demo()' for some demos, 'help()' for on-line help, or 922s 'help.start()' for an HTML browser interface to help. 922s Type 'q()' to quit R. 922s 922s > library("matrixStats") 922s > 922s > ## Create isFALSE() if running on an old version of R 922s > if (!exists("isFALSE", mode="function")) { 922s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 922s + } 922s > 922s > rowWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 922s + res <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 922s + 922s + # Keep naming support consistency same as rowWeightedMedians() 922s + if (!is.null(w)) { 922s + if (isFALSE(useNames)) names(res) <- NULL 922s + } 922s + else if (is.na(useNames) || !useNames) names(res) <- NULL 922s + 922s + res 922s + } 922s > 922s > colWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 922s + res <- apply(x, MARGIN = 2L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 922s + 922s + # Keep naming support consistency same as colWeightedMedians() 922s + if (!is.null(w)) { 922s + if (isFALSE(useNames)) names(res) <- NULL 922s + } 922s + else if (is.na(useNames) || !useNames) names(res) <- NULL 922s + 922s + res 922s + } 922s > 922s > set.seed(1) 922s > 922s > x <- matrix(rnorm(20), nrow = 5, ncol = 4) 922s > print(x) 922s [,1] [,2] [,3] [,4] 922s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 922s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 922s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 922s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 922s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 922s > 922s > # To check names attribute 922s > dimnames <- list(letters[1:5], LETTERS[1:4]) 922s > 922s > # Non-weighted row medians 922s > x_est0 <- rowMedians(x) 922s > x_est1 <- rowWeightedMedians(x) 922s > stopifnot(all.equal(x_est1, x_est0)) 922s > x_est2 <- colWeightedMedians(t(x)) 922s > stopifnot(all.equal(x_est2, x_est0)) 922s > # Test with and without dimnames on x 922s > for (setDimnames in c(TRUE, FALSE)) { 922s + if (setDimnames) dimnames(x) <- dimnames 922s + else dimnames(x) <- NULL 922s + # Check names attribute 922s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 922s + x_est0 <- rowMedians(x, useNames = useNames) 922s + x_est1 <- rowWeightedMedians(x, useNames = useNames) 922s + x_est2 <- colWeightedMedians(t(x), useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + stopifnot(all.equal(x_est2, x_est0)) 922s + } 922s + } 922s > 922s > 922s > # Weighted row medians (uniform weights) 922s > w <- rep(2.5, times = ncol(x)) 922s > x_est0 <- rowMedians(x) 922s > x_est1 <- rowWeightedMedians(x, w = w) 922s > stopifnot(all.equal(x_est1, x_est0)) 922s > x_est2 <- colWeightedMedians(t(x), w = w) 922s > stopifnot(all.equal(x_est2, x_est0)) 922s > # Test with and without dimnames on x 922s > for (setDimnames in c(TRUE, FALSE)) { 922s + if (setDimnames) dimnames(x) <- dimnames 922s + else dimnames(x) <- NULL 922s + # Check names attribute 922s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 922s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 922s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 922s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + } 922s + } 922s > 922s > 922s > # Weighted row medians (excluding some columns) 922s > w <- c(1, 1, 0, 1) 922s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 922s > x_est1 <- rowWeightedMedians(x, w = w) 922s > stopifnot(all.equal(x_est1, x_est0)) 922s > x_est2 <- colWeightedMedians(t(x), w = w) 922s > stopifnot(all.equal(x_est2, x_est0)) 922s > # Test with and without dimnames on x 922s > for (setDimnames in c(TRUE, FALSE)) { 922s + if (setDimnames) dimnames(x) <- dimnames 922s + else dimnames(x) <- NULL 922s + # Check names attribute 922s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 922s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 922s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 922s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + } 922s + } 922s > 922s > # Weighted row medians (excluding some columns) 922s > w <- c(0, 1, 0, 0) 922s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 922s > x_est1 <- rowWeightedMedians(x, w = w) 922s > stopifnot(all.equal(x_est1, x_est0)) 922s > x_est2 <- colWeightedMedians(t(x), w = w) 922s > stopifnot(all.equal(x_est2, x_est0)) 922s > # Test with and without dimnames on x 922s > for (setDimnames in c(TRUE, FALSE)) { 922s + if (setDimnames) dimnames(x) <- dimnames 922s + else dimnames(x) <- NULL 922s + # Check names attribute 922s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 922s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 922s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 922s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + } 922s + } 922s > 922s > # Weighted row medians (all zero weights) 922s > w <- c(0, 0, 0, 0) 922s > x_est0 <- rowMedians(x[, (w == 1), drop = FALSE]) 922s > x_est1 <- rowWeightedMedians(x, w = w) 922s > stopifnot(all.equal(x_est1, x_est0)) 922s > x_est2 <- colWeightedMedians(t(x), w = w) 922s > stopifnot(all.equal(x_est2, x_est0)) 922s > # Test with and without dimnames on x 922s > for (setDimnames in c(TRUE, FALSE)) { 922s + if (setDimnames) dimnames(x) <- dimnames 922s + else dimnames(x) <- NULL 922s + # Check names attribute 922s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 922s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 922s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 922s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + } 922s + } 922s > 922s > # Weighted medians by rows and columns 922s > w <- 1:4 922s > x_est1 <- rowWeightedMedians(x, w = w) 922s > x_est2 <- colWeightedMedians(t(x), w = w) 922s > stopifnot(all.equal(x_est2, x_est1)) 922s > # Test with and without dimnames on x 922s > for (setDimnames in c(TRUE, FALSE)) { 922s + if (setDimnames) dimnames(x) <- dimnames 922s + else dimnames(x) <- NULL 922s + # Check names attribute 922s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 922s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 922s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 922s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + } 922s + } 922s > 922s > 922s > # Weighted row medians with missing values 922s > x_est0 <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = TRUE) 922s > print(x_est0) 922s [1] -0.04493361 0.23519330 0.73832471 0.65759463 0.59390132 922s > x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE) 922s > print(x_est1) 922s [1] -0.04493361 0.23519330 0.73832471 0.65759463 0.59390132 922s > stopifnot(all.equal(x_est1, x_est0)) 922s > x_est2 <- colWeightedMedians(t(x), w = w) 922s > stopifnot(all.equal(x_est2, x_est0)) 922s > # Test with and without dimnames on x 922s > for (setDimnames in c(TRUE, FALSE)) { 922s + if (setDimnames) dimnames(x) <- dimnames 922s + else dimnames(x) <- NULL 922s + # Check names attribute 922s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 922s + x_est0 <- rowWeightedMedians_R(x, w = w, na.rm = TRUE, useNames = useNames) 922s + x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + x_est0 <- colWeightedMedians_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 922s + x_est1 <- colWeightedMedians(t(x), w = w, na.rm = TRUE, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + } 922s + } 922s > 922s > # Weighted medians by rows and columns 922s > w <- 1:4 922s > x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE) 922s > x_est2 <- colWeightedMedians(t(x), w = w, na.rm = TRUE) 922s > stopifnot(all.equal(x_est2, x_est1)) 922s > # Test with and without dimnames on x 922s > for (setDimnames in c(TRUE, FALSE)) { 922s + if (setDimnames) dimnames(x) <- dimnames 922s + else dimnames(x) <- NULL 922s + # Check names attribute 922s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 922s + x_est0 <- rowWeightedMedians_R(x, w = w, na.rm = TRUE, useNames = useNames) 922s + x_est1 <- rowWeightedMedians(x, w = w, na.rm = TRUE, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + x_est0 <- colWeightedMedians_R(t(x), w = w, na.rm = TRUE, useNames = useNames) 922s + x_est1 <- colWeightedMedians(t(x), w = w, na.rm = TRUE, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + } 922s + } 922s > 922s > 922s > # Inf weight 922s > x <- matrix(1:2, nrow = 1, ncol = 2) 922s > w <- c(7, Inf) 922s > x_est1 <- rowWeightedMedians(x, w = w) 922s > x_est2 <- colWeightedMedians(t(x), w = w) 922s > stopifnot(identical(2, x_est1)) 922s > stopifnot(identical(2, x_est2)) 922s > # Test with and without dimnames on x 922s > dimnames <- list("a", LETTERS[1:2]) 922s > for (setDimnames in c(TRUE, FALSE)) { 922s + if (setDimnames) dimnames(x) <- dimnames 922s + else dimnames(x) <- NULL 922s + # Check names attribute 922s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 922s + x_est0 <- rowWeightedMedians_R(x, w = w, useNames = useNames) 922s + x_est1 <- rowWeightedMedians(x, w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + x_est0 <- colWeightedMedians_R(t(x), w = w, useNames = useNames) 922s + x_est1 <- colWeightedMedians(t(x), w = w, useNames = useNames) 922s + stopifnot(all.equal(x_est1, x_est0)) 922s + } 922s + } 922s > 922s 922s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 922s Copyright (C) 2024 The R Foundation for Statistical Computing 922s Platform: s390x-ibm-linux-gnu 922s 922s R is free software and comes with ABSOLUTELY NO WARRANTY. 922s You are welcome to redistribute it under certain conditions. 922s Type 'license()' or 'licence()' for distribution details. 922s 922s R is a collaborative project with many contributors. 922s Type 'contributors()' for more information and 922s 'citation()' on how to cite R or R packages in publications. 922s 922s Type 'demo()' for some demos, 'help()' for on-line help, or 922s 'help.start()' for an HTML browser interface to help. 922s Type 'q()' to quit R. 922s 922s > library("matrixStats") 922s > 922s > ## Create isFALSE() if running on an old version of R 922s > if (!exists("isFALSE", mode="function")) { 922s + isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x 922s + } 922s > 922s > rowWeightedMedians_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) { 922s + res <- apply(x, MARGIN = 1L, FUN = weightedMedian, w = w, na.rm = na.rm, ...) 922s + 922s + # Keep naming support consistency same as rowWeightedMedians() 922s + if (!is.null(w)) { 922s + if (isFALSE(useNames)) names(res) <- NULL 922s + } 922s + else if (is.na(useNames) || !useNames) names(res) <- NULL 922s + 922s + res 922s + } 922s > 922s > 922s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 922s > # Subsetted tests 922s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 922s > source("utils/validateIndicesFramework.R") 922s > # To check names attribute 922s > dimnames <- list(letters[1:6], LETTERS[1:6]) 922s > for (mode in c("numeric", "integer", "logical")) { 922s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 922s + w <- runif(6, min = 0, max = 6) 922s + storage.mode(x) <- mode 922s + storage.mode(w) <- if (mode == "logical") "integer" else mode 922s + if (mode == "numeric") w[1] <- Inf 922s + 922s + # Test with and without dimnames on x 922s + for (setDimnames in c(TRUE, FALSE)) { 922s + if (setDimnames) dimnames(x) <- dimnames 922s + else dimnames(x) <- NULL 922s + 922s + count <- 0L 922s + for (rows in index_cases) { 922s + for (cols in index_cases) { 922s + count <- count + 1L 922s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 922s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 922s + useNames <- useNames[count %% length(useNames) + 1] 922s + 922s + validateIndicesTestMatrix_w(x, w, rows, cols, 922s + ftest = rowWeightedMedians, 922s + fsure = rowWeightedMedians_R, 922s + na.rm = na.rm, useNames = useNames) 922s + validateIndicesTestMatrix_w(x, w, rows, cols, 922s + fcoltest = colWeightedMedians, 922s + fsure = rowWeightedMedians_R, 922s + na.rm = na.rm, useNames = useNames) 922s + } 922s + } 922s + } 922s + } 924s > 924s 924s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 924s Copyright (C) 2024 The R Foundation for Statistical Computing 924s Platform: s390x-ibm-linux-gnu 924s 924s R is free software and comes with ABSOLUTELY NO WARRANTY. 924s You are welcome to redistribute it under certain conditions. 924s Type 'license()' or 'licence()' for distribution details. 924s 924s R is a collaborative project with many contributors. 924s Type 'contributors()' for more information and 924s 'citation()' on how to cite R or R packages in publications. 924s 924s Type 'demo()' for some demos, 'help()' for on-line help, or 924s 'help.start()' for an HTML browser interface to help. 924s Type 'q()' to quit R. 924s 924s > library("matrixStats") 924s > 924s > set.seed(1) 924s > 924s > x <- matrix(rnorm(20), nrow = 5L, ncol = 4L) 924s > print(x) 924s [,1] [,2] [,3] [,4] 924s [1,] -0.6264538 -0.8204684 1.5117812 -0.04493361 924s [2,] 0.1836433 0.4874291 0.3898432 -0.01619026 924s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 924s [4,] 1.5952808 0.5757814 -2.2146999 0.82122120 924s [5,] 0.3295078 -0.3053884 1.1249309 0.59390132 924s > 924s > # To check names attribute 924s > dimnames <- list(letters[1:5], LETTERS[1:4]) 924s > 924s > # Weighted row variances (uniform weights - all w = 1) 924s > # Non-weighted row variances 924s > x_est0 <- rowVars(x) 924s > w <- rep(1, times = ncol(x)) 924s > x_est1 <- rowWeightedVars(x, w = w) 924s > print(x_est1) 924s [1] 1.11767161 0.05022969 0.83582537 2.76819528 0.35351857 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > x_est2 <- colWeightedVars(t(x), w = w) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > # Check names attribute 924s > dimnames(x) <- dimnames 924s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 924s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > x_est0 <- rowVars(x, useNames = TRUE) 924s > if (!matrixStats:::isUseNamesNADefunct()) { 924s + x_est1 <- rowWeightedVars(x, w = w, useNames = NA) 924s + x_est2 <- colWeightedVars(t(x), w = w, useNames = NA) 924s + stopifnot(all.equal(x_est1, x_est0)) 924s + stopifnot(all.equal(x_est2, x_est0)) 924s + } 924s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 924s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > dimnames(x) <- NULL 924s > 924s > 924s > # Weighted row variances (uniform weights - all w = 3) 924s > x3 <- cbind(x, x, x) 924s > x_est0 <- rowVars(x3) 924s > w <- rep(3, times = ncol(x)) 924s > x_est1 <- rowWeightedVars(x, w = w) 924s > print(x_est1) 924s [1] 0.91445859 0.04109702 0.68385712 2.26488705 0.28924246 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > x_est2 <- colWeightedVars(t(x), w = w) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > # Check names attribute 924s > dimnames(x) <- dimnames 924s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 924s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > x3 <- cbind(x, x, x) 924s > x_est0 <- rowVars(x3, useNames = TRUE) 924s > if (!matrixStats:::isUseNamesNADefunct()) { 924s + x_est1 <- rowWeightedVars(x, w = w, useNames = NA) 924s + x_est2 <- colWeightedVars(t(x), w = w, useNames = NA) 924s + stopifnot(all.equal(x_est1, x_est0)) 924s + stopifnot(all.equal(x_est2, x_est0)) 924s + } 924s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 924s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > dimnames(x) <- NULL 924s > 924s > 924s > # Weighted row variances (excluding some columns) 924s > w <- c(1, 1, 0, 1) 924s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 924s > x_est1 <- rowWeightedVars(x, w = w) 924s > print(x_est1) 924s [1] 0.16287693 0.06430861 0.94767651 0.28313135 0.21361984 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > x_est2 <- colWeightedVars(t(x), w = w) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > # Check names attribute 924s > dimnames(x) <- dimnames 924s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 924s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 924s > if (!matrixStats:::isUseNamesNADefunct()) { 924s + x_est1 <- rowWeightedVars(x, w = w, useNames = NA) 924s + x_est2 <- colWeightedVars(t(x), w = w, useNames = NA) 924s + stopifnot(all.equal(x_est1, x_est0)) 924s + stopifnot(all.equal(x_est2, x_est0)) 924s + } 924s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 924s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > dimnames(x) <- NULL 924s > 924s > 924s > # Weighted row variances (excluding some columns) 924s > w <- c(0, 1, 0, 0) 924s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 924s > x_est1 <- rowWeightedVars(x, w = w) 924s > #stopifnot(all.equal(x_est1, x_est0)) 924s > x_est2 <- colWeightedVars(t(x), w = w) 924s > stopifnot(all.equal(x_est2, x_est1)) 924s > # Check names attribute 924s > dimnames(x) <- dimnames 924s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 924s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 924s > if (!matrixStats:::isUseNamesNADefunct()) { 924s + x_est1 <- rowWeightedVars(x, w = w, useNames = NA) 924s + x_est2 <- colWeightedVars(t(x), w = w, useNames = NA) 924s + stopifnot(all.equal(x_est1, x_est0)) 924s + stopifnot(all.equal(x_est2, x_est0)) 924s + } 924s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 924s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > dimnames(x) <- NULL 924s > 924s > 924s > # Weighted row variances (all zero weights) 924s > w <- c(0, 0, 0, 0) 924s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE]) 924s > x_est1 <- rowWeightedVars(x, w = w) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > x_est2 <- colWeightedVars(t(x), w = w) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > # Check names attribute 924s > dimnames(x) <- dimnames 924s > x_est1 <- rowWeightedVars(x, w = w, useNames = FALSE) 924s > x_est2 <- colWeightedVars(t(x), w = w, useNames = FALSE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > x_est0 <- rowVars(x[, (w == 1), drop = FALSE], useNames = TRUE) 924s > if (!matrixStats:::isUseNamesNADefunct()) { 924s + x_est1 <- rowWeightedVars(x, w = w, useNames = NA) 924s + x_est2 <- colWeightedVars(t(x), w = w, useNames = NA) 924s + stopifnot(all.equal(x_est1, x_est0)) 924s + stopifnot(all.equal(x_est2, x_est0)) 924s + } 924s > x_est1 <- rowWeightedVars(x, w = w, useNames = TRUE) 924s > x_est2 <- colWeightedVars(t(x), w = w, useNames = TRUE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > dimnames(x) <- NULL 924s > 924s > # Weighted variances by rows and columns 924s > w <- 1:4 924s > # Test with and without dimnames on x 924s > for (setDimnames in c(TRUE, FALSE)) { 924s + if (setDimnames) dimnames(x) <- dimnames 924s + else dimnames(x) <- NULL 924s + # Check names attribute 924s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 924s + x_est1 <- rowWeightedVars(x, w = w, useNames = useNames) 924s + print(x_est1) 924s + x_est2 <- colWeightedVars(t(x), w = w, useNames = useNames) 924s + stopifnot(all.equal(x_est2, x_est1)) 924s + } 924s + } 924s a b c d e 924s 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 924s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 924s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 924s [1] 0.90747094 0.05040463 0.65089440 2.28697479 0.27902734 924s > 924s > 924s > x[sample(length(x), size = 0.3 * length(x))] <- NA 924s > print(x) 924s [,1] [,2] [,3] [,4] 924s [1,] -0.6264538 NA 1.5117812 -0.04493361 924s [2,] 0.1836433 NA NA -0.01619026 924s [3,] -0.8356286 0.7383247 -0.6212406 0.94383621 924s [4,] 1.5952808 NA -2.2146999 0.82122120 924s [5,] 0.3295078 NA NA 0.59390132 924s > 924s > # Non-weighted row variances with missing values 924s > x_est0 <- rowVars(x, na.rm = TRUE) 924s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE) 924s > print(x_est1) 924s [1] 1.22226258 0.01996673 0.83582537 4.05532299 0.03495197 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > # Check names attribute 924s > dimnames(x) <- dimnames 924s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = FALSE) 924s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = FALSE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > x_est0 <- rowVars(x, na.rm = TRUE, useNames = TRUE) 924s > x_est1 <- rowWeightedVars(x, w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = TRUE) 924s > x_est2 <- colWeightedVars(t(x), w = rep(1, times = ncol(x)), na.rm = TRUE, useNames = TRUE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > dimnames(x) <- NULL 924s > 924s > 924s > # Weighted row variances with missing values 924s > # Test with and without dimnames on x 924s > for (setDimnames in c(TRUE, FALSE)) { 924s + if (setDimnames) dimnames(x) <- dimnames 924s + else dimnames(x) <- NULL 924s + # Check names attribute 924s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 924s + x_est1 <- rowWeightedVars(x, w = w, na.rm = TRUE, useNames = useNames) 924s + print(x_est1) 924s + x_est2 <- colWeightedVars(t(x), w = w, na.rm = TRUE, useNames = useNames) 924s + stopifnot(all.equal(x_est2, x_est1)) 924s + } 924s + } 924s a b c d e 924s 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 924s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 924s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 924s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 924s > 924s > 924s > # Weighted variances by rows and columns 924s > w <- 1:4 924s > # Test with and without dimnames on x 924s > for (setDimnames in c(TRUE, FALSE)) { 924s + if (setDimnames) dimnames(x) <- dimnames 924s + else dimnames(x) <- NULL 924s + # Check names attribute 924s + for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) { 924s + x_est1 <- rowWeightedVars(x, w = w, na.rm = TRUE, useNames = useNames) 924s + print(x_est1) 924s + x_est2 <- colWeightedVars(t(x), w = w, na.rm = TRUE, useNames = useNames) 924s + stopifnot(all.equal(x_est2, x_est1)) 924s + } 924s + } 924s a b c d e 924s 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 924s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 924s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 924s [1] 0.788377504 0.007986693 0.650894398 2.795470241 0.013980790 924s > 924s > 924s > # Weighted row standard deviation (excluding some columns) 924s > w <- c(1, 1, 0, 1) 924s > ## FIXME: rowVars()/rowSds() needs na.rm = FALSE (wrong default) 924s > x_est0 <- rowSds(x[, (w == 1), drop = FALSE], na.rm = FALSE) 924s > x_est1 <- rowWeightedSds(x, w = w) 924s > print(x_est1) 924s [1] NA NA 0.9734868 NA NA 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > # Check names attribute 924s > dimnames(x) <- dimnames 924s > x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = FALSE) 924s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = FALSE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > x_est0 <- rowSds(x[, (w == 1), drop = FALSE], na.rm = FALSE, useNames = TRUE) 924s > if (!matrixStats:::isUseNamesNADefunct()) { 924s + x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = NA) 924s + x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = NA) 924s + stopifnot(all.equal(x_est1, x_est0)) 924s + stopifnot(all.equal(x_est2, x_est0)) 924s + } 924s > x_est1 <- rowWeightedSds(x, w = w, na.rm = FALSE, useNames = TRUE) 924s > x_est2 <- colWeightedSds(t(x), w = w, na.rm = FALSE, useNames = TRUE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > dimnames(x) <- NULL 924s > 924s > 924s > # Weighted row MADs (excluding some columns) 924s > w <- c(1, 1, 0, 1) 924s > x_est0 <- rowMads(x[, (w == 1), drop = FALSE]) 924s > x_est1 <- rowWeightedMads(x, w = w) 924s > print(x_est1) 924s [1] NA NA 0.3046914 NA NA 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > x_est2 <- colWeightedMads(t(x), w = w) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > # Check names attribute 924s > dimnames(x) <- dimnames 924s > x_est1 <- rowWeightedMads(x, w = w, useNames = FALSE) 924s > x_est2 <- colWeightedMads(t(x), w = w, useNames = FALSE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > x_est0 <- rowMads(x[, (w == 1), drop = FALSE], useNames = TRUE) 924s > if (!matrixStats:::isUseNamesNADefunct()) { 924s + x_est1 <- rowWeightedMads(x, w = w, useNames = NA) 924s + x_est2 <- colWeightedMads(t(x), w = w, useNames = NA) 924s + stopifnot(all.equal(x_est1, x_est0)) 924s + stopifnot(all.equal(x_est2, x_est0)) 924s + } 924s > x_est1 <- rowWeightedMads(x, w = w, useNames = TRUE) 924s > x_est2 <- colWeightedMads(t(x), w = w, useNames = TRUE) 924s > stopifnot(all.equal(x_est1, x_est0)) 924s > stopifnot(all.equal(x_est2, x_est0)) 924s > dimnames(x) <- NULL 924s > 924s 924s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 924s Copyright (C) 2024 The R Foundation for Statistical Computing 924s Platform: s390x-ibm-linux-gnu 924s 924s R is free software and comes with ABSOLUTELY NO WARRANTY. 924s You are welcome to redistribute it under certain conditions. 924s Type 'license()' or 'licence()' for distribution details. 924s 924s R is a collaborative project with many contributors. 924s Type 'contributors()' for more information and 924s 'citation()' on how to cite R or R packages in publications. 924s 924s Type 'demo()' for some demos, 'help()' for on-line help, or 924s 'help.start()' for an HTML browser interface to help. 924s Type 'q()' to quit R. 924s 925s > library("matrixStats") 925s > 925s > fcns <- list( 925s + weightedVar = c(rowWeightedVars, colWeightedVars), 925s + weightedSd = c(rowWeightedSds, colWeightedSds), 925s + weightedMad = c(rowWeightedMads, colWeightedMads) 925s + ) 925s > 925s > 925s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 925s > # Subsetted tests 925s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 925s > source("utils/validateIndicesFramework.R") 925s > # To check names attribute 925s > dimnames <- list(letters[1:6], LETTERS[1:6]) 925s > for (fcn in names(fcns)) { 925s + cat(sprintf("subsetted tests on matrix %s()...\n", fcn)) 925s + row_fcn <- fcns[[fcn]][[1]] 925s + col_fcn <- fcns[[fcn]][[2]] 925s + 925s + for (mode in c("numeric", "integer")) { 925s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 925s + w <- runif(6, min = 0, max = 6) 925s + storage.mode(x) <- mode 925s + storage.mode(w) <- mode 925s + if (mode == "numeric") w[1] <- Inf 925s + 925s + # Test with and without dimnames on x 925s + for (setDimnames in c(TRUE, FALSE)) { 925s + if (setDimnames) dimnames(x) <- dimnames 925s + else dimnames(x) <- NULL 925s + 925s + count <- 0L 925s + for (rows in index_cases) { 925s + for (cols in index_cases) { 925s + count <- count + 1L 925s + na.rm <- c(TRUE, FALSE)[count %% 2 + 1] 925s + useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE) 925s + useNames <- useNames[count %% length(useNames) + 1] 925s + 925s + validateIndicesTestMatrix_w(x, w, rows, cols, 925s + ftest = row_fcn, fsure = row_fcn, 925s + na.rm = na.rm, useNames = useNames) 925s + validateIndicesTestMatrix_w(x, w, rows, cols, 925s + fcoltest = col_fcn, fsure = row_fcn, 925s + na.rm = na.rm, useNames = useNames) 925s + } 925s + } 925s + } 925s + } 925s + cat(sprintf("%s()...DONE\n", fcn)) 925s + } 925s subsetted tests on matrix weightedVar()... 926s weightedVar()...DONE 926s subsetted tests on matrix weightedSd()... 928s weightedSd()...DONE 928s subsetted tests on matrix weightedMad()... 929s weightedMad()...DONE 929s > 929s 929s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 929s Copyright (C) 2024 The R Foundation for Statistical Computing 929s Platform: s390x-ibm-linux-gnu 929s 929s R is free software and comes with ABSOLUTELY NO WARRANTY. 929s You are welcome to redistribute it under certain conditions. 929s Type 'license()' or 'licence()' for distribution details. 929s 929s R is a collaborative project with many contributors. 929s Type 'contributors()' for more information and 929s 'citation()' on how to cite R or R packages in publications. 929s 929s Type 'demo()' for some demos, 'help()' for on-line help, or 929s 'help.start()' for an HTML browser interface to help. 929s Type 'q()' to quit R. 929s 929s > library("matrixStats") 929s > 929s > signTabulate0 <- function(x, ...) { 929s + nneg <- sum(x < 0, na.rm = TRUE) 929s + nzero <- sum(x == 0, na.rm = TRUE) 929s + npos <- sum(x > 0, na.rm = TRUE) 929s + nna <- sum(is.na(x)) 929s + nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 929s + nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 929s + res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 929s + res <- as.double(res) 929s + names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 929s + if (is.integer(x)) res <- res[1:4] 929s + res 929s + } # signTabulate0() 929s > 929s > 929s > # Simulate data 929s > set.seed(0xBEEF) 929s > n <- 100L 929s > x <- runif(n) 929s > x[sample(n, size = 0.1 * n)] <- 0 929s > x[sample(n, size = 0.1 * n)] <- NA_real_ 929s > x[sample(n, size = 0.1 * n)] <- -Inf 929s > x[sample(n, size = 0.1 * n)] <- +Inf 929s > 929s > # Doubles 929s > message("Doubles:") 929s > counts0 <- signTabulate0(x) 929s > print(counts0) 929s -1 0 +1 NA -Inf +Inf 929s 9 7 77 7 9 10 929s > counts1 <- signTabulate(x) 929s > print(counts1) 929s -1 0 +1 NA -Inf +Inf 929s 9 7 77 7 9 10 929s > stopifnot(identical(counts1, counts0)) 929s Doubles: 929s > 929s > # Integers 929s > message("Integers:") 929s > x <- suppressWarnings(as.integer(x)) 929s > counts0 <- signTabulate0(x) 929s > print(counts0) 929s -1 0 +1 NA 929s 0 74 0 26 929s > counts1 <- signTabulate(x) 929s > print(counts1) 929s -1 0 +1 NA 929s 0 74 0 26 929s > stopifnot(identical(counts1, counts0)) 929s > 929s Integers: 929s 929s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 929s Copyright (C) 2024 The R Foundation for Statistical Computing 929s Platform: s390x-ibm-linux-gnu 929s 929s R is free software and comes with ABSOLUTELY NO WARRANTY. 929s You are welcome to redistribute it under certain conditions. 929s Type 'license()' or 'licence()' for distribution details. 929s 929s R is a collaborative project with many contributors. 929s Type 'contributors()' for more information and 929s 'citation()' on how to cite R or R packages in publications. 929s 929s Type 'demo()' for some demos, 'help()' for on-line help, or 929s 'help.start()' for an HTML browser interface to help. 929s Type 'q()' to quit R. 929s 929s > library("matrixStats") 930s > 930s > signTabulate0 <- function(x, ...) { 930s + nneg <- sum(x < 0, na.rm = TRUE) 930s + nzero <- sum(x == 0, na.rm = TRUE) 930s + npos <- sum(x > 0, na.rm = TRUE) 930s + nna <- sum(is.na(x)) 930s + nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 930s + nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 930s + res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 930s + res <- as.double(res) 930s + names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 930s + if (is.integer(x)) res <- res[1:4] 930s + res 930s + } # signTabulate0() 930s > 930s > 930s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 930s > # Subsetted tests 930s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 930s > source("utils/validateIndicesFramework.R") 930s > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 930s > x[2:3, 4:5] <- +Inf 930s > x[4:5, 1:2] <- -Inf 930s > for (idxs in index_cases) { 930s + validateIndicesTestVector(x, idxs, 930s + ftest = signTabulate, fsure = signTabulate0) 930s + } 930s > 930s 930s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 930s Copyright (C) 2024 The R Foundation for Statistical Computing 930s Platform: s390x-ibm-linux-gnu 930s 930s R is free software and comes with ABSOLUTELY NO WARRANTY. 930s You are welcome to redistribute it under certain conditions. 930s Type 'license()' or 'licence()' for distribution details. 930s 930s R is a collaborative project with many contributors. 930s Type 'contributors()' for more information and 930s 'citation()' on how to cite R or R packages in publications. 930s 930s Type 'demo()' for some demos, 'help()' for on-line help, or 930s 'help.start()' for an HTML browser interface to help. 930s Type 'q()' to quit R. 930s 930s > library("matrixStats") 930s > options(warn = 1) 930s > 930s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 930s > # Consistency checks 930s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 930s > set.seed(1) 930s > 930s > sum2_R <- function(x, na.rm = FALSE, idxs = NULL) { 930s + if (is.null(idxs)) { 930s + sum(x, na.rm = na.rm) 930s + } else { 930s + sum(x[idxs], na.rm = na.rm) 930s + } 930s + } # sum2_R() 930s > 930s > 930s > cat("Consistency checks:\n") 930s Consistency checks: 930s > for (kk in 1:20) { 930s + cat("Random test #", kk, "\n", sep = "") 930s + 930s + # Simulate data in a matrix of any shape 930s + n <- sample(1e3, size = 1L) 930s + x <- rnorm(n, sd = 100) 930s + 930s + # Add NAs? 930s + if ((kk %% 4) %in% c(3, 0)) { 930s + cat("Adding NAs\n") 930s + nna <- sample(n, size = 1L) 930s + na_values <- c(NA_real_, NaN) 930s + t <- sample(na_values, size = nna, replace = TRUE) 930s + x[sample(length(x), size = nna)] <- t 930s + } 930s + 930s + # Integer or double? 930s + if ((kk %% 4) %in% c(2, 0)) { 930s + cat("Coercing to integers\n") 930s + storage.mode(x) <- "integer" 930s + } 930s + 930s + na.rm <- sample(c(TRUE, FALSE), size = 1L) 930s + 930s + # Sum over all 930s + y0 <- sum2_R(x, na.rm = na.rm) 930s + y1 <- sum2(x, na.rm = na.rm) 930s + stopifnot(all.equal(y1, y0)) 930s + 930s + # Sum over subset 930s + nidxs <- sample(n, size = 1L) 930s + idxs <- sample(n, size = nidxs) 930s + y0 <- sum2_R(x, na.rm = na.rm, idxs = idxs) 930s + y1 <- sum2(x, na.rm = na.rm, idxs = idxs) 930s + stopifnot(all.equal(y1, y0)) 930s + 930s + if (storage.mode(x) == "integer") { 930s + storage.mode(x) <- "logical" 930s + 930s + y0 <- sum2_R(x, na.rm = na.rm) 930s + y1 <- sum2(x, na.rm = na.rm) 930s + stopifnot(all.equal(y1, y0)) 930s + 930s + y0 <- sum2_R(x, na.rm = na.rm, idxs = idxs) 930s + y1 <- sum2(x, na.rm = na.rm, idxs = idxs) 930s + stopifnot(all.equal(y1, y0)) 930s + } 930s + } # for (kk ...) 930s Random test #1 930s Random test #2 930s Coercing to integers 930s Random test #3 930s Adding NAs 930s Random test #4 930s Adding NAs 930s Coercing to integers 930s Random test #5 930s Random test #6 930s Coercing to integers 930s Random test #7 930s Adding NAs 930s Random test #8 930s Adding NAs 930s Coercing to integers 930s Random test #9 930s Random test #10 930s Coercing to integers 930s Random test #11 930s Adding NAs 930s Random test #12 930s Adding NAs 930s Coercing to integers 930s Random test #13 930s Random test #14 930s Coercing to integers 930s Random test #15 930s Adding NAs 930s Random test #16 930s Adding NAs 930s Coercing to integers 930s Random test #17 930s Random test #18 930s Coercing to integers 930s Random test #19 930s Adding NAs 930s Random test #20 930s Adding NAs 930s Coercing to integers 930s > 930s > 930s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 930s > # All missing values 930s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 930s > for (n in 0:2) { 930s + for (na.rm in c(FALSE, TRUE)) { 930s + x <- rep(NA_real_, times = n) 930s + y0 <- sum(x, na.rm = na.rm) 930s + y <- sum2(x, na.rm = na.rm) 930s + stopifnot(all.equal(y, y0)) 930s + 930s + x <- rep(NA_integer_, times = n) 930s + y0 <- sum(x, na.rm = na.rm) 930s + y <- sum2(x, na.rm = na.rm) 930s + stopifnot(all.equal(y, y0)) 930s + 930s + x <- rep(NA, times = n) 930s + y0 <- sum(x, na.rm = na.rm) 930s + y <- sum2(x, na.rm = na.rm) 930s + stopifnot(all.equal(y, y0)) 930s + } 930s + } 930s > 930s > 930s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 930s > # Special cases 930s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > for (na.rm in c(FALSE, TRUE)) { 937s + # Summing over zero elements (integers) 937s + x <- integer(0) 937s + s1 <- sum(x, na.rm = na.rm) 937s + s2 <- sum2(x, na.rm = na.rm) 937s + stopifnot(identical(s1, s2)) 937s + 937s + x <- 1:10 937s + idxs <- integer(0) 937s + s1 <- sum(x[idxs], na.rm = na.rm) 937s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 937s + stopifnot(identical(s1, s2)) 937s + 937s + # Summing over NA_integer_:s 937s + x <- rep(NA_integer_, times = 10L) 937s + s1 <- sum(x, na.rm = na.rm) 937s + s2 <- sum2(x, na.rm = na.rm) 937s + stopifnot(identical(s1, s2)) 937s + 937s + x <- rep(NA_integer_, times = 10L) 937s + idxs <- 1:5 937s + s1 <- sum(x[idxs], na.rm = na.rm) 937s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 937s + stopifnot(identical(s1, s2)) 937s + 937s + 937s + # Summing over zero elements (doubles) 937s + x <- double(0) 937s + s1 <- sum(x) 937s + s2 <- sum2(x) 937s + stopifnot( 937s + identical(s1, 0), 937s + identical(s1, s2) 937s + ) 937s + 937s + x <- as.double(1:10) 937s + idxs <- integer(0) 937s + s1 <- sum(x[idxs]) 937s + s2 <- sum2(x, idxs = idxs) 937s + stopifnot( 937s + identical(s1, 0), 937s + identical(s1, s2) 937s + ) 937s + 937s + # Summing over NA_real_:s 937s + x <- rep(NA_real_, times = 10L) 937s + s1 <- sum(x, na.rm = na.rm) 937s + s2 <- sum2(x, na.rm = na.rm) 937s + stopifnot( 937s + !na.rm || s1 == 0, 937s + identical(s1, s2) 937s + ) 937s + 937s + x <- rep(NA_real_, times = 10L) 937s + idxs <- 1:5 937s + s1 <- sum(x[idxs], na.rm = na.rm) 937s + s2 <- sum2(x, idxs = idxs, na.rm = na.rm) 937s + stopifnot( 937s + !na.rm || s1 == 0, 937s + identical(s1, s2) 937s + ) 937s + 937s + # Summing over -Inf:s 937s + x <- rep(-Inf, times = 3L) 937s + s1 <- sum(x, na.rm = na.rm) 937s + s2 <- sum2(x, na.rm = na.rm) 937s + stopifnot( 937s + is.infinite(s1) && s1 < 0, 937s + identical(s1, s2) 937s + ) 937s + 937s + # Summing over +Inf:s 937s + x <- rep(+Inf, times = 3L) 937s + s1 <- sum(x, na.rm = na.rm) 937s + s2 <- sum2(x, na.rm = na.rm) 937s + stopifnot(identical(s1, s2)) 937s + stopifnot( 937s + is.infinite(s1) && s1 > 0, 937s + identical(s1, s2) 937s + ) 937s + 937s + # Summing over mix of -Inf:s and +Inf:s 937s + x <- rep(c(-Inf, +Inf), times = 3L) 937s + s1 <- sum(x, na.rm = na.rm) 937s + s2 <- sum2(x, na.rm = na.rm) 937s + stopifnot( 937s + is.nan(s1), 937s + identical(s1, s2) 937s + ) 937s + 937s + # Summing over mix of -Inf:s and +Inf:s and numerics 937s + x <- rep(c(-Inf, +Inf, 3.14), times = 2L) 937s + s1 <- sum(x, na.rm = na.rm) 937s + s2 <- sum2(x, na.rm = na.rm) 937s + stopifnot( 937s + is.nan(s1), 937s + identical(s1, s2) 937s + ) 937s + 937s + # Summing over mix of NaN, NA, +Inf, and numerics 937s + x <- c(NaN, NA, +Inf, 3.14) 937s + s1 <- sum(x, na.rm = na.rm) 937s + s2 <- sum2(x, na.rm = na.rm) 937s + if (na.rm) { 937s + stopifnot( 937s + is.infinite(s1) && s1 > 0, 937s + identical(s2, s1) 937s + ) 937s + } else { 937s + stopifnot(is.na(s1), is.na(s2)) 937s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 937s + ## returned here (as one would expect). NaN might very well be returned, 937s + ## when both NA and NaN are involved. This is an accepted feature in R, 937s + ## which is documented in help("is.nan"). See also 937s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 937s + ## Thus, we cannot guarantee that s1 is identical to s0. 937s + } 937s + 937s + # Summing over mix of NaN, NA, +Inf, and numerics 937s + x <- c(NA, NaN, +Inf, 3.14) 937s + s1 <- sum(x, na.rm = na.rm) 937s + s2 <- sum2(x, na.rm = na.rm) 937s + if (na.rm) { 937s + stopifnot( 937s + is.infinite(s1) && s1 > 0, 937s + identical(s2, s1) 937s + ) 937s + } else { 937s + stopifnot(is.na(s1), is.na(s2)) 937s + ## NOTE, due to compiler optimization, it is not guaranteed that NA is 937s + ## returned here (as one would expect). NaN might very well be returned, 937s + ## when both NA and NaN are involved. This is an accepted feature in R, 937s + ## which is documented in help("is.nan"). See also 937s + ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html. 937s + ## Thus, we cannot guarantee that s1 is identical to s0. 937s + } 937s + } 937s > 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Summing of large integers 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > x <- c(.Machine$integer.max, 1L, -.Machine$integer.max) 937s > 937s > # Total gives integer overflow 937s > s1 <- sum(x[1:2]) # NA_integer_ w/ warning 937s > s2 <- sum2(x[1:2]) # NA_integer_ w/ warning 937s > stopifnot( 937s + getRversion() >= "3.5.0" || identical(s1, NA_integer_), 937s + identical(s2, NA_integer_) 937s + ) 937s > 937s > ## Assert above warning 937s > res <- tryCatch({ 937s + s2 <- sum2(x[1:2]) 937s + }, warning = identity) 937s > stopifnot(inherits(res, "warning")) 937s > 937s > 937s > # Total gives integer overflow (coerce to numeric) 937s > s1 <- sum(as.numeric(x[1:2])) # 2147483648 937s > s2 <- sum2(as.numeric(x[1:2])) # 2147483648 937s > s3 <- sum2(x[1:2], mode = "double") # 2147483648 937s > stopifnot( 937s + identical(s1, 2147483648), 937s + identical(s1, s2), 937s + identical(s1, s3) 937s + ) 937s > 937s > # Cumulative sum would give integer overflow but not the total 937s > s1 <- sum(x) # 1L 937s > s2 <- sum2(x) # 1L 937s > stopifnot( 937s + identical(s1, 1L), 937s + identical(s1, s2) 937s + ) 937s > 937s > # Input is double but coersing result to integer 937s > x <- c(1, 2, 3.1) 937s > s1 <- sum2(x) 937s > s2 <- sum2(x, mode = "integer") 937s > stopifnot( 937s + identical(as.integer(s1), s2) 937s + ) 937s > 937s > ## Assert above warning 937s > res <- tryCatch({ 937s + s2 <- sum2(x, mode = "integer") 937s + }, warning = identity) 937s > stopifnot(inherits(res, "warning")) 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Summing of large doubles 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > ## Double overflow 937s > x <- rep(.Machine$double.xmax, times = 2L) 937s > y0 <- sum(x) 937s > print(y0) 937s [1] Inf 937s > y <- sum2(x) 937s > print(y) 937s [1] Inf 937s > stopifnot( 937s + is.infinite(y) && y > 0, 937s + identical(y, y0) 937s + ) 937s > 937s > x <- rep(-.Machine$double.xmax, times = 2L) 937s > y0 <- sum(x) 937s > print(y0) 937s [1] -Inf 937s > y <- sum2(x) 937s > print(y) 937s [1] -Inf 937s > stopifnot( 937s + is.infinite(y) && y < 0, 937s + identical(y, y0) 937s + ) 937s > 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Argument 'idxs' 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > x <- 1:10 937s > idxs_list <- list( 937s + integer = 1:5, 937s + double = as.double(1:5), 937s + logical = (x <= 5) 937s + ) 937s > 937s > for (idxs in idxs_list) { 937s + cat("idxs:\n") 937s + str(idxs) 937s + s1 <- sum(x[idxs], na.rm = TRUE) 937s + s2 <- sum2(x, idxs = idxs, na.rm = TRUE) 937s + stopifnot(identical(s1, s2)) 937s + } 937s idxs: 937s int [1:5] 1 2 3 4 5 937s idxs: 937s num [1:5] 1 2 3 4 5 937s idxs: 937s logi [1:10] TRUE TRUE TRUE TRUE TRUE FALSE ... 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library("matrixStats") 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Subsetted tests 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > source("utils/validateIndicesFramework.R") 937s > x <- runif(6, min = -6, max = 6) 937s > storage.mode(x) <- "integer" 937s > for (idxs in index_cases) { 937s + validateIndicesTestVector(x, idxs, 937s + ftest = sum2, fsure = sum, 937s + na.rm = FALSE) 937s + validateIndicesTestVector(x, idxs, 937s + ftest = sum2, fsure = sum, 937s + na.rm = TRUE) 937s + } 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library(matrixStats) 937s > source("utils/validateIndicesFramework.R") 937s > 937s > oopts <- options(matrixStats.validateIndices = "ignore") 937s > 937s > ftest <- function(x, idxs) validateIndices(idxs, length(x)) 937s > 937s > x <- 1:6 937s > for (idxs in index_cases) { 937s + for (mode in c("integer", "numeric", "logical")) { 937s + if (!is.null(idxs)) { 937s + suppressWarnings({storage.mode(idxs) <- mode}) 937s + } 937s + validateIndicesTestVector(x, idxs, ftest = ftest, fsure = identity) 937s + } 937s + } 937s > 937s > ftest <- function(x, idxs) validateIndices(idxs, length(x)) 937s > 937s > for (idxs in index_error_cases) { 937s + validateIndicesTestVector(x, idxs, ftest = ftest, fsure = identity) 937s + } 937s > 937s > 937s > ftest <- function(x, rows, cols) { 937s + vr <- validateIndices(rows, dim(x)[1], FALSE) 937s + vc <- validateIndices(cols, dim(x)[2], FALSE) 937s + 937s + stopifnot(all((vr > 0 & vr <= dim(x)[1]) | is.na(vr))) 937s + stopifnot(all((vc > 0 & vc <= dim(x)[2]) | is.na(vc))) 937s + suppressWarnings(x <- x[vr, vc, drop = FALSE]) 937s + x 937s + } 937s > 937s > x <- matrix(1:36, nrow = 6, ncol = 6) 937s > for (rows in index_cases) { 937s + for (cols in index_cases) { 937s + validateIndicesTestMatrix(x, rows, cols, ftest = ftest, fsure = identity) 937s + } 937s + } 937s > 937s > # Testing for 64-bit builds (64 bits = 8 bytes) 937s > if (.Machine$sizeof.pointer == 8L) { 937s + validateIndices(c(1.25*2^40, 3, 1*2^38, 1, 1.4*2^39), maxIdx = 1*2^41) 937s + } 937s [1] 1.374390e+12 3.000000e+00 2.748779e+11 1.000000e+00 7.696581e+11 937s > 937s > options(oopts) 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library("matrixStats") 937s > 937s > set.seed(1) 937s > x <- rnorm(1e4) 937s > 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Variance estimators 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > sigma2_a <- var(x) 937s > cat(sprintf("var(x) = %g\n", sigma2_a)) 937s var(x) = 1.02487 937s > 937s > sigma2_b <- varDiff(x) 937s > cat(sprintf("varDiff(x) = %g\n", sigma2_b)) 937s varDiff(x) = 1.01224 937s > 937s > d <- abs(sigma2_b - sigma2_a) 937s > cat(sprintf("Absolute difference = %g\n", d)) 937s Absolute difference = 0.0126268 937s > stopifnot(d < 0.02) 937s > 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Standard deviation estimators 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > sigma_a <- sd(x) 937s > cat(sprintf("sd(x) = %g\n", sigma_a)) 937s sd(x) = 1.01236 937s > 937s > sigma_b <- sdDiff(x) 937s > cat(sprintf("sdDiff(x) = %g\n", sigma_b)) 937s sdDiff(x) = 1.0061 937s > 937s > d <- abs(sigma_b - sigma_a) 937s > cat(sprintf("Absolute difference = %g\n", d)) 937s Absolute difference = 0.00625567 937s > stopifnot(d < 0.01) 937s > 937s > # Sanity checks 937s > stopifnot(abs(sigma2_a - sigma_a ^ 2) < 1e-9) 937s > stopifnot(abs(sigma2_b - sigma_b ^ 2) < 1e-9) 937s > 937s > 937s > sigma_a2 <- mad(x) 937s > cat(sprintf("mad(x) = %g\n", sigma_a2)) 937s mad(x) = 0.998376 937s > 937s > sigma_b2 <- madDiff(x) 937s > cat(sprintf("madDiff(x) = %g\n", sigma_b2)) 937s madDiff(x) = 1.02513 937s > 937s > d <- abs(sigma_b2 - sigma_a2) 937s > cat(sprintf("Absolute difference = %g\n", d)) 937s Absolute difference = 0.0267497 937s > stopifnot(d < 0.05) 937s > 937s > 937s > sigma_a3 <- IQR(x) 937s > cat(sprintf("IQR(x) = %g\n", sigma_a3)) 937s IQR(x) = 1.35105 937s > 937s > sigma_b3 <- iqrDiff(x) 937s > cat(sprintf("iqrDiff(x) = %g\n", sigma_b3)) 937s iqrDiff(x) = 1.37797 937s > 937s > d <- abs(sigma_b3 - sigma_a3) 937s > cat(sprintf("Absolute difference = %g\n", d)) 937s Absolute difference = 0.0269152 937s > stopifnot(d < 0.05) 937s > 937s > 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Trimmed estimators 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > y <- x 937s > outliers <- sample(length(x), size = 0.1 * length(x)) 937s > y[outliers] <- 100 * y[outliers] 937s > 937s > sigma_ao <- sd(y[-outliers]) 937s > cat(sprintf("sd(y) = %g\n", sigma_ao)) 937s sd(y) = 1.01166 937s > 937s > sigma_bo <- sdDiff(y[-outliers]) 937s > cat(sprintf("sdDiff(y) = %g\n", sigma_bo)) 937s sdDiff(y) = 1.00743 937s > 937s > d <- abs(sigma_b - sigma_a) 937s > cat(sprintf("Absolute difference = %g\n", d)) 937s Absolute difference = 0.00625567 937s > stopifnot(d < 0.01) 937s > 937s > sigma_bot <- sdDiff(y, trim = 0.05) 937s > cat(sprintf("sdDiff(y, trim = 0.05) = %g\n", sigma_bot)) 937s sdDiff(y, trim = 0.05) = 7.74327 937s > 937s > d <- abs(sigma_bot - sigma_a) 937s > cat(sprintf("Absolute difference = %g\n", d)) 937s Absolute difference = 6.73091 937s > #stopifnot(d < 1e-3) 937s > 937s > sigma_cot <- madDiff(y, trim = 0.05) 937s > cat(sprintf("madDiff(y, trim = 0.05) = %g\n", sigma_cot)) 937s madDiff(y, trim = 0.05) = 1.15278 937s > 937s > sigma_dot <- iqrDiff(y, trim = 0.05) 937s > cat(sprintf("iqrDiff(y, trim = 0.05) = %g\n", sigma_dot)) 937s iqrDiff(y, trim = 0.05) = 1.55762 937s > 937s > 937s > fcns <- list( 937s + varDiff = varDiff, 937s + sdDiff = sdDiff, 937s + madDiff = madDiff, 937s + iqrDiff = iqrDiff 937s + ) 937s > 937s > for (name in names(fcns)) { 937s + cat(sprintf("%s()...\n", name)) 937s + fcn <- fcns[[name]] 937s + 937s + for (mode in c("integer", "double")) { 937s + cat("mode: ", mode, "", sep = "") 937s + for (n in 0:3) { 937s + x <- runif(n, min = -5, max = 5) 937s + storage.mode(x) <- mode 937s + str(x) 937s + 937s + y <- fcn(x) 937s + yt <- fcn(x, trim = 0.1) 937s + str(list("non-trimmed" = y, trimmed = yt)) 937s + } # for (mode ...) 937s + } 937s + 937s + cat(sprintf("%s()...DONE\n", name)) 937s + } # for (name ...) 937s varDiff()... 937s mode: integer int(0) 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s int -4 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s int [1:2] 3 2 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s int [1:3] 1 4 -1 937s List of 2 937s $ non-trimmed: num 16 937s $ trimmed : num 16 937s mode: double num(0) 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s num -0.794 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s num [1:2] 0.897 -3.728 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s num [1:3] 2.07 -1.13 1.94 937s List of 2 937s $ non-trimmed: num 9.83 937s $ trimmed : num 9.83 937s varDiff()...DONE 937s sdDiff()... 937s mode: integer int(0) 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s int 2 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s int [1:2] -4 1 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s int [1:3] -2 1 -1 937s List of 2 937s $ non-trimmed: num 2.5 937s $ trimmed : num 2.5 937s mode: double num(0) 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s num -3.78 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s num [1:2] -2.04 2.38 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s num [1:3] 1.42 -2.14 1.14 937s List of 2 937s $ non-trimmed: num 3.42 937s $ trimmed : num 3.42 937s sdDiff()...DONE 937s madDiff()... 937s mode: integer int(0) 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s int -1 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s int [1:2] -1 4 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s int [1:3] -1 0 -3 937s List of 2 937s $ non-trimmed: num 2.1 937s $ trimmed : num 2.1 937s mode: double num(0) 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s num -1.13 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s num [1:2] -1.7 -1.21 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s num [1:3] -2.39 -0.464 3.086 937s List of 2 937s $ non-trimmed: num 0.851 937s $ trimmed : num 0.851 937s madDiff()...DONE 937s iqrDiff()... 937s mode: integer int(0) 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s int 3 937s List of 2 937s $ non-trimmed: num 0 937s $ trimmed : num 0 937s int [1:2] -3 4 937s List of 2 937s $ non-trimmed: num 0 937s $ trimmed : num 0 937s int [1:3] 0 -2 -2 937s List of 2 937s $ non-trimmed: num 0.707 937s $ trimmed : num 0.707 937s mode: double num(0) 937s List of 2 937s $ non-trimmed: num NA 937s $ trimmed : num NA 937s num -4.46 937s List of 2 937s $ non-trimmed: num 0 937s $ trimmed : num 0 937s num [1:2] 3.67 1.02 937s List of 2 937s $ non-trimmed: num 0 937s $ trimmed : num 0 937s num [1:3] -0.537 -2.733 2.857 937s List of 2 937s $ non-trimmed: num 2.75 937s $ trimmed : num 2.75 937s iqrDiff()...DONE 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library("matrixStats") 937s > 937s > fcns <- list( 937s + varDiff = varDiff, 937s + sdDiff = sdDiff, 937s + madDiff = madDiff, 937s + iqrDiff = iqrDiff 937s + ) 937s > 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Subsetted tests 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > source("utils/validateIndicesFramework.R") 937s > for (name in names(fcns)) { 937s + cat(sprintf("subsetted tests on %s()...\n", name)) 937s + fcn <- fcns[[name]] 937s + 937s + for (mode in c("numeric", "integer")) { 937s + x <- runif(6, min = -6, max = 6) 937s + storage.mode(x) <- mode 937s + trim <- runif(1, min = 0, max = 0.5) 937s + if (mode == "numeric") x[1] <- Inf 937s + 937s + for (diff in 1:2) { 937s + for (idxs in index_cases) { 937s + validateIndicesTestVector(x, idxs, 937s + ftest = fcn, fsure = fcn, 937s + na.rm = TRUE, diff = diff, trim = trim) 937s + validateIndicesTestVector(x, idxs, 937s + ftest = fcn, fsure = fcn, 937s + na.rm = FALSE, diff = diff, trim = trim) 937s + } 937s + } 937s + } 937s + cat(sprintf("%s()...DONE\n", name)) 937s + } 937s subsetted tests on varDiff()... 937s varDiff()...DONE 937s subsetted tests on sdDiff()... 937s sdDiff()...DONE 937s subsetted tests on madDiff()... 937s madDiff()...DONE 937s subsetted tests on iqrDiff()... 937s iqrDiff()...DONE 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library("matrixStats") 937s > 937s > for (mode in c("logical", "integer", "double")) { 937s + cat("mode: ", mode, "", sep = "") 937s + n <- 2L 937s + x <- runif(n, min = -5, max = 5) 937s + if (mode == "logical") { 937s + x <- x > 0 937s + } 937s + storage.mode(x) <- mode 937s + str(x) 937s + 937s + cat("All weights are 1\n") 937s + w <- rep(1, times = n) 937s + m0 <- weighted.mean(x, w) 937s + m1 <- weightedMean(x, w) 937s + str(list(m0 = m0, m1 = m1)) 937s + stopifnot(identical(m1, m0)) 937s + 937s + cat("First weight is 5\n") 937s + # Pull the mean towards zero 937s + w[1] <- 5 937s + str(w) 937s + m0 <- weighted.mean(x, w) 937s + m1 <- weightedMean(x, w) 937s + str(list(m0 = m0, m1 = m1)) 937s + stopifnot(identical(m1, m0)) 937s + 937s + cat("All weights are 0\n") 937s + # All weights set to zero 937s + w <- rep(0, times = n) 937s + m0 <- weighted.mean(x, w) 937s + m1 <- weightedMean(x, w) 937s + str(list(m0 = m0, m1 = m1)) 937s + stopifnot(identical(m1, m0)) 937s + 937s + cat("First weight is 8.5\n") 937s + # Put even more weight on the zero 937s + w[1] <- 8.5 937s + m0 <- weighted.mean(x, w) 937s + m1 <- weightedMean(x, w) 937s + str(list(m0 = m0, m1 = m1)) 937s + stopifnot(identical(m1, m0)) 937s + 937s + cat("First weight is Inf\n") 937s + # All weight on the first value 937s + w[1] <- Inf 937s + m0 <- weighted.mean(x, w) 937s + m1 <- weightedMean(x, w) 937s + str(list(m0 = m0, m1 = m1)) 937s + stopifnot(identical(m1, m0)) 937s + 937s + cat("Last weight is Inf\n") 937s + # All weight on the last value 937s + w[1] <- 1 937s + w[n] <- Inf 937s + m0 <- weighted.mean(x, w) 937s + m1 <- weightedMean(x, w) 937s + str(list(m0 = m0, m1 = m1)) 937s + stopifnot(identical(m1, m0)) 937s + } # for (mode ...) 937s mode: logical logi [1:2] FALSE FALSE 937s All weights are 1 937s List of 2 937s $ m0: num 0 937s $ m1: num 0 937s First weight is 5 937s num [1:2] 5 1 937s List of 2 937s $ m0: num 0 937s $ m1: num 0 937s All weights are 0 937s List of 2 937s $ m0: num NaN 937s $ m1: num NaN 937s First weight is 8.5 937s List of 2 937s $ m0: num 0 937s $ m1: num 0 937s First weight is Inf 937s List of 2 937s $ m0: num NaN 937s $ m1: num NaN 937s Last weight is Inf 937s List of 2 937s $ m0: num NaN 937s $ m1: num NaN 937s mode: integer int [1:2] 0 3 937s All weights are 1 937s List of 2 937s $ m0: num 1.5 937s $ m1: num 1.5 937s First weight is 5 937s num [1:2] 5 1 937s List of 2 937s $ m0: num 0.5 937s $ m1: num 0.5 937s All weights are 0 937s List of 2 937s $ m0: num NaN 937s $ m1: num NaN 937s First weight is 8.5 937s List of 2 937s $ m0: num 0 937s $ m1: num 0 937s First weight is Inf 937s List of 2 937s $ m0: num NaN 937s $ m1: num NaN 937s Last weight is Inf 937s List of 2 937s $ m0: num NaN 937s $ m1: num NaN 937s mode: double num [1:2] -4.29 4.73 937s All weights are 1 937s List of 2 937s $ m0: num 0.222 937s $ m1: num 0.222 937s First weight is 5 937s num [1:2] 5 1 937s List of 2 937s $ m0: num -2.79 937s $ m1: num -2.79 937s All weights are 0 937s List of 2 937s $ m0: num NaN 937s $ m1: num NaN 937s First weight is 8.5 937s List of 2 937s $ m0: num -4.29 937s $ m1: num -4.29 937s First weight is Inf 937s List of 2 937s $ m0: num NaN 937s $ m1: num NaN 937s Last weight is Inf 937s List of 2 937s $ m0: num NaN 937s $ m1: num NaN 937s > 937s > 937s > message("*** Testing for missing values") 937s > # NA tests 937s > xs <- list(A = c(1, 2, 3), B = c(NA, 2, 3), C = c(NA, 2, 3)) 937s > ws <- list(A = c(1, 1, 1), B = c(NA, 1, 1), C = c(1, NA, 1)) 937s > ## NOTE: The (B, B) case with na.rm = TRUE is interesting because 937s > ## even if NAs in 'w' are not dropped by na.rm = TRUE, this one 937s > ## is because 'x' is dropped and therefore that first element 937s > ## is skipped in the computation. It basically does 937s > ## keep <- !is.na(x); x <- x[keep]; w <- w[keep] 937s > ## without looking at 'w'. 937s > for (x in xs) { 937s + for (mode in c("logical", "integer", "double")) { 937s + storage.mode(x) <- mode 937s + for (w in ws) { 937s + for (na.rm in c(FALSE, TRUE)) { 937s + cat(sprintf("mode: %s, na.rm = %s\n", mode, na.rm)) 937s + str(list(x = x, w = w)) 937s + m0 <- weighted.mean(x, w, na.rm = na.rm) 937s + m1 <- weightedMean(x, w, na.rm = na.rm) 937s + str(list(m0 = m0, m1 = m1)) 937s + stopifnot(all.equal(m1, m0)) 937s + } 937s + } 937s + } 937s + } 937s mode: logical, na.rm = FALSE 937s List of 2 937s $ x: logi [1:3] TRUE TRUE TRUE 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: logical, na.rm = TRUE 937s List of 2 937s $ x: logi [1:3] TRUE TRUE TRUE 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: logical, na.rm = FALSE 937s List of 2 937s $ x: logi [1:3] TRUE TRUE TRUE 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = TRUE 937s List of 2 937s $ x: logi [1:3] TRUE TRUE TRUE 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = FALSE 937s List of 2 937s $ x: logi [1:3] TRUE TRUE TRUE 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = TRUE 937s List of 2 937s $ x: logi [1:3] TRUE TRUE TRUE 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = FALSE 937s List of 2 937s $ x: int [1:3] 1 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: integer, na.rm = TRUE 937s List of 2 937s $ x: int [1:3] 1 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: integer, na.rm = FALSE 937s List of 2 937s $ x: int [1:3] 1 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = TRUE 937s List of 2 937s $ x: int [1:3] 1 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = FALSE 937s List of 2 937s $ x: int [1:3] 1 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = TRUE 937s List of 2 937s $ x: int [1:3] 1 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = FALSE 937s List of 2 937s $ x: num [1:3] 1 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: double, na.rm = TRUE 937s List of 2 937s $ x: num [1:3] 1 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: double, na.rm = FALSE 937s List of 2 937s $ x: num [1:3] 1 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = TRUE 937s List of 2 937s $ x: num [1:3] 1 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = FALSE 937s List of 2 937s $ x: num [1:3] 1 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = TRUE 937s List of 2 937s $ x: num [1:3] 1 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = FALSE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = TRUE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: logical, na.rm = FALSE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = TRUE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: logical, na.rm = FALSE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = TRUE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = FALSE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = TRUE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: integer, na.rm = FALSE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = TRUE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: integer, na.rm = FALSE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = TRUE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = FALSE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = TRUE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: double, na.rm = FALSE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = TRUE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: double, na.rm = FALSE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = TRUE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = FALSE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = TRUE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: logical, na.rm = FALSE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = TRUE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: logical, na.rm = FALSE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: logical, na.rm = TRUE 937s List of 2 937s $ x: logi [1:3] NA TRUE TRUE 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = FALSE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = TRUE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: integer, na.rm = FALSE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = TRUE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: integer, na.rm = FALSE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: integer, na.rm = TRUE 937s List of 2 937s $ x: int [1:3] NA 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = FALSE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = TRUE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] 1 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: double, na.rm = FALSE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = TRUE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] NA 1 1 937s List of 2 937s $ m0: num 1 937s $ m1: num 1 937s mode: double, na.rm = FALSE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s mode: double, na.rm = TRUE 937s List of 2 937s $ x: num [1:3] NA 1 1 937s $ w: num [1:3] 1 NA 1 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library("matrixStats") 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Subsetted tests 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > source("utils/validateIndicesFramework.R") 937s > for (mode in c("numeric", "integer")) { 937s + x <- runif(6, min = -6, max = 6) 937s + w <- runif(6, min = 0, max = 6) 937s + storage.mode(x) <- mode 937s + storage.mode(w) <- mode 937s + if (mode == "numeric") w[1] <- Inf 937s + 937s + for (idxs in index_cases) { 937s + validateIndicesTestVector_w(x, w, idxs, 937s + ftest = weightedMean, fsure = weighted.mean, 937s + na.rm = TRUE, refine = TRUE) 937s + validateIndicesTestVector_w(x, w, idxs, 937s + ftest = weightedMean, fsure = weighted.mean, 937s + na.rm = FALSE, refine = TRUE) 937s + } 937s + } 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library("matrixStats") 937s > 937s > x <- 1:5 937s > y <- weightedMedian(x) 937s > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = TRUE) 937s > print(y) 937s [1] 3 937s > 937s > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = FALSE) 937s > print(y) 937s [1] NA 937s > stopifnot(is.na(y)) 937s > 937s > x <- 1:10 937s > n <- length(x) 937s > 937s > y1 <- median(x) # 5.5 937s > y2 <- weightedMedian(x) # 5.5 937s > stopifnot(all.equal(y1, y2)) 937s > 937s > 937s > w <- rep(1, times = n) 937s > y1 <- weightedMedian(x, w) # 5.5 (default) 937s > y2a <- weightedMedian(x, ties = "weighted") # 5.5 (default) 937s > y2b <- weightedMedian(x, ties = "min") # 5 937s > y2c <- weightedMedian(x, ties = "max") # 6 937s > stopifnot(all.equal(y2a, y1)) 937s > 937s > y3 <- weightedMedian(x, w) # 5.5 (default) 937s > 937s > 937s > # Pull the median towards zero 937s > w[1] <- 5 937s > y1 <- weightedMedian(x, w) # 3.5 937s > y <- c(rep(0, times = w[1]), x[-1]) # Only possible for integer weights 937s > y2 <- median(y) # 3.5 937s > stopifnot(all.equal(y1, y2)) 937s > 937s > # Put even more weight on the zero 937s > w[1] <- 8.5 937s > y <- weightedMedian(x, w) # 2 937s > 937s > # All weight on the first value 937s > w[1] <- Inf 937s > y <- weightedMedian(x, w) # 1 937s > 937s > # All weight on the last value 937s > w[1] <- 1 937s > w[n] <- Inf 937s > y <- weightedMedian(x, w) # 10 937s > 937s > # All weights set to zero 937s > w <- rep(0, times = n) 937s > y <- weightedMedian(x, w) # NA 937s > 937s > x <- 1:4 937s > w <- rep(1, times = 4) 937s > for (mode in c("integer", "double")) { 937s + storage.mode(x) <- mode 937s + for (ties in c("weighted", "mean", "min", "max")) { 937s + cat(sprintf("ties = %s\n", ties)) 937s + y <- weightedMedian(x, w, ties = ties) 937s + } 937s + } 937s ties = weighted 937s ties = mean 937s ties = min 937s ties = max 937s ties = weighted 937s ties = mean 937s ties = min 937s ties = max 937s > 937s > set.seed(0x42) 937s > 937s > y <- weightedMedian(x = double(0L)) 937s > print(y) 937s [1] NA 937s > stopifnot(length(y) == 1L) 937s > stopifnot(is.na(y)) 937s > 937s > y <- weightedMedian(x = x[1]) 937s > print(y) 937s [1] 1 937s > stopifnot(length(y) == 1L) 937s > stopifnot(all.equal(y, x[1])) 937s > 937s > 937s > n <- 1e3 937s > x <- runif(n) 937s > w <- runif(n, min = 0, max = 1) 937s > for (mode in c("integer", "double")) { 937s + storage.mode(x) <- mode 937s + for (ties in c("weighted", "mean", "min", "max")) { 937s + y <- weightedMedian(x, w, ties = ties) 937s + cat(sprintf("mode = %s, ties = %s, result = %g\n", mode, ties, y)) 937s + } 937s + } 937s mode = integer, ties = weighted, result = 0 937s mode = integer, ties = mean, result = 0 937s mode = integer, ties = min, result = 0 937s mode = integer, ties = max, result = 0 937s mode = double, ties = weighted, result = 0 937s mode = double, ties = mean, result = 0 937s mode = double, ties = min, result = 0 937s mode = double, ties = max, result = 0 937s > 937s > 937s > # A large vector 937s > n <- 1e5 937s > x <- runif(n) 937s > w <- runif(n, min = 0, max = 1) 937s > y <- weightedMedian(x, w) 937s > 937s > y <- weightedMedian(x, w, ties = "min") 937s > 937s > 937s > # Single Number 937s > xs <- c(1, NA_integer_) 937s > ws <- c(1, NA_integer_) 937s > for (x in xs) { 937s + for (w in ws) { 937s + y <- weightedMedian(x = x, w = w) 937s + if (is.na(w)) z <- NA_real_ 937s + else z <- x[1] 937s + stopifnot(all.equal(y, z)) 937s + } 937s + } 937s > 937s > ## Logical 937s > x1 <- c(TRUE, FALSE, TRUE) 937s > w0 <- c(0, 0, 0) 937s > stopifnot(!is.finite(weightedMedian(x1, w0)), 937s + !is.infinite(weightedMedian(x1, w0))) 937s > 937s > w1 <- c(1, 1, 1) 937s > stopifnot(weightedMedian(x1, w1) == 1) 937s > 937s > w2 <- c(1, 2, 3) 937s > stopifnot(weightedMedian(x1, w2) == 1) 937s > 937s > ### NA 937s > stopifnot(is.na(weightedMedian(c(TRUE, FALSE, NA), 937s + c(1, 2, 3))), 937s + all.equal(weightedMedian(c(TRUE, FALSE, NA), 937s + c(1, 2, 3), 937s + na.rm = TRUE), 937s + weightedMedian(c(TRUE, FALSE), 937s + c(1, 2)))) 937s > ### Identical to as.integer() 937s > x <- rcauchy(100) 937s > w <- abs(rcauchy(100)) 937s > stopifnot(all.equal(weightedMedian(x > 0, w), 937s + weightedMedian(as.integer(x > 0), w))) 937s > 937s > 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s Warning in sum2(x[1:2]) : 937s Integer overflow. Use sum2(..., mode = "double") to avoid this. 937s Warning in sum2(x, mode = "integer") : 937s sum2(x, mode = "integer") called with typeof(x) == "double"; did you mean to use as.integer(sum2(x))? 937s *** Testing for missing values 937s > library("matrixStats") 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Subsetted tests 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > source("utils/validateIndicesFramework.R") 937s > for (mode in c("numeric", "integer")) { 937s + x <- runif(6, min = -6, max = 6) 937s + w <- runif(6, min = 0, max = 6) 937s + storage.mode(x) <- mode 937s + storage.mode(w) <- mode 937s + if (mode == "numeric") w[1] <- Inf 937s + 937s + for (idxs in index_cases) { 937s + validateIndicesTestVector_w(x, w, idxs, 937s + ftest = weightedMedian, 937s + fsure = weightedMedian, 937s + na.rm = TRUE) 937s + validateIndicesTestVector_w(x, w, idxs, 937s + ftest = weightedMedian, 937s + fsure = weightedMedian, 937s + na.rm = FALSE) 937s + 937s + for (ties in c("weighted", "mean", "min", "max")) { 937s + validateIndicesTestVector_w(x, w, idxs, 937s + ftest = weightedMedian, 937s + fsure = weightedMedian, 937s + na.rm = TRUE, ties = ties) 937s + validateIndicesTestVector_w(x, w, idxs, 937s + ftest = weightedMedian, 937s + fsure = weightedMedian, 937s + na.rm = FALSE, ties = ties) 937s + } 937s + } 937s + } 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library("matrixStats") 937s *** weightedVar() ... 937s - Zero elements 937s > 937s > weightedVar_R <- function(x, w) { 937s + mu <- weighted.mean(x, w = w) 937s + sum(w * (x - mu) ^ 2) / (sum(w) - 1) 937s + } 937s > 937s > 937s > n <- 10 937s > x <- as.double(1:n) 937s > 937s > message("*** weightedVar() ...") 937s > 937s > message("- Zero elements") 937s > m0 <- var(integer(0)) 937s > m1 <- weightedVar(integer(0), w = integer(0)) 937s > str(list(m0 = m0, m1 = m1)) 937s List of 2 937s $ m0: num NA 937s $ m1: int NA 937s > stopifnot(all.equal(m1, m0)) 937s > 937s > 937s > message("- One elements") 937s - One elements 937s > m0 <- var(1) 937s > m1 <- weightedVar(1) 937s > str(list(m0 = m0, m1 = m1)) 937s List of 2 937s $ m0: num NA 937s $ m1: num NA- Uniform weights (all w = 1) 937s 937s > stopifnot(all.equal(m1, m0)) 937s > 937s > 937s > message("- Uniform weights (all w = 1)") 937s > m0 <- var(x) 937s > w <- rep(1, times = n) 937s > m1 <- weightedVar(x, w = w) 937s > str(list(m0 = m0, m1 = m1)) 937s List of 2 937s $ m0:- Uniform weights (all w = 3) 937s num 9.17 937s $ m1: num 9.17 937s > stopifnot(all.equal(m1, m0)) 937s > 937s > 937s > message("- Uniform weights (all w = 3)") 937s > m0 <- var(rep(x, each = 3)) 937s > w <- rep(3, times = n) 937s > m1 <- weightedVar(x, w = w) 937s > str(list(m0 = m0, m1 = m1)) 937s List of 2 937s $ m0: num 8.53 937s $ m1: num 8.53 937s > stopifnot(all.equal(m1, m0)) 937s > 937s > 937s > message("- Uniform weights on the first five elements") 937s > idxs <- 1:5 937s - Uniform weights on the first five elements 937s > m0 <- var(x[1:5]) 937s > w <- rep(0, times = n) 937s > w[idxs] <- 1 937s > m1 <- weightedVar(x, w = w) 937s > str(list(m0 = m0, m1 = m1)) 937s List of 2 937s $ m0: num 2.5 937s $ m1: num 2.5 937s > stopifnot(all.equal(m1, m0)) 937s > 937s > 937s > message("- Uniform weights on every second elements") 937s > idxs <- seq(from = 1, to = n, by = 2) 937s > m0 <- var(x[idxs]) 937s > - Uniform weights on every second elements 937s w <- rep(0, times = n) 937s > w[idxs] <- 1 937s > m1 <- weightedVar(x, w = w) 937s > str(list(m0 = m0, m1 = m1)) 937s List of 2 937s $ m0: num 10 937s $ m1: num 10 937s > stopifnot(all.equal(m1, m0)) 937s > 937s > 937s > message("- All weights are zero") 937s > idxs <- integer(0L) 937s > - All weights are zero 937s m0 <- var(x[idxs]) 937s > w <- rep(0, times = n) 937s > w[idxs] <- 1 937s > m1 <- weightedVar(x, w = w) 937s > str(list(m0 = m0, m1 = m1)) 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s > stopifnot(all.equal(m1, m0)) 937s > 937s > message("- Infinite weight on first element") 937s > idxs <- 1L 937s > m0 <- var(x[idxs]) 937s - Infinite weight on first element 937s > w <- rep(0, times = n) 937s > w[idxs] <- Inf 937s > m1 <- weightedVar(x, w = w) 937s > str(list(m0 = m0, m1 = m1)) 937s List of 2 937s $ m0: num NA 937s $ m1: num NA 937s > stopifnot(all.equal(m1, m0)) 937s > 937s > message("- Missing-value weight on first element") 937s > idxs <- 1L 937s > w <- rep(1, times = n) 937s > w[idxs] <- NA_real_ 937s - Missing-value weight on first element 937s > m1 <- weightedVar(x, w = w) 937s > str(list(m1 = m1)) 937s List of 1 937s $ m1: num NA 937s > stopifnot(identical(m1, NA_real_)) 937s > 937s > 937s > message("- Frequency weights") 937s > 937s > ## From https://en.wikipedia.org/wiki/Weighted_arithmetic_mean 937s > y <- c(2, 2, 4, 5, 5, 5) 937s > x <- unique(y) 937s > w <- table(y) 937s > stopifnot(names(w) == x) 937s > 937s > m0 <- weightedVar(x, w = w) 937s > m1 <- var(y) 937s > stopifnot(all.equal(m1, m0)) 937s - Frequency weights 937s > m2 <- weightedVar(x, w = w) 937s > str(list(m0 = m0, m1 = m1, m2 = m2)) 937s List of 3 937s $ m0: num 2.17 937s $ m1: num 2.17 937s $ m2: num 2.17 937s > stopifnot(all.equal(m2, m0)) 937s > 937s > ## From https://github.com/HenrikBengtsson/matrixStats/issues/72 937s > large <- c(21, 8, 26, 1, 15, 33, 12, 25, 0, 84) 937s > years <- c(41706, 9301, 33678, 3082, 27040, 44188, 10049, 30591, 2275, 109831) 937s > 937s > m0 <- weightedVar(large, w = years) 937s > m1 <- weightedVar(large, w = years) 937s > str(list(m0 = m0, m1 = m1)) 937s List of 2 937s *** weightedVar() ... DONE 937s $ m0: num 899 937s $ m1: num 899 937s > stopifnot(all.equal(m1, m0)) 937s > 937s > message("*** weightedVar() ... DONE") 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library("matrixStats") 937s > 937s > fcns <- list( 937s + weightedVar = weightedVar, 937s + weightedSd = weightedSd, 937s + weightedMad = weightedMad 937s + ) 937s > 937s > for (name in names(fcns)) { 937s + cat(sprintf("%s()...\n", name)) 937s + fcn <- fcns[[name]] 937s + 937s + for (mode in c("integer", "double")) { 937s + cat("mode: ", mode, "\n", sep = "") 937s + n <- 15L 937s + x <- runif(n, min = -5, max = 5) 937s + storage.mode(x) <- mode 937s + str(x) 937s + 937s + for (add_na in c(FALSE, TRUE)) { 937s + cat("add_na: ", add_na, "\n", sep = "") 937s + if (add_na) { 937s + x[c(5, 7)] <- NA 937s + } 937s + str(x) 937s + 937s + for (na.rm in c(FALSE, TRUE)) { 937s + cat("na.rm: ", na.rm, "\n", sep = "") 937s + 937s + cat("Weights are not specified (all are 1)\n") 937s + m1 <- fcn(x, na.rm = na.rm) 937s + str(list(m1 = m1)) 937s + 937s + cat("All weights are 1\n") 937s + w <- rep(1, times = n) 937s + m1 <- fcn(x, w, na.rm = na.rm) 937s + str(list(m1 = m1)) 937s + 937s + cat("First weight is 5\n") 937s + # Pull the mean towards zero 937s + w[1] <- 5 937s + str(w) 937s + m1 <- fcn(x, w, na.rm = na.rm) 937s + str(list(m1 = m1)) 937s + 937s + cat("All weights are 0\n") 937s + # All weights set to zero 937s + w <- rep(0, times = n) 937s + m1 <- fcn(x, w, na.rm = na.rm) 937s + str(list(m1 = m1)) 937s + 937s + cat("First weight is 8.5\n") 937s + # Put even more weight on the zero 937s + w[1] <- 8.5 937s + m1 <- fcn(x, w, na.rm = na.rm) 937s + str(list(m1 = m1)) 937s + 937s + cat("First weight is Inf\n") 937s + # All weight on the first value 937s + w[1] <- Inf 937s + m1 <- fcn(x, w, na.rm = na.rm) 937s + str(list(m1 = m1)) 937s + 937s + cat("Last weight is Inf\n") 937s + # All weight on the last value 937s + w[1] <- 1 937s + w[n] <- Inf 937s + m1 <- fcn(x, w, na.rm = na.rm) 937s + str(list(m1 = m1)) 937s + 937s + cat("Last weight is NA\n") 937s + # All weight on the last value 937s + w[1] <- 1 937s + w[n] <- NA_real_ 937s + m1 <- fcn(x, w, na.rm = na.rm) 937s + str(list(m1 = m1)) 937s + } # for (na.rm ...) 937s + } # for (add_na ...) 937s + } # for (mode ...) 937s + 937s + cat(sprintf("%s()...DONE\n", name)) 937s + } # for (name ...) 937s weightedVar()... 937s mode: integer 937s int [1:15] 0 0 0 3 -3 -4 1 -2 -4 -1 ... 937s add_na: FALSE 937s int [1:15] 0 0 0 3 -3 -4 1 -2 -4 -1 ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 4.41 937s All weights are 1 937s List of 1 937s $ m1: num 4.41 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 3.56 937s All weights are 0 937s List of 1 937s $ m1: int NA 937s First weight is 8.5 937s List of 1 937s $ m1: int NA 937s First weight is Inf 937s List of 1 937s $ m1: int NA 937s Last weight is Inf 937s List of 1 937s $ m1: int NA 937s Last weight is NA 937s List of 1 937s $ m1: int NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 4.41 937s All weights are 1 937s List of 1 937s $ m1: num 4.41 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 3.56 937s All weights are 0 937s List of 1 937s $ m1: int NA 937s First weight is 8.5 937s List of 1 937s $ m1: int NA 937s First weight is Inf 937s List of 1 937s $ m1: int NA 937s Last weight is Inf 937s List of 1 937s $ m1: int NA 937s Last weight is NA 937s List of 1 937s $ m1: int NA 937s add_na: TRUE 937s int [1:15] 0 0 0 3 NA -4 NA -2 -4 -1 ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: int NA 937s All weights are 1 937s List of 1 937s $ m1: int NA 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: int NA 937s All weights are 0 937s List of 1 937s $ m1: int NA 937s First weight is 8.5 937s List of 1 937s $ m1: int NA 937s First weight is Inf 937s List of 1 937s $ m1: int NA 937s Last weight is Inf 937s List of 1 937s $ m1: int NA 937s Last weight is NA 937s List of 1 937s $ m1: int NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 4.47 937s All weights are 1 937s List of 1 937s $ m1: num 4.47 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 3.49 937s All weights are 0 937s List of 1 937s $ m1: int NA 937s First weight is 8.5 937s List of 1 937s $ m1: int NA 937s First weight is Inf 937s List of 1 937s $ m1: int NA 937s Last weight is Inf 937s List of 1 937s $ m1: int NA 937s Last weight is NA 937s List of 1 937s $ m1: int NA 937s mode: double 937s num [1:15] -1.682 0.77 0.103 0.973 1.429 ... 937s add_na: FALSE 937s num [1:15] -1.682 0.77 0.103 0.973 1.429 ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 3.91 937s All weights are 1 937s List of 1 937s $ m1: num 3.91 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 3.35 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 3.91 937s All weights are 1 937s List of 1 937s $ m1: num 3.91 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 3.35 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s add_na: TRUE 937s num [1:15] -1.682 0.77 0.103 0.973 NA ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num NA 937s All weights are 1 937s List of 1 937s $ m1: num NA 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num NA 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 3.92 937s All weights are 1 937s List of 1 937s $ m1: num 3.92 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 3.15 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s weightedVar()...DONE 937s weightedSd()... 937s mode: integer 937s int [1:15] -3 4 0 -2 -4 3 3 4 3 1 ... 937s add_na: FALSE 937s int [1:15] -3 4 0 -2 -4 3 3 4 3 1 ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.97 937s All weights are 1 937s List of 1 937s $ m1: num 2.97 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 3 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.97 937s All weights are 1 937s List of 1 937s $ m1: num 2.97 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 3 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s add_na: TRUE 937s int [1:15] -3 4 0 -2 NA 3 NA 4 3 1 ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num NA 937s All weights are 1 937s List of 1 937s $ m1: num NA 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num NA 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.84 937s All weights are 1 937s List of 1 937s $ m1: num 2.84 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 2.93 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s mode: double 937s num [1:15] -1.338 -1.342 4.452 -0.815 -4.194 ... 937s add_na: FALSE 937s num [1:15] -1.338 -1.342 4.452 -0.815 -4.194 ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.98 937s All weights are 1 937s List of 1 937s $ m1: num 2.98 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 2.78 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.98 937s All weights are 1 937s List of 1 937s $ m1: num 2.98 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 2.78 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s add_na: TRUE 937s num [1:15] -1.338 -1.342 4.452 -0.815 NA ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num NA 937s All weights are 1 937s List of 1 937s $ m1: num NA 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num NA 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.67 937s All weights are 1 937s List of 1 937s $ m1: num 2.67 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 2.52 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num NA 937s First weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is Inf 937s List of 1 937s $ m1: num NA 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s weightedSd()...DONE 937s weightedMad()... 937s mode: integer 937s int [1:15] -1 -2 2 1 2 1 -4 -2 0 -4 ... 937s add_na: FALSE 937s int [1:15] -1 -2 2 1 2 1 -4 -2 0 -4 ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.97 937s All weights are 1 937s List of 1 937s $ m1: num 2.97 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 1.48 937s All weights are 0 937s List of 1 937s $ m1: int NA 937s First weight is 8.5 937s List of 1 937s $ m1: int 0 937s First weight is Inf 937s List of 1 937s $ m1: int 0 937s Last weight is Inf 937s List of 1 937s $ m1: int 0 937s Last weight is NA 937s List of 1 937s $ m1: int NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.97 937s All weights are 1 937s List of 1 937s $ m1: num 2.97 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 1.48 937s All weights are 0 937s List of 1 937s $ m1: int NA 937s First weight is 8.5 937s List of 1 937s $ m1: int 0 937s First weight is Inf 937s List of 1 937s $ m1: int 0 937s Last weight is Inf 937s List of 1 937s $ m1: int 0 937s Last weight is NA 937s List of 1 937s $ m1: int NA 937s add_na: TRUE 937s int [1:15] -1 -2 2 1 NA 1 NA -2 0 -4 ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num NA 937s All weights are 1 937s List of 1 937s $ m1: int NA 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: int NA 937s All weights are 0 937s List of 1 937s $ m1: int NA 937s First weight is 8.5 937s List of 1 937s $ m1: int 0 937s First weight is Inf 937s List of 1 937s $ m1: int 0 937s Last weight is Inf 937s List of 1 937s $ m1: int 0 937s Last weight is NA 937s List of 1 937s $ m1: int NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.97 937s All weights are 1 937s List of 1 937s $ m1: num 2.97 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 1.48 937s All weights are 0 937s List of 1 937s $ m1: int NA 937s First weight is 8.5 937s List of 1 937s $ m1: int 0 937s First weight is Inf 937s List of 1 937s $ m1: int 0 937s Last weight is Inf 937s List of 1 937s $ m1: int 0 937s Last weight is NA 937s List of 1 937s $ m1: int NA 937s mode: double 937s num [1:15] 2.783 -4.096 4.352 1.136 0.777 ... 937s add_na: FALSE 937s num [1:15] 2.783 -4.096 4.352 1.136 0.777 ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.93 937s All weights are 1 937s List of 1 937s $ m1: num 2.93 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 1.68 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num 0 937s First weight is Inf 937s List of 1 937s $ m1: num 0 937s Last weight is Inf 937s List of 1 937s $ m1: num 0 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 2.93 937s All weights are 1 937s List of 1 937s $ m1: num 2.93 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 1.68 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num 0 937s First weight is Inf 937s List of 1 937s $ m1: num 0 937s Last weight is Inf 937s List of 1 937s $ m1: num 0 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s add_na: TRUE 937s num [1:15] 2.78 -4.1 4.35 1.14 NA ... 937s na.rm: FALSE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num NA 937s All weights are 1 937s List of 1 937s $ m1: num NA 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num NA 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num 0 937s First weight is Inf 937s List of 1 937s $ m1: num 0 937s Last weight is Inf 937s List of 1 937s $ m1: num 0 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s na.rm: TRUE 937s Weights are not specified (all are 1) 937s List of 1 937s $ m1: num 3.68 937s All weights are 1 937s List of 1 937s $ m1: num 3.68 937s First weight is 5 937s num [1:15] 5 1 1 1 1 1 1 1 1 1 ... 937s List of 1 937s $ m1: num 2.06 937s All weights are 0 937s List of 1 937s $ m1: num NA 937s First weight is 8.5 937s List of 1 937s $ m1: num 0 937s First weight is Inf 937s List of 1 937s $ m1: num 0 937s Last weight is Inf 937s List of 1 937s $ m1: num 0 937s Last weight is NA 937s List of 1 937s $ m1: num NA 937s weightedMad()...DONE 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library("matrixStats") 937s > 937s > fcns <- list( 937s + weightedVar = weightedVar, 937s + weightedSd = weightedSd, 937s + weightedMad = weightedMad 937s + ) 937s > 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Subsetted tests 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > source("utils/validateIndicesFramework.R") 937s > for (name in names(fcns)) { 937s + cat(sprintf("subsetted tests on %s()...\n", name)) 937s + fcn <- fcns[[name]] 937s + 937s + for (mode in c("numeric", "integer")) { 937s + x <- runif(6, min = -6, max = 6) 937s + w <- runif(6, min = 0, max = 6) 937s + storage.mode(x) <- mode 937s + storage.mode(w) <- mode 937s + if (mode == "numeric") w[1] <- Inf 937s + 937s + for (idxs in index_cases) { 937s + validateIndicesTestVector_w(x, w, idxs, 937s + ftest = fcn, fsure = fcn, 937s + na.rm = TRUE) 937s + validateIndicesTestVector_w(x, w, idxs, 937s + ftest = fcn, fsure = fcn, 937s + na.rm = FALSE) 937s + } 937s + } 937s + cat(sprintf("%s()...DONE\n", name)) 937s + } 937s subsetted tests on weightedVar()... 937s weightedVar()...DONE 937s subsetted tests on weightedSd()... 937s weightedSd()...DONE 937s subsetted tests on weightedMad()... 937s weightedMad()...DONE 937s > 937s 937s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 937s Copyright (C) 2024 The R Foundation for Statistical Computing 937s Platform: s390x-ibm-linux-gnu 937s 937s R is free software and comes with ABSOLUTELY NO WARRANTY. 937s You are welcome to redistribute it under certain conditions. 937s Type 'license()' or 'licence()' for distribution details. 937s 937s R is a collaborative project with many contributors. 937s Type 'contributors()' for more information and 937s 'citation()' on how to cite R or R packages in publications. 937s 937s Type 'demo()' for some demos, 'help()' for on-line help, or 937s 'help.start()' for an HTML browser interface to help. 937s Type 'q()' to quit R. 937s 937s > library("matrixStats") 937s > 937s > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 937s + if (na.rm) { 937s + xnok <- is.na(x) 937s + ynok <- is.na(y) 937s + anok <- xnok & ynok 937s + unit <- switch(OP, 937s + "+" = 0, 937s + "-" = NA_real_, 937s + "*" = 1, 937s + "/" = NA_real_, 937s + stop("Unknown 'OP' operator: ", OP) 937s + ) 937s + x[xnok] <- unit 937s + y[ynok] <- unit 937s + } 937s + 937s + ans <- switch(OP, 937s + "+" = x + y, 937s + "-" = x - y, 937s + "*" = x * y, 937s + "/" = x / y, 937s + stop("Unknown 'OP' operator: ", OP) 937s + ) 937s + 937s + if (na.rm) { 937s + ans[anok] <- NA_real_ 937s + } 937s + 937s + ans 937s + } # x_OP_y_R() 937s > 937s > 937s > 937s > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 937s + t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm)) 937s + } 937s > 937s > 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # No missing values 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > x <- matrix(1:16, nrow = 4, ncol = 4) 937s > y <- 1:nrow(x) 937s > storage.mode(y) <- storage.mode(x) 937s > 937s > for (OP in c("+", "-", "*", "/")) { 937s + for (na.rm in c(FALSE, TRUE)) { 937s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 937s + 937s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 937s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 937s + str(a1) 937s + stopifnot(all.equal(a1, a0)) 937s + 937s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 937s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 937s + str(b1) 937s + stopifnot(all.equal(b1, b0)) 937s + } 937s + } 937s OP = '+', na.rm = FALSE 937s int [1:4, 1:4] 2 4 6 8 6 8 10 12 10 12 ... 937s int [1:4, 1:4] 2 3 4 5 7 8 9 10 12 13 ... 937s OP = '+', na.rm = TRUE 937s int [1:4, 1:4] 2 4 6 8 6 8 10 12 10 12 ... 937s int [1:4, 1:4] 2 3 4 5 7 8 9 10 12 13 ... 937s OP = '-', na.rm = FALSE 937s int [1:4, 1:4] 0 0 0 0 4 4 4 4 8 8 ... 937s int [1:4, 1:4] 0 1 2 3 3 4 5 6 6 7 ... 937s OP = '-', na.rm = TRUE 937s int [1:4, 1:4] 0 0 0 0 4 4 4 4 8 8 ... 937s int [1:4, 1:4] 0 1 2 3 3 4 5 6 6 7 ... 937s OP = '*', na.rm = FALSE 937s int [1:4, 1:4] 1 4 9 16 5 12 21 32 9 20 ... 937s int [1:4, 1:4] 1 2 3 4 10 12 14 16 27 30 ... 937s OP = '*', na.rm = TRUE 937s int [1:4, 1:4] 1 4 9 16 5 12 21 32 9 20 ... 937s int [1:4, 1:4] 1 2 3 4 10 12 14 16 27 30 ... 937s OP = '/', na.rm = FALSE 937s num [1:4, 1:4] 1 1 1 1 5 ... 937s num [1:4, 1:4] 1 2 3 4 2.5 ... 937s OP = '/', na.rm = TRUE 937s num [1:4, 1:4] 1 1 1 1 5 ... 937s num [1:4, 1:4] 1 2 3 4 2.5 ... 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Missing values in x, y, or both. 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > for (which in c("x", "y", "both")) { 937s + x <- matrix(1:16, nrow = 4, ncol = 4) 937s + y <- 1:nrow(x) 937s + storage.mode(y) <- storage.mode(x) 937s + 937s + if (which == "x") { 937s + x[3:6] <- NA_real_ 937s + } else if (which == "y") { 937s + y[c(1, 3)] <- NA_real_ 937s + } else if (which == "both") { 937s + x[3:6] <- NA_real_ 937s + y[c(1, 3)] <- NA_real_ 937s + } 937s + 937s + for (OP in c("+", "-", "*", "/")) { 937s + for (na.rm in c(FALSE, TRUE)) { 937s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 937s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 937s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 937s + str(a1) 937s + stopifnot(all.equal(a1, a0)) 937s + 937s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 937s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 937s + str(b1) 937s + stopifnot(all.equal(b1, b0)) 937s + } 937s + } 937s + } 937s OP = '+', na.rm = FALSE 937s num [1:4, 1:4] 2 4 NA NA NA NA 10 12 10 12 ... 937s num [1:4, 1:4] 2 3 NA NA NA NA 9 10 12 13 ... 937s OP = '+', na.rm = TRUE 937s num [1:4, 1:4] 2 4 3 4 1 2 10 12 10 12 ... 937s num [1:4, 1:4] 2 3 1 1 2 2 9 10 12 13 ... 937s OP = '-', na.rm = FALSE 937s num [1:4, 1:4] 0 0 NA NA NA NA 4 4 8 8 ... 937s num [1:4, 1:4] 0 1 NA NA NA NA 5 6 6 7 ... 937s OP = '-', na.rm = TRUE 937s num [1:4, 1:4] 0 0 NA NA NA NA 4 4 8 8 ... 937s num [1:4, 1:4] 0 1 NA NA NA NA 5 6 6 7 ... 937s OP = '*', na.rm = FALSE 937s num [1:4, 1:4] 1 4 NA NA NA NA 21 32 9 20 ... 937s num [1:4, 1:4] 1 2 NA NA NA NA 14 16 27 30 ... 937s OP = '*', na.rm = TRUE 937s num [1:4, 1:4] 1 4 3 4 1 2 21 32 9 20 ... 937s num [1:4, 1:4] 1 2 1 1 2 2 14 16 27 30 ... 937s OP = '/', na.rm = FALSE 937s num [1:4, 1:4] 1 1 NA NA NA ... 937s num [1:4, 1:4] 1 2 NA NA NA ... 937s OP = '/', na.rm = TRUE 937s num [1:4, 1:4] 1 1 NA NA NA ... 937s num [1:4, 1:4] 1 2 NA NA NA ... 937s OP = '+', na.rm = FALSE 937s num [1:4, 1:4] NA 4 NA 8 NA 8 NA 12 NA 12 ... 937s num [1:4, 1:4] NA NA NA NA 7 8 9 10 NA NA ... 937s OP = '+', na.rm = TRUE 937s num [1:4, 1:4] 1 4 3 8 5 8 7 12 9 12 ... 937s num [1:4, 1:4] 1 2 3 4 7 8 9 10 9 10 ... 937s OP = '-', na.rm = FALSE 937s num [1:4, 1:4] NA 0 NA 0 NA 4 NA 4 NA 8 ... 937s num [1:4, 1:4] NA NA NA NA 3 4 5 6 NA NA ... 937s OP = '-', na.rm = TRUE 937s num [1:4, 1:4] NA 0 NA 0 NA 4 NA 4 NA 8 ... 937s num [1:4, 1:4] NA NA NA NA 3 4 5 6 NA NA ... 937s OP = '*', na.rm = FALSE 937s num [1:4, 1:4] NA 4 NA 16 NA 12 NA 32 NA 20 ... 937s num [1:4, 1:4] NA NA NA NA 10 12 14 16 NA NA ... 937s OP = '*', na.rm = TRUE 937s num [1:4, 1:4] 1 4 3 16 5 12 7 32 9 20 ... 937s num [1:4, 1:4] 1 2 3 4 10 12 14 16 9 10 ... 937s OP = '/', na.rm = FALSE 937s num [1:4, 1:4] NA 1 NA 1 NA 3 NA 2 NA 5 ... 937s num [1:4, 1:4] NA NA NA NA 2.5 3 3.5 4 NA NA ... 937s OP = '/', na.rm = TRUE 937s num [1:4, 1:4] NA 1 NA 1 NA 3 NA 2 NA 5 ... 937s num [1:4, 1:4] NA NA NA NA 2.5 3 3.5 4 NA NA ... 937s OP = '+', na.rm = FALSE 937s num [1:4, 1:4] NA 4 NA NA NA NA NA 12 NA 12 ... 937s num [1:4, 1:4] NA NA NA NA NA NA 9 10 NA NA ... 937s OP = '+', na.rm = TRUE 937s num [1:4, 1:4] 1 4 NA 4 NA 2 7 12 9 12 ... 937s num [1:4, 1:4] 1 2 NA NA 2 2 9 10 9 10 ... 937s OP = '-', na.rm = FALSE 937s num [1:4, 1:4] NA 0 NA NA NA NA NA 4 NA 8 ... 937s num [1:4, 1:4] NA NA NA NA NA NA 5 6 NA NA ... 937s OP = '-', na.rm = TRUE 937s num [1:4, 1:4] NA 0 NA NA NA NA NA 4 NA 8 ... 937s num [1:4, 1:4] NA NA NA NA NA NA 5 6 NA NA ... 937s OP = '*', na.rm = FALSE 937s num [1:4, 1:4] NA 4 NA NA NA NA NA 32 NA 20 ... 937s num [1:4, 1:4] NA NA NA NA NA NA 14 16 NA NA ... 937s OP = '*', na.rm = TRUE 937s num [1:4, 1:4] 1 4 NA 4 NA 2 7 32 9 20 ... 937s num [1:4, 1:4] 1 2 NA NA 2 2 14 16 9 10 ... 937s OP = '/', na.rm = FALSE 937s num [1:4, 1:4] NA 1 NA NA NA NA NA 2 NA 5 ... 937s num [1:4, 1:4] NA NA NA NA NA NA 3.5 4 NA NA ... 937s OP = '/', na.rm = TRUE 937s num [1:4, 1:4] NA 1 NA NA NA NA NA 2 NA 5 ... 937s num [1:4, 1:4] NA NA NA NA NA NA 3.5 4 NA NA ... 937s > 937s > 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # Length differences 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > x <- matrix(1:8, nrow = 2, ncol = 4) 937s > y <- 1:ncol(x) 937s > storage.mode(y) <- storage.mode(x) 937s > 937s > for (OP in c("+", "-", "*", "/")) { 937s + for (na.rm in c(FALSE, TRUE)) { 937s + cat(sprintf("OP = '%s', na.rm = %s\n", OP, na.rm)) 937s + 937s + a0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 937s + a1 <- x_OP_y(x, y, OP, na.rm = na.rm) 937s + str(a1) 937s + stopifnot(all.equal(a1, a0)) 937s + 937s + b0 <- t_tx_OP_y_R(x, y, OP, na.rm = na.rm) 937s + b1 <- t_tx_OP_y(x, y, OP, na.rm = na.rm) 937s + str(b1) 937s + stopifnot(all.equal(b1, b0)) 937s + } 937s + } 937s OP = '+', na.rm = FALSE 937s int [1:2, 1:4] 2 4 6 8 6 8 10 12 937s int [1:2, 1:4] 2 3 5 6 8 9 11 12 937s OP = '+', na.rm = TRUE 937s int [1:2, 1:4] 2 4 6 8 6 8 10 12 937s int [1:2, 1:4] 2 3 5 6 8 9 11 12 937s OP = '-', na.rm = FALSE 937s int [1:2, 1:4] 0 0 0 0 4 4 4 4 937s int [1:2, 1:4] 0 1 1 2 2 3 3 4 937s OP = '-', na.rm = TRUE 937s int [1:2, 1:4] 0 0 0 0 4 4 4 4 937s int [1:2, 1:4] 0 1 1 2 2 3 3 4 937s OP = '*', na.rm = FALSE 937s int [1:2, 1:4] 1 4 9 16 5 12 21 32 937s int [1:2, 1:4] 1 2 6 8 15 18 28 32 937s OP = '*', na.rm = TRUE 937s int [1:2, 1:4] 1 4 9 16 5 12 21 32 937s int [1:2, 1:4] 1 2 6 8 15 18 28 32 937s OP = '/', na.rm = FALSE 937s num [1:2, 1:4] 1 1 1 1 5 ... 937s num [1:2, 1:4] 1 2 1.5 2 1.67 ... 937s OP = '/', na.rm = TRUE 937s num [1:2, 1:4] 1 1 1 1 5 ... 937s num [1:2, 1:4] 1 2 1.5 2 1.67 ... 937s > 937s > 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > # All missing values 937s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 937s > xs <- list( 937s + A = matrix(1:2, nrow = 2, ncol = 2), 937s + B = matrix(NA_integer_, nrow = 2, ncol = 2) 937s + ) 937s > ys <- list( 937s + A = 1L, 937s + B = NA_integer_ 937s + ) 937s > 937s > for (x in xs) { 937s + for (y in ys) { 937s + for (mode in c("logical", "integer", "double")) { 937s + storage.mode(x) <- mode 937s + storage.mode(y) <- mode 937s + str(list(x = x, y = y)) 937s + 937s + for (OP in c("+", "-", "*", "/")) { 937s + for (na.rm in c(FALSE, TRUE)) { 937s + cat(sprintf("mode = '%s', OP = '%s', na.rm = %s\n", mode, OP, na.rm)) 937s + suppressWarnings({ 937s + z0 <- x_OP_y_R(x, y, OP, na.rm = na.rm) 937s + z <- x_OP_y(x, y, OP, na.rm = na.rm) 937s + }) 937s + str(z) 937s + stopifnot(all.equal(z, z0)) 937s + } 937s + } 937s + } # for (mode ...) 937s + } # for (y ...) 937s + } # for (x ...) 937s List of 2 937s $ x: logi [1:2, 1:2] TRUE TRUE TRUE TRUE 937s $ y: logi TRUE 937s mode = 'logical', OP = '+', na.rm = FALSE 937s int [1:2, 1:2] 2 2 2 2 937s mode = 'logical', OP = '+', na.rm = TRUE 937s int [1:2, 1:2] 2 2 2 2 937s mode = 'logical', OP = '-', na.rm = FALSE 937s int [1:2, 1:2] 0 0 0 0 937s mode = 'logical', OP = '-', na.rm = TRUE 937s int [1:2, 1:2] 0 0 0 0 937s mode = 'logical', OP = '*', na.rm = FALSE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'logical', OP = '*', na.rm = TRUE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'logical', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] 1 1 1 1 937s mode = 'logical', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] 1 1 1 1 937s List of 2 937s $ x: int [1:2, 1:2] 1 1 1 1 937s $ y: int 1 937s mode = 'integer', OP = '+', na.rm = FALSE 937s int [1:2, 1:2] 2 2 2 2 937s mode = 'integer', OP = '+', na.rm = TRUE 937s int [1:2, 1:2] 2 2 2 2 937s mode = 'integer', OP = '-', na.rm = FALSE 937s int [1:2, 1:2] 0 0 0 0 937s mode = 'integer', OP = '-', na.rm = TRUE 937s int [1:2, 1:2] 0 0 0 0 937s mode = 'integer', OP = '*', na.rm = FALSE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'integer', OP = '*', na.rm = TRUE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'integer', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] 1 1 1 1 937s mode = 'integer', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] 1 1 1 1 937s List of 2 937s $ x: num [1:2, 1:2] 1 1 1 1 937s $ y: num 1 937s mode = 'double', OP = '+', na.rm = FALSE 937s num [1:2, 1:2] 2 2 2 2 937s mode = 'double', OP = '+', na.rm = TRUE 937s num [1:2, 1:2] 2 2 2 2 937s mode = 'double', OP = '-', na.rm = FALSE 937s num [1:2, 1:2] 0 0 0 0 937s mode = 'double', OP = '-', na.rm = TRUE 937s num [1:2, 1:2] 0 0 0 0 937s mode = 'double', OP = '*', na.rm = FALSE 937s num [1:2, 1:2] 1 1 1 1 937s mode = 'double', OP = '*', na.rm = TRUE 937s num [1:2, 1:2] 1 1 1 1 937s mode = 'double', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] 1 1 1 1 937s mode = 'double', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] 1 1 1 1 937s List of 2 937s $ x: logi [1:2, 1:2] TRUE TRUE TRUE TRUE 937s $ y: logi NA 937s mode = 'logical', OP = '+', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '+', na.rm = TRUE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'logical', OP = '-', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '-', na.rm = TRUE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '*', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '*', na.rm = TRUE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'logical', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s List of 2 937s $ x: int [1:2, 1:2] 1 1 1 1 937s $ y: int NA 937s mode = 'integer', OP = '+', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '+', na.rm = TRUE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'integer', OP = '-', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '-', na.rm = TRUE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '*', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '*', na.rm = TRUE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'integer', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s List of 2 937s $ x: num [1:2, 1:2] 1 1 1 1 937s $ y: num NA 937s mode = 'double', OP = '+', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '+', na.rm = TRUE 937s num [1:2, 1:2] 1 1 1 1 937s mode = 'double', OP = '-', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '-', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '*', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '*', na.rm = TRUE 937s num [1:2, 1:2] 1 1 1 1 937s mode = 'double', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s List of 2 937s $ x: logi [1:2, 1:2] NA NA NA NA 937s $ y: logi TRUE 937s mode = 'logical', OP = '+', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '+', na.rm = TRUE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'logical', OP = '-', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '-', na.rm = TRUE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '*', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '*', na.rm = TRUE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'logical', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s List of 2 937s $ x: int [1:2, 1:2] NA NA NA NA 937s $ y: int 1 937s mode = 'integer', OP = '+', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '+', na.rm = TRUE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'integer', OP = '-', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '-', na.rm = TRUE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '*', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '*', na.rm = TRUE 937s int [1:2, 1:2] 1 1 1 1 937s mode = 'integer', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s List of 2 937s $ x: num [1:2, 1:2] NA NA NA NA 937s $ y: num 1 937s mode = 'double', OP = '+', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '+', na.rm = TRUE 937s num [1:2, 1:2] 1 1 1 1 937s mode = 'double', OP = '-', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '-', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '*', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '*', na.rm = TRUE 937s num [1:2, 1:2] 1 1 1 1 937s mode = 'double', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s List of 2 937s $ x: logi [1:2, 1:2] NA NA NA NA 937s $ y: logi NA 937s mode = 'logical', OP = '+', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '+', na.rm = TRUE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '-', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '-', na.rm = TRUE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '*', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '*', na.rm = TRUE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'logical', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s List of 2 937s $ x: int [1:2, 1:2] NA NA NA NA 937s $ y: int NA 937s mode = 'integer', OP = '+', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '+', na.rm = TRUE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '-', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '-', na.rm = TRUE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '*', na.rm = FALSE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '*', na.rm = TRUE 937s int [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'integer', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s List of 2 937s $ x: num [1:2, 1:2] NA NA NA NA 937s $ y: num NA 937s mode = 'double', OP = '+', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '+', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '-', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '-', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '*', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '*', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '/', na.rm = FALSE 937s num [1:2, 1:2] NA NA NA NA 937s mode = 'double', OP = '/', na.rm = TRUE 937s num [1:2, 1:2] NA NA NA NA 937s > 938s 938s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 938s Copyright (C) 2024 The R Foundation for Statistical Computing 938s Platform: s390x-ibm-linux-gnu 938s 938s R is free software and comes with ABSOLUTELY NO WARRANTY. 938s You are welcome to redistribute it under certain conditions. 938s Type 'license()' or 'licence()' for distribution details. 938s 938s R is a collaborative project with many contributors. 938s Type 'contributors()' for more information and 938s 'citation()' on how to cite R or R packages in publications. 938s 938s Type 'demo()' for some demos, 'help()' for on-line help, or 938s 'help.start()' for an HTML browser interface to help. 938s Type 'q()' to quit R. 938s 938s > library("matrixStats") 938s > 938s > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 938s + if (na.rm) { 938s + xnok <- is.na(x) 938s + ynok <- is.na(y) 938s + anok <- xnok & ynok 938s + unit <- switch(OP, 938s + "+" = 0, 938s + "-" = NA_real_, 938s + "*" = 1, 938s + "/" = NA_real_, 938s + stop("Unknown 'OP' operator: ", OP) 938s + ) 938s + x[xnok] <- unit 938s + y[ynok] <- unit 938s + } 938s + 938s + ans <- switch(OP, 938s + "+" = x + y, 938s + "-" = x - y, 938s + "*" = x * y, 938s + "/" = x / y, 938s + stop("Unknown 'OP' operator: ", OP) 938s + ) 938s + 938s + if (na.rm) { 938s + ans[anok] <- NA_real_ 938s + } 938s + 938s + ans 938s + } # x_OP_y_R() 938s > 938s > 938s > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) { 938s + t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm)) 938s + } 938s > 938s > 938s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 938s > # Subsetted tests 938s > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 938s > source("utils/validateIndicesFramework.R") 938s > for (OP in c("+", "-", "*", "/")) { 938s + for (mode in c("numeric", "integer", "logical")) { 938s + x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L) 938s + y <- runif(6, min = 0, max = 6) 938s + storage.mode(x) <- mode 938s + storage.mode(y) <- mode 938s + if (mode == "numeric") y[1] <- Inf 938s + 938s + for (xrows in index_cases) { 938s + for (xcols in index_cases) { 938s + if (is.null(xrows)) xrows <- seq_len(nrow(x)) 938s + if (is.null(xcols)) xcols <- seq_len(ncol(x)) 938s + 938s + for (yidxs in list(xrows, xcols)) { 938s + for (na.rm in c(TRUE, FALSE)) { 938s + 938s + suppressWarnings({ 938s + actual <- tryCatch( 938s + x_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs, 938s + na.rm = na.rm), 938s + error = function(c) "error" 938s + ) 938s + 938s + expect <- tryCatch( 938s + x_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP, 938s + na.rm = na.rm), 938s + error = function(c) "error" 938s + ) 938s + }) 938s + stopifnot(all.equal(as.vector(actual), as.vector(expect))) 938s + 938s + suppressWarnings({ 938s + actual <- tryCatch( 938s + t_tx_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs, 938s + na.rm = na.rm), 938s + error = function(c) "error" 938s + ) 938s + 938s + expect <- tryCatch( 938s + t_tx_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP, 938s + na.rm = na.rm), 938s + error = function(c) "error" 938s + ) 938s + }) 938s + stopifnot(all.equal(as.vector(actual), as.vector(expect))) 938s + } 938s + } 938s + } 938s + } 938s + } 938s + } 944s > 944s 944s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 944s Copyright (C) 2024 The R Foundation for Statistical Computing 944s Platform: s390x-ibm-linux-gnu 944s 944s R is free software and comes with ABSOLUTELY NO WARRANTY. 944s You are welcome to redistribute it under certain conditions. 944s Type 'license()' or 'licence()' for distribution details. 944s 944s R is a collaborative project with many contributors. 944s Type 'contributors()' for more information and 944s 'citation()' on how to cite R or R packages in publications. 944s 944s Type 'demo()' for some demos, 'help()' for on-line help, or 944s 'help.start()' for an HTML browser interface to help. 944s Type 'q()' to quit R. 944s 944s > ## These tests need to be last of all tests, otherwise 944s > ## covr::package_coverage() gives an error. 944s > cat("1. Loading package\n") 944s 1. Loading package 944s > loadNamespace("matrixStats") 944s 945s > stopifnot("matrixStats" %in% loadedNamespaces()) 945s > 945s > cat("2. Unloading package\n") 945s 2. Unloading package 945s > unloadNamespace("matrixStats") 945s > stopifnot(!"matrixStats" %in% loadedNamespaces()) 945s > 945s > if (FALSE) { 945s + ## 'covr' gives "Error in library("matrixStats") : 945s + ## there is no package called 'matrixStats'" here, cf. 945s + ## https://travis-ci.org/HenrikBengtsson/matrixStats/builds/48015577 945s + 945s + cat("3. Attaching package\n") 945s + library("matrixStats") 945s + stopifnot("package:matrixStats" %in% search()) 945s + 945s + cat("4. Detaching package\n") 945s + detach("package:matrixStats") 945s + stopifnot(!"package:matrixStats" %in% search()) 945s + stopifnot("matrixStats" %in% loadedNamespaces()) 945s + 945s + cat("5. Unloading package\n") 945s + unloadNamespace("matrixStats") 945s + stopifnot(!"matrixStats" %in% loadedNamespaces()) 945s + 945s + cat("6. Attaching package (again)\n") 945s + library("matrixStats") 945s + stopifnot("package:matrixStats" %in% search()) 945s + 945s + cat("7. Detaching package (again)\n") 945s + detach("package:matrixStats") 945s + stopifnot(!"package:matrixStats" %in% search()) 945s + stopifnot("matrixStats" %in% loadedNamespaces()) 945s + } 945s > 945s > cat("7. DONE\n") 945s 7. DONE 945s > 945s autopkgtest [10:08:02]: test run-unit-test: -----------------------] 961s run-unit-test PASS 961s autopkgtest [10:08:18]: test run-unit-test: - - - - - - - - - - results - - - - - - - - - - 961s autopkgtest [10:08:18]: test pkg-r-autopkgtest: preparing testbed 1184s autopkgtest [10:12:01]: testbed dpkg architecture: s390x 1185s autopkgtest [10:12:02]: testbed apt version: 2.9.3 1185s autopkgtest [10:12:02]: @@@@@@@@@@@@@@@@@@@@ test bed setup 1185s Get:1 http://ftpmaster.internal/ubuntu oracular-proposed InRelease [73.9 kB] 1185s Get:2 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse Sources [3388 B] 1186s Get:3 http://ftpmaster.internal/ubuntu oracular-proposed/main Sources [57.4 kB] 1186s Get:4 http://ftpmaster.internal/ubuntu oracular-proposed/restricted Sources [1964 B] 1186s Get:5 http://ftpmaster.internal/ubuntu oracular-proposed/universe Sources [507 kB] 1186s Get:6 http://ftpmaster.internal/ubuntu oracular-proposed/main s390x Packages [155 kB] 1186s Get:7 http://ftpmaster.internal/ubuntu oracular-proposed/universe s390x Packages [456 kB] 1187s Get:8 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse s390x Packages [1968 B] 1187s Fetched 1257 kB in 2s (665 kB/s) 1187s Reading package lists... 1190s Reading package lists... 1190s Building dependency tree... 1190s Reading state information... 1190s Calculating upgrade... 1191s The following packages will be upgraded: 1191s curl dracut-install gir1.2-glib-2.0 klibc-utils libclang-cpp18 libclang1-18 1191s libcurl3t64-gnutls libcurl4t64 libglib2.0-0t64 libglib2.0-data libklibc 1191s libllvm18 libuv1t64 1191s 13 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 1191s Need to get 61.3 MB of archives. 1191s After this operation, 3163 kB disk space will be freed. 1191s Get:1 http://ftpmaster.internal/ubuntu oracular/main s390x gir1.2-glib-2.0 s390x 2.80.2-1ubuntu1 [180 kB] 1191s Get:2 http://ftpmaster.internal/ubuntu oracular/main s390x libglib2.0-0t64 s390x 2.80.2-1ubuntu1 [1558 kB] 1194s Get:3 http://ftpmaster.internal/ubuntu oracular/main s390x libglib2.0-data all 2.80.2-1ubuntu1 [49.3 kB] 1194s Get:4 http://ftpmaster.internal/ubuntu oracular/main s390x libuv1t64 s390x 1.48.0-4 [100 kB] 1194s Get:5 http://ftpmaster.internal/ubuntu oracular/main s390x curl s390x 8.5.0-2ubuntu10.1 [227 kB] 1194s Get:6 http://ftpmaster.internal/ubuntu oracular/main s390x libcurl4t64 s390x 8.5.0-2ubuntu10.1 [364 kB] 1195s Get:7 http://ftpmaster.internal/ubuntu oracular/main s390x dracut-install s390x 060+5-8ubuntu1 [32.6 kB] 1195s Get:8 http://ftpmaster.internal/ubuntu oracular/main s390x klibc-utils s390x 2.0.13-4ubuntu1 [114 kB] 1195s Get:9 http://ftpmaster.internal/ubuntu oracular/main s390x libklibc s390x 2.0.13-4ubuntu1 [55.0 kB] 1195s Get:10 http://ftpmaster.internal/ubuntu oracular/main s390x libclang-cpp18 s390x 1:18.1.6-1 [15.9 MB] 1218s Get:11 http://ftpmaster.internal/ubuntu oracular/main s390x libllvm18 s390x 1:18.1.6-1 [33.1 MB] 1252s Get:12 http://ftpmaster.internal/ubuntu oracular/main s390x libclang1-18 s390x 1:18.1.6-1 [9290 kB] 1259s Get:13 http://ftpmaster.internal/ubuntu oracular/main s390x libcurl3t64-gnutls s390x 8.5.0-2ubuntu10.1 [356 kB] 1259s Fetched 61.3 MB in 1min 8s (897 kB/s) 1260s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 54977 files and directories currently installed.) 1260s Preparing to unpack .../00-gir1.2-glib-2.0_2.80.2-1ubuntu1_s390x.deb ... 1260s Unpacking gir1.2-glib-2.0:s390x (2.80.2-1ubuntu1) over (2.80.1-0ubuntu2) ... 1260s Preparing to unpack .../01-libglib2.0-0t64_2.80.2-1ubuntu1_s390x.deb ... 1260s Unpacking libglib2.0-0t64:s390x (2.80.2-1ubuntu1) over (2.80.1-0ubuntu2) ... 1260s Preparing to unpack .../02-libglib2.0-data_2.80.2-1ubuntu1_all.deb ... 1260s Unpacking libglib2.0-data (2.80.2-1ubuntu1) over (2.80.1-0ubuntu2) ... 1260s Preparing to unpack .../03-libuv1t64_1.48.0-4_s390x.deb ... 1260s Unpacking libuv1t64:s390x (1.48.0-4) over (1.48.0-1.1build1) ... 1260s Preparing to unpack .../04-curl_8.5.0-2ubuntu10.1_s390x.deb ... 1260s Unpacking curl (8.5.0-2ubuntu10.1) over (8.5.0-2ubuntu10) ... 1260s Preparing to unpack .../05-libcurl4t64_8.5.0-2ubuntu10.1_s390x.deb ... 1260s Unpacking libcurl4t64:s390x (8.5.0-2ubuntu10.1) over (8.5.0-2ubuntu10) ... 1260s Preparing to unpack .../06-dracut-install_060+5-8ubuntu1_s390x.deb ... 1260s Unpacking dracut-install (060+5-8ubuntu1) over (060+5-1ubuntu3) ... 1260s Preparing to unpack .../07-klibc-utils_2.0.13-4ubuntu1_s390x.deb ... 1260s Unpacking klibc-utils (2.0.13-4ubuntu1) over (2.0.13-4) ... 1260s Preparing to unpack .../08-libklibc_2.0.13-4ubuntu1_s390x.deb ... 1260s Unpacking libklibc:s390x (2.0.13-4ubuntu1) over (2.0.13-4) ... 1260s Preparing to unpack .../09-libclang-cpp18_1%3a18.1.6-1_s390x.deb ... 1260s Unpacking libclang-cpp18 (1:18.1.6-1) over (1:18.1.3-1) ... 1261s Preparing to unpack .../10-libllvm18_1%3a18.1.6-1_s390x.deb ... 1261s Unpacking libllvm18:s390x (1:18.1.6-1) over (1:18.1.3-1) ... 1262s Preparing to unpack .../11-libclang1-18_1%3a18.1.6-1_s390x.deb ... 1262s Unpacking libclang1-18 (1:18.1.6-1) over (1:18.1.3-1) ... 1262s Preparing to unpack .../12-libcurl3t64-gnutls_8.5.0-2ubuntu10.1_s390x.deb ... 1262s Unpacking libcurl3t64-gnutls:s390x (8.5.0-2ubuntu10.1) over (8.5.0-2ubuntu10) ... 1262s Setting up libcurl4t64:s390x (8.5.0-2ubuntu10.1) ... 1262s Setting up libuv1t64:s390x (1.48.0-4) ... 1262s Setting up libcurl3t64-gnutls:s390x (8.5.0-2ubuntu10.1) ... 1262s Setting up libklibc:s390x (2.0.13-4ubuntu1) ... 1262s Setting up libglib2.0-0t64:s390x (2.80.2-1ubuntu1) ... 1262s No schema files found: doing nothing. 1262s Setting up libglib2.0-data (2.80.2-1ubuntu1) ... 1262s Setting up gir1.2-glib-2.0:s390x (2.80.2-1ubuntu1) ... 1262s Setting up dracut-install (060+5-8ubuntu1) ... 1262s Setting up curl (8.5.0-2ubuntu10.1) ... 1262s Setting up klibc-utils (2.0.13-4ubuntu1) ... 1262s Setting up libllvm18:s390x (1:18.1.6-1) ... 1262s Setting up libclang1-18 (1:18.1.6-1) ... 1262s Setting up libclang-cpp18 (1:18.1.6-1) ... 1262s Processing triggers for libc-bin (2.39-0ubuntu8.1) ... 1262s Processing triggers for man-db (2.12.1-1) ... 1263s Processing triggers for initramfs-tools (0.142ubuntu27) ... 1263s update-initramfs: Generating /boot/initrd.img-6.8.0-31-generic 1263s W: No lz4 in /usr/bin:/sbin:/bin, using gzip 1268s Using config file '/etc/zipl.conf' 1268s Building bootmap in '/boot' 1268s Adding IPL section 'ubuntu' (default) 1268s Preparing boot device for LD-IPL: sda. 1268s Done. 1268s Reading package lists... 1269s Building dependency tree... 1269s Reading state information... 1269s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 1270s Hit:1 http://ftpmaster.internal/ubuntu oracular InRelease 1270s Hit:2 http://ftpmaster.internal/ubuntu oracular-updates InRelease 1270s Hit:3 http://ftpmaster.internal/ubuntu oracular-security InRelease 1270s Hit:4 http://ftpmaster.internal/ubuntu oracular-proposed InRelease 1271s Reading package lists... 1271s Reading package lists... 1272s Building dependency tree... 1272s Reading state information... 1272s Calculating upgrade... 1272s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 1272s Reading package lists... 1272s Building dependency tree... 1272s Reading state information... 1273s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 1273s autopkgtest [10:13:30]: rebooting testbed after setup commands that affected boot 1278s autopkgtest-virt-ssh: WARNING: ssh connection failed. Retrying in 3 seconds... 1311s autopkgtest-virt-ssh: WARNING: ssh connection failed. Retrying in 3 seconds... 1323s Reading package lists... 1323s Building dependency tree... 1323s Reading state information... 1324s Starting pkgProblemResolver with broken count: 0 1324s Starting 2 pkgProblemResolver with broken count: 0 1324s Done 1324s The following additional packages will be installed: 1324s build-essential cpp cpp-13 cpp-13-s390x-linux-gnu cpp-s390x-linux-gnu 1324s dctrl-tools fontconfig fonts-glyphicons-halflings fonts-mathjax g++ g++-13 1324s g++-13-s390x-linux-gnu g++-s390x-linux-gnu gcc gcc-13 gcc-13-base 1324s gcc-13-s390x-linux-gnu gcc-s390x-linux-gnu gfortran gfortran-13 1324s gfortran-13-s390x-linux-gnu gfortran-s390x-linux-gnu icu-devtools libasan8 1324s libatomic1 libblas-dev libblas3 libbz2-dev libcairo2 libcc1-0 libdatrie1 1324s libdeflate-dev libgcc-13-dev libgfortran-13-dev libgfortran5 libgomp1 1324s libgraphite2-3 libharfbuzz0b libice6 libicu-dev libisl23 libitm1 libjpeg-dev 1324s libjpeg-turbo8-dev libjpeg8-dev libjs-bootstrap libjs-highlight.js 1324s libjs-jquery libjs-jquery-datatables libjs-mathjax liblapack-dev liblapack3 1324s liblzma-dev libmpc3 libncurses-dev libpango-1.0-0 libpangocairo-1.0-0 1324s libpangoft2-1.0-0 libpaper-utils libpaper1 libpcre2-16-0 libpcre2-32-0 1324s libpcre2-dev libpcre2-posix3 libpixman-1-0 libpkgconf3 libpng-dev 1324s libreadline-dev libsm6 libstdc++-13-dev libtcl8.6 libthai-data libthai0 1324s libtirpc-dev libtk8.6 libubsan1 libxcb-render0 libxcb-shm0 libxft2 1324s libxrender1 libxss1 libxt6t64 node-normalize.css pkg-r-autopkgtest pkgconf 1324s pkgconf-bin r-base-core r-base-dev r-cran-base64enc r-cran-cli 1324s r-cran-colorspace r-cran-commonmark r-cran-evaluate r-cran-fansi 1324s r-cran-farver r-cran-ggplot2 r-cran-glue r-cran-gtable r-cran-highr 1324s r-cran-isoband r-cran-knitr r-cran-labeling r-cran-lattice r-cran-lifecycle 1324s r-cran-magrittr r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats 1324s r-cran-mgcv r-cran-munsell r-cran-nlme r-cran-pillar r-cran-pkgconfig 1324s r-cran-r6 r-cran-rcolorbrewer r-cran-rlang r-cran-scales r-cran-tibble 1324s r-cran-utf8 r-cran-vctrs r-cran-viridislite r-cran-withr r-cran-xfun 1324s r-cran-yaml unzip x11-common xdg-utils zip zlib1g-dev 1324s Suggested packages: 1324s cpp-doc gcc-13-locales cpp-13-doc debtags g++-multilib g++-13-multilib 1324s gcc-13-doc gcc-multilib manpages-dev autoconf automake libtool flex bison 1324s gdb gcc-doc gcc-13-multilib gdb-s390x-linux-gnu gfortran-multilib 1324s gfortran-doc gfortran-13-multilib gfortran-13-doc libcoarrays-dev 1324s liblapack-doc icu-doc fonts-mathjax-extras fonts-stix libjs-mathjax-doc 1324s liblzma-doc ncurses-doc readline-doc libstdc++-13-doc tcl8.6 tk8.6 1324s libjs-html5shiv elpa-ess r-doc-info | r-doc-pdf r-mathlib r-base-html 1324s texlive-base texlive-latex-base texlive-plain-generic 1324s texlive-fonts-recommended texlive-fonts-extra texlive-extra-utils 1324s texlive-latex-recommended texlive-latex-extra texinfo r-cran-kernsmooth 1324s r-cran-kernlab r-cran-mvtnorm r-cran-vcd r-cran-shiny r-cran-shinyjs 1324s r-cran-dplyr r-cran-png r-cran-jpeg r-cran-rmarkdown r-cran-viridis 1324s r-cran-covr r-cran-magick r-cran-sf r-cran-bit64 r-cran-dbi 1324s r-cran-formattable r-cran-nanotime r-cran-palmerpenguins r-cran-stringi 1324s r-cran-survival r-cran-units r-cran-vdiffr r-cran-testthat r-cran-bench 1324s r-cran-blob r-cran-brio r-cran-callr r-cran-crayon r-cran-here r-cran-hms 1324s r-cran-htmltools r-cran-pkgbuild r-cran-pkgload r-cran-purrr r-cran-tidyr 1324s Recommended packages: 1324s bzip2-doc javascript-common libpng-tools r-recommended r-doc-html 1324s r-cran-callr r-cran-covr r-cran-crayon r-cran-digest r-cran-htmltools 1324s r-cran-htmlwidgets r-cran-mockery r-cran-processx r-cran-ps r-cran-rmarkdown 1324s r-cran-rprojroot r-cran-rstudioapi r-cran-testthat r-cran-whoami r-cran-curl 1324s r-cran-xml2 r-cran-unitizer r-cran-dplyr r-cran-hexbin r-cran-hmisc 1324s r-cran-mapproj r-cran-maps r-cran-multcomp r-cran-profvis r-cran-quantreg 1324s r-cran-ragg r-cran-rpart r-cran-sf r-cran-svglite r-cran-vdiffr r-cran-dbi 1324s r-cran-rsqlite r-cran-waldo r-cran-testit r-cran-bslib r-cran-codetools 1324s r-cran-formatr r-cran-gridsvg r-cran-jpeg r-cran-magick r-cran-png 1324s r-cran-reticulate r-cran-rgl r-cran-sass r-cran-tikzdevice r-cran-tinytex 1324s r-cran-webshot node-highlight.js r-cran-lintr r-cran-tidyverse r-cran-rcurl 1324s r-cran-r.devices r-cran-r.rsp r-cran-lubridate r-cran-fs r-cran-usethis 1324s r-cran-bit64 r-cran-dichromat r-cran-hms r-cran-stringi r-cran-data.table 1324s r-cran-mockr r-cran-formattable r-cran-generics r-cran-pkgdown 1324s r-cran-zeallot r-cran-mime r-cran-remotes r-cran-renv r-cran-jsonlite 1324s r-cran-runit libfile-mimeinfo-perl libnet-dbus-perl libx11-protocol-perl 1324s x11-utils x11-xserver-utils 1324s The following NEW packages will be installed: 1324s autopkgtest-satdep build-essential cpp cpp-13 cpp-13-s390x-linux-gnu 1324s cpp-s390x-linux-gnu dctrl-tools fontconfig fonts-glyphicons-halflings 1324s fonts-mathjax g++ g++-13 g++-13-s390x-linux-gnu g++-s390x-linux-gnu gcc 1324s gcc-13 gcc-13-base gcc-13-s390x-linux-gnu gcc-s390x-linux-gnu gfortran 1324s gfortran-13 gfortran-13-s390x-linux-gnu gfortran-s390x-linux-gnu 1324s icu-devtools libasan8 libatomic1 libblas-dev libblas3 libbz2-dev libcairo2 1324s libcc1-0 libdatrie1 libdeflate-dev libgcc-13-dev libgfortran-13-dev 1324s libgfortran5 libgomp1 libgraphite2-3 libharfbuzz0b libice6 libicu-dev 1324s libisl23 libitm1 libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libjs-bootstrap 1324s libjs-highlight.js libjs-jquery libjs-jquery-datatables libjs-mathjax 1324s liblapack-dev liblapack3 liblzma-dev libmpc3 libncurses-dev libpango-1.0-0 1324s libpangocairo-1.0-0 libpangoft2-1.0-0 libpaper-utils libpaper1 libpcre2-16-0 1324s libpcre2-32-0 libpcre2-dev libpcre2-posix3 libpixman-1-0 libpkgconf3 1324s libpng-dev libreadline-dev libsm6 libstdc++-13-dev libtcl8.6 libthai-data 1324s libthai0 libtirpc-dev libtk8.6 libubsan1 libxcb-render0 libxcb-shm0 libxft2 1324s libxrender1 libxss1 libxt6t64 node-normalize.css pkg-r-autopkgtest pkgconf 1324s pkgconf-bin r-base-core r-base-dev r-cran-base64enc r-cran-cli 1324s r-cran-colorspace r-cran-commonmark r-cran-evaluate r-cran-fansi 1324s r-cran-farver r-cran-ggplot2 r-cran-glue r-cran-gtable r-cran-highr 1324s r-cran-isoband r-cran-knitr r-cran-labeling r-cran-lattice r-cran-lifecycle 1324s r-cran-magrittr r-cran-markdown r-cran-mass r-cran-matrix r-cran-matrixstats 1324s r-cran-mgcv r-cran-munsell r-cran-nlme r-cran-pillar r-cran-pkgconfig 1324s r-cran-r6 r-cran-rcolorbrewer r-cran-rlang r-cran-scales r-cran-tibble 1324s r-cran-utf8 r-cran-vctrs r-cran-viridislite r-cran-withr r-cran-xfun 1324s r-cran-yaml unzip x11-common xdg-utils zip zlib1g-dev 1324s 0 upgraded, 131 newly installed, 0 to remove and 0 not upgraded. 1324s Need to get 161 MB/161 MB of archives. 1324s After this operation, 460 MB of additional disk space will be used. 1324s Get:1 /tmp/autopkgtest.HmO1t4/2-autopkgtest-satdep.deb autopkgtest-satdep s390x 0 [756 B] 1324s Get:2 http://ftpmaster.internal/ubuntu oracular/main s390x gcc-13-base s390x 13.2.0-23ubuntu4 [48.9 kB] 1325s Get:3 http://ftpmaster.internal/ubuntu oracular/main s390x libisl23 s390x 0.26-3build1 [713 kB] 1325s Get:4 http://ftpmaster.internal/ubuntu oracular/main s390x libmpc3 s390x 1.3.1-1build1 [58.4 kB] 1325s Get:5 http://ftpmaster.internal/ubuntu oracular/main s390x cpp-13-s390x-linux-gnu s390x 13.2.0-23ubuntu4 [9939 kB] 1328s Get:6 http://ftpmaster.internal/ubuntu oracular/main s390x cpp-13 s390x 13.2.0-23ubuntu4 [1030 B] 1328s Get:7 http://ftpmaster.internal/ubuntu oracular/main s390x cpp-s390x-linux-gnu s390x 4:13.2.0-7ubuntu1 [5308 B] 1328s Get:8 http://ftpmaster.internal/ubuntu oracular/main s390x cpp s390x 4:13.2.0-7ubuntu1 [22.4 kB] 1328s Get:9 http://ftpmaster.internal/ubuntu oracular/main s390x libcc1-0 s390x 14.1.0-1ubuntu1 [50.7 kB] 1328s Get:10 http://ftpmaster.internal/ubuntu oracular/main s390x libgomp1 s390x 14.1.0-1ubuntu1 [151 kB] 1328s Get:11 http://ftpmaster.internal/ubuntu oracular/main s390x libitm1 s390x 14.1.0-1ubuntu1 [31.1 kB] 1328s Get:12 http://ftpmaster.internal/ubuntu oracular/main s390x libatomic1 s390x 14.1.0-1ubuntu1 [9378 B] 1328s Get:13 http://ftpmaster.internal/ubuntu oracular/main s390x libasan8 s390x 14.1.0-1ubuntu1 [3003 kB] 1328s Get:14 http://ftpmaster.internal/ubuntu oracular/main s390x libubsan1 s390x 14.1.0-1ubuntu1 [1189 kB] 1328s Get:15 http://ftpmaster.internal/ubuntu oracular/main s390x libgcc-13-dev s390x 13.2.0-23ubuntu4 [1004 kB] 1328s Get:16 http://ftpmaster.internal/ubuntu oracular/main s390x gcc-13-s390x-linux-gnu s390x 13.2.0-23ubuntu4 [19.1 MB] 1329s Get:17 http://ftpmaster.internal/ubuntu oracular/main s390x gcc-13 s390x 13.2.0-23ubuntu4 [472 kB] 1329s Get:18 http://ftpmaster.internal/ubuntu oracular/main s390x gcc-s390x-linux-gnu s390x 4:13.2.0-7ubuntu1 [1208 B] 1329s Get:19 http://ftpmaster.internal/ubuntu oracular/main s390x gcc s390x 4:13.2.0-7ubuntu1 [5014 B] 1329s Get:20 http://ftpmaster.internal/ubuntu oracular/main s390x libstdc++-13-dev s390x 13.2.0-23ubuntu4 [2494 kB] 1329s Get:21 http://ftpmaster.internal/ubuntu oracular/main s390x g++-13-s390x-linux-gnu s390x 13.2.0-23ubuntu4 [11.3 MB] 1330s Get:22 http://ftpmaster.internal/ubuntu oracular/main s390x g++-13 s390x 13.2.0-23ubuntu4 [14.5 kB] 1330s Get:23 http://ftpmaster.internal/ubuntu oracular/main s390x g++-s390x-linux-gnu s390x 4:13.2.0-7ubuntu1 [956 B] 1330s Get:24 http://ftpmaster.internal/ubuntu oracular/main s390x g++ s390x 4:13.2.0-7ubuntu1 [1096 B] 1330s Get:25 http://ftpmaster.internal/ubuntu oracular/main s390x build-essential s390x 12.10ubuntu1 [4930 B] 1330s Get:26 http://ftpmaster.internal/ubuntu oracular/main s390x dctrl-tools s390x 2.24-3build3 [106 kB] 1330s Get:27 http://ftpmaster.internal/ubuntu oracular/main s390x fontconfig s390x 2.15.0-1.1ubuntu2 [191 kB] 1330s Get:28 http://ftpmaster.internal/ubuntu oracular/universe s390x fonts-glyphicons-halflings all 1.009~3.4.1+dfsg-3 [118 kB] 1330s Get:29 http://ftpmaster.internal/ubuntu oracular/main s390x fonts-mathjax all 2.7.9+dfsg-1 [2208 kB] 1330s Get:30 http://ftpmaster.internal/ubuntu oracular/main s390x libgfortran5 s390x 14.1.0-1ubuntu1 [600 kB] 1330s Get:31 http://ftpmaster.internal/ubuntu oracular/main s390x libgfortran-13-dev s390x 13.2.0-23ubuntu4 [623 kB] 1330s Get:32 http://ftpmaster.internal/ubuntu oracular/main s390x gfortran-13-s390x-linux-gnu s390x 13.2.0-23ubuntu4 [10.4 MB] 1330s Get:33 http://ftpmaster.internal/ubuntu oracular/main s390x gfortran-13 s390x 13.2.0-23ubuntu4 [11.7 kB] 1330s Get:34 http://ftpmaster.internal/ubuntu oracular/main s390x gfortran-s390x-linux-gnu s390x 4:13.2.0-7ubuntu1 [1016 B] 1330s Get:35 http://ftpmaster.internal/ubuntu oracular/main s390x gfortran s390x 4:13.2.0-7ubuntu1 [1174 B] 1330s Get:36 http://ftpmaster.internal/ubuntu oracular/main s390x icu-devtools s390x 74.2-1ubuntu3 [223 kB] 1330s Get:37 http://ftpmaster.internal/ubuntu oracular/main s390x libblas3 s390x 3.12.0-3build1 [245 kB] 1330s Get:38 http://ftpmaster.internal/ubuntu oracular/main s390x libblas-dev s390x 3.12.0-3build1 [239 kB] 1330s Get:39 http://ftpmaster.internal/ubuntu oracular/main s390x libbz2-dev s390x 1.0.8-5.1 [39.4 kB] 1330s Get:40 http://ftpmaster.internal/ubuntu oracular/main s390x libpixman-1-0 s390x 0.42.2-1build1 [206 kB] 1330s Get:41 http://ftpmaster.internal/ubuntu oracular/main s390x libxcb-render0 s390x 1.17.0-2 [17.0 kB] 1330s Get:42 http://ftpmaster.internal/ubuntu oracular/main s390x libxcb-shm0 s390x 1.17.0-2 [5862 B] 1330s Get:43 http://ftpmaster.internal/ubuntu oracular/main s390x libxrender1 s390x 1:0.9.10-1.1build1 [20.4 kB] 1330s Get:44 http://ftpmaster.internal/ubuntu oracular/main s390x libcairo2 s390x 1.18.0-3build1 [589 kB] 1330s Get:45 http://ftpmaster.internal/ubuntu oracular/main s390x libdatrie1 s390x 0.2.13-3build1 [20.6 kB] 1330s Get:46 http://ftpmaster.internal/ubuntu oracular/main s390x libdeflate-dev s390x 1.20-1 [52.1 kB] 1330s Get:47 http://ftpmaster.internal/ubuntu oracular/main s390x libgraphite2-3 s390x 1.3.14-2build1 [80.0 kB] 1330s Get:48 http://ftpmaster.internal/ubuntu oracular/main s390x libharfbuzz0b s390x 8.3.0-2build2 [515 kB] 1330s Get:49 http://ftpmaster.internal/ubuntu oracular/main s390x x11-common all 1:7.7+23ubuntu3 [21.7 kB] 1330s Get:50 http://ftpmaster.internal/ubuntu oracular/main s390x libice6 s390x 2:1.0.10-1build3 [44.8 kB] 1330s Get:51 http://ftpmaster.internal/ubuntu oracular/main s390x libicu-dev s390x 74.2-1ubuntu3 [11.9 MB] 1331s Get:52 http://ftpmaster.internal/ubuntu oracular/main s390x libjpeg-turbo8-dev s390x 2.1.5-2ubuntu2 [284 kB] 1331s Get:53 http://ftpmaster.internal/ubuntu oracular/main s390x libjpeg8-dev s390x 8c-2ubuntu11 [1484 B] 1331s Get:54 http://ftpmaster.internal/ubuntu oracular/main s390x libjpeg-dev s390x 8c-2ubuntu11 [1484 B] 1331s Get:55 http://ftpmaster.internal/ubuntu oracular/universe s390x libjs-bootstrap all 3.4.1+dfsg-3 [129 kB] 1331s Get:56 http://ftpmaster.internal/ubuntu oracular/universe s390x libjs-highlight.js all 9.18.5+dfsg1-2 [385 kB] 1331s Get:57 http://ftpmaster.internal/ubuntu oracular/main s390x libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 1331s Get:58 http://ftpmaster.internal/ubuntu oracular/universe s390x libjs-jquery-datatables all 1.11.5+dfsg-2 [146 kB] 1331s Get:59 http://ftpmaster.internal/ubuntu oracular/main s390x liblapack3 s390x 3.12.0-3build1 [2976 kB] 1331s Get:60 http://ftpmaster.internal/ubuntu oracular/main s390x liblapack-dev s390x 3.12.0-3build1 [5983 kB] 1331s Get:61 http://ftpmaster.internal/ubuntu oracular/main s390x libncurses-dev s390x 6.4+20240113-1ubuntu2 [412 kB] 1331s Get:62 http://ftpmaster.internal/ubuntu oracular/main s390x libthai-data all 0.1.29-2build1 [158 kB] 1331s Get:63 http://ftpmaster.internal/ubuntu oracular/main s390x libthai0 s390x 0.1.29-2build1 [20.7 kB] 1331s Get:64 http://ftpmaster.internal/ubuntu oracular/main s390x libpango-1.0-0 s390x 1.52.2+ds-1 [242 kB] 1331s Get:65 http://ftpmaster.internal/ubuntu oracular/main s390x libpangoft2-1.0-0 s390x 1.52.2+ds-1 [43.4 kB] 1331s Get:66 http://ftpmaster.internal/ubuntu oracular/main s390x libpangocairo-1.0-0 s390x 1.52.2+ds-1 [28.2 kB] 1331s Get:67 http://ftpmaster.internal/ubuntu oracular/main s390x libpaper1 s390x 1.1.29build1 [13.4 kB] 1331s Get:68 http://ftpmaster.internal/ubuntu oracular/main s390x libpaper-utils s390x 1.1.29build1 [8442 B] 1331s Get:69 http://ftpmaster.internal/ubuntu oracular/main s390x libpcre2-16-0 s390x 10.42-4ubuntu2 [233 kB] 1331s Get:70 http://ftpmaster.internal/ubuntu oracular/main s390x libpcre2-32-0 s390x 10.42-4ubuntu2 [219 kB] 1331s Get:71 http://ftpmaster.internal/ubuntu oracular/main s390x libpcre2-posix3 s390x 10.42-4ubuntu2 [6752 B] 1331s Get:72 http://ftpmaster.internal/ubuntu oracular/main s390x libpcre2-dev s390x 10.42-4ubuntu2 [809 kB] 1331s Get:73 http://ftpmaster.internal/ubuntu oracular/main s390x libpkgconf3 s390x 1.8.1-2build1 [31.4 kB] 1331s Get:74 http://ftpmaster.internal/ubuntu oracular/main s390x zlib1g-dev s390x 1:1.3.dfsg-3.1ubuntu2 [904 kB] 1331s Get:75 http://ftpmaster.internal/ubuntu oracular/main s390x libpng-dev s390x 1.6.43-5build1 [277 kB] 1331s Get:76 http://ftpmaster.internal/ubuntu oracular/main s390x libreadline-dev s390x 8.2-4build1 [189 kB] 1331s Get:77 http://ftpmaster.internal/ubuntu oracular/main s390x libsm6 s390x 2:1.2.3-1build3 [17.7 kB] 1331s Get:78 http://ftpmaster.internal/ubuntu oracular/main s390x libtcl8.6 s390x 8.6.14+dfsg-1build1 [1038 kB] 1331s Get:79 http://ftpmaster.internal/ubuntu oracular/main s390x libxft2 s390x 2.3.6-1build1 [49.6 kB] 1331s Get:80 http://ftpmaster.internal/ubuntu oracular/main s390x libxss1 s390x 1:1.2.3-1build3 [7396 B] 1331s Get:81 http://ftpmaster.internal/ubuntu oracular/main s390x libtk8.6 s390x 8.6.14-1build1 [833 kB] 1331s Get:82 http://ftpmaster.internal/ubuntu oracular/main s390x libxt6t64 s390x 1:1.2.1-1.2build1 [184 kB] 1331s Get:83 http://ftpmaster.internal/ubuntu oracular/universe s390x node-normalize.css all 8.0.1-5 [10.8 kB] 1331s Get:84 http://ftpmaster.internal/ubuntu oracular/main s390x zip s390x 3.0-13build1 [189 kB] 1331s Get:85 http://ftpmaster.internal/ubuntu oracular/main s390x unzip s390x 6.0-28ubuntu4 [180 kB] 1331s Get:86 http://ftpmaster.internal/ubuntu oracular/main s390x xdg-utils all 1.1.3-4.1ubuntu3 [62.0 kB] 1331s Get:87 http://ftpmaster.internal/ubuntu oracular/universe s390x r-base-core s390x 4.4.0-2 [28.5 MB] 1332s Get:88 http://ftpmaster.internal/ubuntu oracular/main s390x liblzma-dev s390x 5.6.1+really5.4.5-1 [184 kB] 1332s Get:89 http://ftpmaster.internal/ubuntu oracular/main s390x pkgconf-bin s390x 1.8.1-2build1 [21.3 kB] 1332s Get:90 http://ftpmaster.internal/ubuntu oracular/main s390x pkgconf s390x 1.8.1-2build1 [16.8 kB] 1332s Get:91 http://ftpmaster.internal/ubuntu oracular/main s390x libtirpc-dev s390x 1.3.4+ds-1.3 [196 kB] 1332s Get:92 http://ftpmaster.internal/ubuntu oracular/universe s390x r-base-dev all 4.4.0-2 [4340 B] 1332s Get:93 http://ftpmaster.internal/ubuntu oracular/universe s390x pkg-r-autopkgtest all 20231212ubuntu1 [6448 B] 1332s Get:94 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-base64enc s390x 0.1-3-3 [28.0 kB] 1332s Get:95 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-cli s390x 3.6.2-1 [1382 kB] 1332s Get:96 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-colorspace s390x 2.1-0+dfsg-1 [1540 kB] 1332s Get:97 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-commonmark s390x 1.9.1-1 [142 kB] 1332s Get:98 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-evaluate all 0.23-1 [90.2 kB] 1332s Get:99 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-fansi s390x 1.0.5-1 [615 kB] 1332s Get:100 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-farver s390x 2.1.1-2 [1351 kB] 1332s Get:101 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-glue s390x 1.7.0-1 [154 kB] 1332s Get:102 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-rlang s390x 1.1.3-1 [1672 kB] 1332s Get:103 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-lifecycle all 1.0.4+dfsg-1 [110 kB] 1333s Get:104 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-gtable all 0.3.4+dfsg-1 [191 kB] 1333s Get:105 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-isoband s390x 0.2.7-1 [1481 kB] 1333s Get:106 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-mass s390x 7.3-60.2-1 [1112 kB] 1333s Get:107 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-lattice s390x 0.22-6-1 [1340 kB] 1333s Get:108 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-nlme s390x 3.1.164-1build1 [2270 kB] 1333s Get:109 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-matrix s390x 1.6-5-1 [3983 kB] 1333s Get:110 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-mgcv s390x 1.9-1-1 [3348 kB] 1333s Get:111 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-labeling all 0.4.3-1 [62.1 kB] 1333s Get:112 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-munsell all 0.5.0-2build1 [208 kB] 1333s Get:113 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-r6 all 2.5.1-1 [99.0 kB] 1333s Get:114 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-rcolorbrewer all 1.1-3-1build1 [55.4 kB] 1333s Get:115 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-viridislite all 0.4.2-2 [1088 kB] 1333s Get:116 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-scales all 1.3.0-1 [603 kB] 1333s Get:117 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-magrittr s390x 2.0.3-1 [154 kB] 1333s Get:118 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-utf8 s390x 1.2.4-1 [143 kB] 1333s Get:119 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-vctrs s390x 0.6.5-1 [1448 kB] 1333s Get:120 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-pillar all 1.9.0+dfsg-1 [464 kB] 1333s Get:121 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-pkgconfig all 2.0.3-2build1 [19.7 kB] 1333s Get:122 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-tibble s390x 3.2.1+dfsg-2 [415 kB] 1333s Get:123 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-withr all 2.5.0-1 [225 kB] 1333s Get:124 http://ftpmaster.internal/ubuntu oracular-proposed/universe s390x r-cran-ggplot2 all 3.5.1+dfsg-1 [3940 kB] 1333s Get:125 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-xfun s390x 0.44+dfsg-1 [517 kB] 1333s Get:126 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-highr all 0.10+dfsg-2 [38.5 kB] 1333s Get:127 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-yaml s390x 2.3.8-2 [112 kB] 1333s Get:128 http://ftpmaster.internal/ubuntu oracular/main s390x libjs-mathjax all 2.7.9+dfsg-1 [5665 kB] 1334s Get:129 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-knitr all 1.46+dfsg-1 [911 kB] 1334s Get:130 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-markdown all 1.12+dfsg-2 [179 kB] 1334s Get:131 http://ftpmaster.internal/ubuntu oracular/universe s390x r-cran-matrixstats s390x 1.2.0-1 [513 kB] 1334s Preconfiguring packages ... 1335s Fetched 161 MB in 9s (17.0 MB/s) 1335s Selecting previously unselected package gcc-13-base:s390x. 1335s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 54978 files and directories currently installed.) 1335s Preparing to unpack .../000-gcc-13-base_13.2.0-23ubuntu4_s390x.deb ... 1335s Unpacking gcc-13-base:s390x (13.2.0-23ubuntu4) ... 1335s Selecting previously unselected package libisl23:s390x. 1335s Preparing to unpack .../001-libisl23_0.26-3build1_s390x.deb ... 1335s Unpacking libisl23:s390x (0.26-3build1) ... 1335s Selecting previously unselected package libmpc3:s390x. 1335s Preparing to unpack .../002-libmpc3_1.3.1-1build1_s390x.deb ... 1335s Unpacking libmpc3:s390x (1.3.1-1build1) ... 1335s Selecting previously unselected package cpp-13-s390x-linux-gnu. 1335s Preparing to unpack .../003-cpp-13-s390x-linux-gnu_13.2.0-23ubuntu4_s390x.deb ... 1335s Unpacking cpp-13-s390x-linux-gnu (13.2.0-23ubuntu4) ... 1335s Selecting previously unselected package cpp-13. 1335s Preparing to unpack .../004-cpp-13_13.2.0-23ubuntu4_s390x.deb ... 1335s Unpacking cpp-13 (13.2.0-23ubuntu4) ... 1335s Selecting previously unselected package cpp-s390x-linux-gnu. 1335s Preparing to unpack .../005-cpp-s390x-linux-gnu_4%3a13.2.0-7ubuntu1_s390x.deb ... 1335s Unpacking cpp-s390x-linux-gnu (4:13.2.0-7ubuntu1) ... 1335s Selecting previously unselected package cpp. 1335s Preparing to unpack .../006-cpp_4%3a13.2.0-7ubuntu1_s390x.deb ... 1335s Unpacking cpp (4:13.2.0-7ubuntu1) ... 1335s Selecting previously unselected package libcc1-0:s390x. 1335s Preparing to unpack .../007-libcc1-0_14.1.0-1ubuntu1_s390x.deb ... 1335s Unpacking libcc1-0:s390x (14.1.0-1ubuntu1) ... 1335s Selecting previously unselected package libgomp1:s390x. 1335s Preparing to unpack .../008-libgomp1_14.1.0-1ubuntu1_s390x.deb ... 1335s Unpacking libgomp1:s390x (14.1.0-1ubuntu1) ... 1335s Selecting previously unselected package libitm1:s390x. 1335s Preparing to unpack .../009-libitm1_14.1.0-1ubuntu1_s390x.deb ... 1335s Unpacking libitm1:s390x (14.1.0-1ubuntu1) ... 1335s Selecting previously unselected package libatomic1:s390x. 1335s Preparing to unpack .../010-libatomic1_14.1.0-1ubuntu1_s390x.deb ... 1335s Unpacking libatomic1:s390x (14.1.0-1ubuntu1) ... 1335s Selecting previously unselected package libasan8:s390x. 1335s Preparing to unpack .../011-libasan8_14.1.0-1ubuntu1_s390x.deb ... 1335s Unpacking libasan8:s390x (14.1.0-1ubuntu1) ... 1335s Selecting previously unselected package libubsan1:s390x. 1335s Preparing to unpack .../012-libubsan1_14.1.0-1ubuntu1_s390x.deb ... 1335s Unpacking libubsan1:s390x (14.1.0-1ubuntu1) ... 1335s Selecting previously unselected package libgcc-13-dev:s390x. 1335s Preparing to unpack .../013-libgcc-13-dev_13.2.0-23ubuntu4_s390x.deb ... 1335s Unpacking libgcc-13-dev:s390x (13.2.0-23ubuntu4) ... 1335s Selecting previously unselected package gcc-13-s390x-linux-gnu. 1335s Preparing to unpack .../014-gcc-13-s390x-linux-gnu_13.2.0-23ubuntu4_s390x.deb ... 1335s Unpacking gcc-13-s390x-linux-gnu (13.2.0-23ubuntu4) ... 1336s Selecting previously unselected package gcc-13. 1336s Preparing to unpack .../015-gcc-13_13.2.0-23ubuntu4_s390x.deb ... 1336s Unpacking gcc-13 (13.2.0-23ubuntu4) ... 1336s Selecting previously unselected package gcc-s390x-linux-gnu. 1336s Preparing to unpack .../016-gcc-s390x-linux-gnu_4%3a13.2.0-7ubuntu1_s390x.deb ... 1336s Unpacking gcc-s390x-linux-gnu (4:13.2.0-7ubuntu1) ... 1336s Selecting previously unselected package gcc. 1336s Preparing to unpack .../017-gcc_4%3a13.2.0-7ubuntu1_s390x.deb ... 1336s Unpacking gcc (4:13.2.0-7ubuntu1) ... 1336s Selecting previously unselected package libstdc++-13-dev:s390x. 1336s Preparing to unpack .../018-libstdc++-13-dev_13.2.0-23ubuntu4_s390x.deb ... 1336s Unpacking libstdc++-13-dev:s390x (13.2.0-23ubuntu4) ... 1336s Selecting previously unselected package g++-13-s390x-linux-gnu. 1336s Preparing to unpack .../019-g++-13-s390x-linux-gnu_13.2.0-23ubuntu4_s390x.deb ... 1336s Unpacking g++-13-s390x-linux-gnu (13.2.0-23ubuntu4) ... 1336s Selecting previously unselected package g++-13. 1336s Preparing to unpack .../020-g++-13_13.2.0-23ubuntu4_s390x.deb ... 1336s Unpacking g++-13 (13.2.0-23ubuntu4) ... 1336s Selecting previously unselected package g++-s390x-linux-gnu. 1336s Preparing to unpack .../021-g++-s390x-linux-gnu_4%3a13.2.0-7ubuntu1_s390x.deb ... 1336s Unpacking g++-s390x-linux-gnu (4:13.2.0-7ubuntu1) ... 1336s Selecting previously unselected package g++. 1336s Preparing to unpack .../022-g++_4%3a13.2.0-7ubuntu1_s390x.deb ... 1336s Unpacking g++ (4:13.2.0-7ubuntu1) ... 1336s Selecting previously unselected package build-essential. 1336s Preparing to unpack .../023-build-essential_12.10ubuntu1_s390x.deb ... 1336s Unpacking build-essential (12.10ubuntu1) ... 1336s Selecting previously unselected package dctrl-tools. 1336s Preparing to unpack .../024-dctrl-tools_2.24-3build3_s390x.deb ... 1336s Unpacking dctrl-tools (2.24-3build3) ... 1336s Selecting previously unselected package fontconfig. 1336s Preparing to unpack .../025-fontconfig_2.15.0-1.1ubuntu2_s390x.deb ... 1336s Unpacking fontconfig (2.15.0-1.1ubuntu2) ... 1336s Selecting previously unselected package fonts-glyphicons-halflings. 1336s Preparing to unpack .../026-fonts-glyphicons-halflings_1.009~3.4.1+dfsg-3_all.deb ... 1336s Unpacking fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 1337s Selecting previously unselected package fonts-mathjax. 1337s Preparing to unpack .../027-fonts-mathjax_2.7.9+dfsg-1_all.deb ... 1337s Unpacking fonts-mathjax (2.7.9+dfsg-1) ... 1337s Selecting previously unselected package libgfortran5:s390x. 1337s Preparing to unpack .../028-libgfortran5_14.1.0-1ubuntu1_s390x.deb ... 1337s Unpacking libgfortran5:s390x (14.1.0-1ubuntu1) ... 1337s Selecting previously unselected package libgfortran-13-dev:s390x. 1337s Preparing to unpack .../029-libgfortran-13-dev_13.2.0-23ubuntu4_s390x.deb ... 1337s Unpacking libgfortran-13-dev:s390x (13.2.0-23ubuntu4) ... 1337s Selecting previously unselected package gfortran-13-s390x-linux-gnu. 1337s Preparing to unpack .../030-gfortran-13-s390x-linux-gnu_13.2.0-23ubuntu4_s390x.deb ... 1337s Unpacking gfortran-13-s390x-linux-gnu (13.2.0-23ubuntu4) ... 1337s Selecting previously unselected package gfortran-13. 1337s Preparing to unpack .../031-gfortran-13_13.2.0-23ubuntu4_s390x.deb ... 1337s Unpacking gfortran-13 (13.2.0-23ubuntu4) ... 1337s Selecting previously unselected package gfortran-s390x-linux-gnu. 1337s Preparing to unpack .../032-gfortran-s390x-linux-gnu_4%3a13.2.0-7ubuntu1_s390x.deb ... 1337s Unpacking gfortran-s390x-linux-gnu (4:13.2.0-7ubuntu1) ... 1337s Selecting previously unselected package gfortran. 1337s Preparing to unpack .../033-gfortran_4%3a13.2.0-7ubuntu1_s390x.deb ... 1337s Unpacking gfortran (4:13.2.0-7ubuntu1) ... 1337s Selecting previously unselected package icu-devtools. 1337s Preparing to unpack .../034-icu-devtools_74.2-1ubuntu3_s390x.deb ... 1337s Unpacking icu-devtools (74.2-1ubuntu3) ... 1337s Selecting previously unselected package libblas3:s390x. 1337s Preparing to unpack .../035-libblas3_3.12.0-3build1_s390x.deb ... 1337s Unpacking libblas3:s390x (3.12.0-3build1) ... 1337s Selecting previously unselected package libblas-dev:s390x. 1337s Preparing to unpack .../036-libblas-dev_3.12.0-3build1_s390x.deb ... 1337s Unpacking libblas-dev:s390x (3.12.0-3build1) ... 1337s Selecting previously unselected package libbz2-dev:s390x. 1337s Preparing to unpack .../037-libbz2-dev_1.0.8-5.1_s390x.deb ... 1337s Unpacking libbz2-dev:s390x (1.0.8-5.1) ... 1337s Selecting previously unselected package libpixman-1-0:s390x. 1337s Preparing to unpack .../038-libpixman-1-0_0.42.2-1build1_s390x.deb ... 1337s Unpacking libpixman-1-0:s390x (0.42.2-1build1) ... 1337s Selecting previously unselected package libxcb-render0:s390x. 1337s Preparing to unpack .../039-libxcb-render0_1.17.0-2_s390x.deb ... 1337s Unpacking libxcb-render0:s390x (1.17.0-2) ... 1337s Selecting previously unselected package libxcb-shm0:s390x. 1337s Preparing to unpack .../040-libxcb-shm0_1.17.0-2_s390x.deb ... 1337s Unpacking libxcb-shm0:s390x (1.17.0-2) ... 1337s Selecting previously unselected package libxrender1:s390x. 1337s Preparing to unpack .../041-libxrender1_1%3a0.9.10-1.1build1_s390x.deb ... 1337s Unpacking libxrender1:s390x (1:0.9.10-1.1build1) ... 1338s Selecting previously unselected package libcairo2:s390x. 1338s Preparing to unpack .../042-libcairo2_1.18.0-3build1_s390x.deb ... 1338s Unpacking libcairo2:s390x (1.18.0-3build1) ... 1338s Selecting previously unselected package libdatrie1:s390x. 1338s Preparing to unpack .../043-libdatrie1_0.2.13-3build1_s390x.deb ... 1338s Unpacking libdatrie1:s390x (0.2.13-3build1) ... 1338s Selecting previously unselected package libdeflate-dev:s390x. 1338s Preparing to unpack .../044-libdeflate-dev_1.20-1_s390x.deb ... 1338s Unpacking libdeflate-dev:s390x (1.20-1) ... 1338s Selecting previously unselected package libgraphite2-3:s390x. 1338s Preparing to unpack .../045-libgraphite2-3_1.3.14-2build1_s390x.deb ... 1338s Unpacking libgraphite2-3:s390x (1.3.14-2build1) ... 1338s Selecting previously unselected package libharfbuzz0b:s390x. 1338s Preparing to unpack .../046-libharfbuzz0b_8.3.0-2build2_s390x.deb ... 1338s Unpacking libharfbuzz0b:s390x (8.3.0-2build2) ... 1338s Selecting previously unselected package x11-common. 1338s Preparing to unpack .../047-x11-common_1%3a7.7+23ubuntu3_all.deb ... 1338s Unpacking x11-common (1:7.7+23ubuntu3) ... 1338s Selecting previously unselected package libice6:s390x. 1338s Preparing to unpack .../048-libice6_2%3a1.0.10-1build3_s390x.deb ... 1338s Unpacking libice6:s390x (2:1.0.10-1build3) ... 1338s Selecting previously unselected package libicu-dev:s390x. 1338s Preparing to unpack .../049-libicu-dev_74.2-1ubuntu3_s390x.deb ... 1338s Unpacking libicu-dev:s390x (74.2-1ubuntu3) ... 1338s Selecting previously unselected package libjpeg-turbo8-dev:s390x. 1338s Preparing to unpack .../050-libjpeg-turbo8-dev_2.1.5-2ubuntu2_s390x.deb ... 1338s Unpacking libjpeg-turbo8-dev:s390x (2.1.5-2ubuntu2) ... 1338s Selecting previously unselected package libjpeg8-dev:s390x. 1338s Preparing to unpack .../051-libjpeg8-dev_8c-2ubuntu11_s390x.deb ... 1338s Unpacking libjpeg8-dev:s390x (8c-2ubuntu11) ... 1338s Selecting previously unselected package libjpeg-dev:s390x. 1338s Preparing to unpack .../052-libjpeg-dev_8c-2ubuntu11_s390x.deb ... 1338s Unpacking libjpeg-dev:s390x (8c-2ubuntu11) ... 1338s Selecting previously unselected package libjs-bootstrap. 1338s Preparing to unpack .../053-libjs-bootstrap_3.4.1+dfsg-3_all.deb ... 1338s Unpacking libjs-bootstrap (3.4.1+dfsg-3) ... 1338s Selecting previously unselected package libjs-highlight.js. 1338s Preparing to unpack .../054-libjs-highlight.js_9.18.5+dfsg1-2_all.deb ... 1338s Unpacking libjs-highlight.js (9.18.5+dfsg1-2) ... 1338s Selecting previously unselected package libjs-jquery. 1338s Preparing to unpack .../055-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 1338s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 1338s Selecting previously unselected package libjs-jquery-datatables. 1338s Preparing to unpack .../056-libjs-jquery-datatables_1.11.5+dfsg-2_all.deb ... 1338s Unpacking libjs-jquery-datatables (1.11.5+dfsg-2) ... 1338s Selecting previously unselected package liblapack3:s390x. 1338s Preparing to unpack .../057-liblapack3_3.12.0-3build1_s390x.deb ... 1338s Unpacking liblapack3:s390x (3.12.0-3build1) ... 1338s Selecting previously unselected package liblapack-dev:s390x. 1338s Preparing to unpack .../058-liblapack-dev_3.12.0-3build1_s390x.deb ... 1338s Unpacking liblapack-dev:s390x (3.12.0-3build1) ... 1339s Selecting previously unselected package libncurses-dev:s390x. 1339s Preparing to unpack .../059-libncurses-dev_6.4+20240113-1ubuntu2_s390x.deb ... 1339s Unpacking libncurses-dev:s390x (6.4+20240113-1ubuntu2) ... 1339s Selecting previously unselected package libthai-data. 1339s Preparing to unpack .../060-libthai-data_0.1.29-2build1_all.deb ... 1339s Unpacking libthai-data (0.1.29-2build1) ... 1339s Selecting previously unselected package libthai0:s390x. 1339s Preparing to unpack .../061-libthai0_0.1.29-2build1_s390x.deb ... 1339s Unpacking libthai0:s390x (0.1.29-2build1) ... 1339s Selecting previously unselected package libpango-1.0-0:s390x. 1339s Preparing to unpack .../062-libpango-1.0-0_1.52.2+ds-1_s390x.deb ... 1339s Unpacking libpango-1.0-0:s390x (1.52.2+ds-1) ... 1339s Selecting previously unselected package libpangoft2-1.0-0:s390x. 1339s Preparing to unpack .../063-libpangoft2-1.0-0_1.52.2+ds-1_s390x.deb ... 1339s Unpacking libpangoft2-1.0-0:s390x (1.52.2+ds-1) ... 1339s Selecting previously unselected package libpangocairo-1.0-0:s390x. 1339s Preparing to unpack .../064-libpangocairo-1.0-0_1.52.2+ds-1_s390x.deb ... 1339s Unpacking libpangocairo-1.0-0:s390x (1.52.2+ds-1) ... 1339s Selecting previously unselected package libpaper1:s390x. 1339s Preparing to unpack .../065-libpaper1_1.1.29build1_s390x.deb ... 1339s Unpacking libpaper1:s390x (1.1.29build1) ... 1339s Selecting previously unselected package libpaper-utils. 1339s Preparing to unpack .../066-libpaper-utils_1.1.29build1_s390x.deb ... 1339s Unpacking libpaper-utils (1.1.29build1) ... 1339s Selecting previously unselected package libpcre2-16-0:s390x. 1339s Preparing to unpack .../067-libpcre2-16-0_10.42-4ubuntu2_s390x.deb ... 1339s Unpacking libpcre2-16-0:s390x (10.42-4ubuntu2) ... 1339s Selecting previously unselected package libpcre2-32-0:s390x. 1339s Preparing to unpack .../068-libpcre2-32-0_10.42-4ubuntu2_s390x.deb ... 1339s Unpacking libpcre2-32-0:s390x (10.42-4ubuntu2) ... 1339s Selecting previously unselected package libpcre2-posix3:s390x. 1339s Preparing to unpack .../069-libpcre2-posix3_10.42-4ubuntu2_s390x.deb ... 1339s Unpacking libpcre2-posix3:s390x (10.42-4ubuntu2) ... 1339s Selecting previously unselected package libpcre2-dev:s390x. 1339s Preparing to unpack .../070-libpcre2-dev_10.42-4ubuntu2_s390x.deb ... 1339s Unpacking libpcre2-dev:s390x (10.42-4ubuntu2) ... 1339s Selecting previously unselected package libpkgconf3:s390x. 1339s Preparing to unpack .../071-libpkgconf3_1.8.1-2build1_s390x.deb ... 1339s Unpacking libpkgconf3:s390x (1.8.1-2build1) ... 1339s Selecting previously unselected package zlib1g-dev:s390x. 1339s Preparing to unpack .../072-zlib1g-dev_1%3a1.3.dfsg-3.1ubuntu2_s390x.deb ... 1339s Unpacking zlib1g-dev:s390x (1:1.3.dfsg-3.1ubuntu2) ... 1339s Selecting previously unselected package libpng-dev:s390x. 1339s Preparing to unpack .../073-libpng-dev_1.6.43-5build1_s390x.deb ... 1339s Unpacking libpng-dev:s390x (1.6.43-5build1) ... 1339s Selecting previously unselected package libreadline-dev:s390x. 1339s Preparing to unpack .../074-libreadline-dev_8.2-4build1_s390x.deb ... 1339s Unpacking libreadline-dev:s390x (8.2-4build1) ... 1339s Selecting previously unselected package libsm6:s390x. 1339s Preparing to unpack .../075-libsm6_2%3a1.2.3-1build3_s390x.deb ... 1339s Unpacking libsm6:s390x (2:1.2.3-1build3) ... 1339s Selecting previously unselected package libtcl8.6:s390x. 1339s Preparing to unpack .../076-libtcl8.6_8.6.14+dfsg-1build1_s390x.deb ... 1339s Unpacking libtcl8.6:s390x (8.6.14+dfsg-1build1) ... 1339s Selecting previously unselected package libxft2:s390x. 1339s Preparing to unpack .../077-libxft2_2.3.6-1build1_s390x.deb ... 1339s Unpacking libxft2:s390x (2.3.6-1build1) ... 1339s Selecting previously unselected package libxss1:s390x. 1339s Preparing to unpack .../078-libxss1_1%3a1.2.3-1build3_s390x.deb ... 1339s Unpacking libxss1:s390x (1:1.2.3-1build3) ... 1339s Selecting previously unselected package libtk8.6:s390x. 1339s Preparing to unpack .../079-libtk8.6_8.6.14-1build1_s390x.deb ... 1339s Unpacking libtk8.6:s390x (8.6.14-1build1) ... 1339s Selecting previously unselected package libxt6t64:s390x. 1339s Preparing to unpack .../080-libxt6t64_1%3a1.2.1-1.2build1_s390x.deb ... 1339s Unpacking libxt6t64:s390x (1:1.2.1-1.2build1) ... 1339s Selecting previously unselected package node-normalize.css. 1339s Preparing to unpack .../081-node-normalize.css_8.0.1-5_all.deb ... 1339s Unpacking node-normalize.css (8.0.1-5) ... 1339s Selecting previously unselected package zip. 1339s Preparing to unpack .../082-zip_3.0-13build1_s390x.deb ... 1339s Unpacking zip (3.0-13build1) ... 1339s Selecting previously unselected package unzip. 1339s Preparing to unpack .../083-unzip_6.0-28ubuntu4_s390x.deb ... 1339s Unpacking unzip (6.0-28ubuntu4) ... 1339s Selecting previously unselected package xdg-utils. 1339s Preparing to unpack .../084-xdg-utils_1.1.3-4.1ubuntu3_all.deb ... 1339s Unpacking xdg-utils (1.1.3-4.1ubuntu3) ... 1339s Selecting previously unselected package r-base-core. 1339s Preparing to unpack .../085-r-base-core_4.4.0-2_s390x.deb ... 1339s Unpacking r-base-core (4.4.0-2) ... 1340s Selecting previously unselected package liblzma-dev:s390x. 1340s Preparing to unpack .../086-liblzma-dev_5.6.1+really5.4.5-1_s390x.deb ... 1340s Unpacking liblzma-dev:s390x (5.6.1+really5.4.5-1) ... 1340s Selecting previously unselected package pkgconf-bin. 1340s Preparing to unpack .../087-pkgconf-bin_1.8.1-2build1_s390x.deb ... 1340s Unpacking pkgconf-bin (1.8.1-2build1) ... 1340s Selecting previously unselected package pkgconf:s390x. 1340s Preparing to unpack .../088-pkgconf_1.8.1-2build1_s390x.deb ... 1340s Unpacking pkgconf:s390x (1.8.1-2build1) ... 1340s Selecting previously unselected package libtirpc-dev:s390x. 1340s Preparing to unpack .../089-libtirpc-dev_1.3.4+ds-1.3_s390x.deb ... 1340s Unpacking libtirpc-dev:s390x (1.3.4+ds-1.3) ... 1340s Selecting previously unselected package r-base-dev. 1340s Preparing to unpack .../090-r-base-dev_4.4.0-2_all.deb ... 1340s Unpacking r-base-dev (4.4.0-2) ... 1340s Selecting previously unselected package pkg-r-autopkgtest. 1340s Preparing to unpack .../091-pkg-r-autopkgtest_20231212ubuntu1_all.deb ... 1340s Unpacking pkg-r-autopkgtest (20231212ubuntu1) ... 1340s Selecting previously unselected package r-cran-base64enc. 1340s Preparing to unpack .../092-r-cran-base64enc_0.1-3-3_s390x.deb ... 1340s Unpacking r-cran-base64enc (0.1-3-3) ... 1340s Selecting previously unselected package r-cran-cli. 1340s Preparing to unpack .../093-r-cran-cli_3.6.2-1_s390x.deb ... 1340s Unpacking r-cran-cli (3.6.2-1) ... 1340s Selecting previously unselected package r-cran-colorspace. 1340s Preparing to unpack .../094-r-cran-colorspace_2.1-0+dfsg-1_s390x.deb ... 1340s Unpacking r-cran-colorspace (2.1-0+dfsg-1) ... 1340s Selecting previously unselected package r-cran-commonmark. 1340s Preparing to unpack .../095-r-cran-commonmark_1.9.1-1_s390x.deb ... 1340s Unpacking r-cran-commonmark (1.9.1-1) ... 1340s Selecting previously unselected package r-cran-evaluate. 1340s Preparing to unpack .../096-r-cran-evaluate_0.23-1_all.deb ... 1340s Unpacking r-cran-evaluate (0.23-1) ... 1340s Selecting previously unselected package r-cran-fansi. 1340s Preparing to unpack .../097-r-cran-fansi_1.0.5-1_s390x.deb ... 1340s Unpacking r-cran-fansi (1.0.5-1) ... 1340s Selecting previously unselected package r-cran-farver. 1340s Preparing to unpack .../098-r-cran-farver_2.1.1-2_s390x.deb ... 1340s Unpacking r-cran-farver (2.1.1-2) ... 1340s Selecting previously unselected package r-cran-glue. 1340s Preparing to unpack .../099-r-cran-glue_1.7.0-1_s390x.deb ... 1340s Unpacking r-cran-glue (1.7.0-1) ... 1340s Selecting previously unselected package r-cran-rlang. 1340s Preparing to unpack .../100-r-cran-rlang_1.1.3-1_s390x.deb ... 1340s Unpacking r-cran-rlang (1.1.3-1) ... 1340s Selecting previously unselected package r-cran-lifecycle. 1340s Preparing to unpack .../101-r-cran-lifecycle_1.0.4+dfsg-1_all.deb ... 1340s Unpacking r-cran-lifecycle (1.0.4+dfsg-1) ... 1340s Selecting previously unselected package r-cran-gtable. 1340s Preparing to unpack .../102-r-cran-gtable_0.3.4+dfsg-1_all.deb ... 1340s Unpacking r-cran-gtable (0.3.4+dfsg-1) ... 1340s Selecting previously unselected package r-cran-isoband. 1340s Preparing to unpack .../103-r-cran-isoband_0.2.7-1_s390x.deb ... 1340s Unpacking r-cran-isoband (0.2.7-1) ... 1341s Selecting previously unselected package r-cran-mass. 1341s Preparing to unpack .../104-r-cran-mass_7.3-60.2-1_s390x.deb ... 1341s Unpacking r-cran-mass (7.3-60.2-1) ... 1341s Selecting previously unselected package r-cran-lattice. 1341s Preparing to unpack .../105-r-cran-lattice_0.22-6-1_s390x.deb ... 1341s Unpacking r-cran-lattice (0.22-6-1) ... 1341s Selecting previously unselected package r-cran-nlme. 1341s Preparing to unpack .../106-r-cran-nlme_3.1.164-1build1_s390x.deb ... 1341s Unpacking r-cran-nlme (3.1.164-1build1) ... 1341s Selecting previously unselected package r-cran-matrix. 1341s Preparing to unpack .../107-r-cran-matrix_1.6-5-1_s390x.deb ... 1341s Unpacking r-cran-matrix (1.6-5-1) ... 1341s Selecting previously unselected package r-cran-mgcv. 1341s Preparing to unpack .../108-r-cran-mgcv_1.9-1-1_s390x.deb ... 1341s Unpacking r-cran-mgcv (1.9-1-1) ... 1341s Selecting previously unselected package r-cran-labeling. 1341s Preparing to unpack .../109-r-cran-labeling_0.4.3-1_all.deb ... 1341s Unpacking r-cran-labeling (0.4.3-1) ... 1341s Selecting previously unselected package r-cran-munsell. 1341s Preparing to unpack .../110-r-cran-munsell_0.5.0-2build1_all.deb ... 1341s Unpacking r-cran-munsell (0.5.0-2build1) ... 1341s Selecting previously unselected package r-cran-r6. 1341s Preparing to unpack .../111-r-cran-r6_2.5.1-1_all.deb ... 1341s Unpacking r-cran-r6 (2.5.1-1) ... 1341s Selecting previously unselected package r-cran-rcolorbrewer. 1341s Preparing to unpack .../112-r-cran-rcolorbrewer_1.1-3-1build1_all.deb ... 1341s Unpacking r-cran-rcolorbrewer (1.1-3-1build1) ... 1341s Selecting previously unselected package r-cran-viridislite. 1341s Preparing to unpack .../113-r-cran-viridislite_0.4.2-2_all.deb ... 1341s Unpacking r-cran-viridislite (0.4.2-2) ... 1341s Selecting previously unselected package r-cran-scales. 1341s Preparing to unpack .../114-r-cran-scales_1.3.0-1_all.deb ... 1341s Unpacking r-cran-scales (1.3.0-1) ... 1341s Selecting previously unselected package r-cran-magrittr. 1341s Preparing to unpack .../115-r-cran-magrittr_2.0.3-1_s390x.deb ... 1341s Unpacking r-cran-magrittr (2.0.3-1) ... 1341s Selecting previously unselected package r-cran-utf8. 1341s Preparing to unpack .../116-r-cran-utf8_1.2.4-1_s390x.deb ... 1341s Unpacking r-cran-utf8 (1.2.4-1) ... 1341s Selecting previously unselected package r-cran-vctrs. 1341s Preparing to unpack .../117-r-cran-vctrs_0.6.5-1_s390x.deb ... 1341s Unpacking r-cran-vctrs (0.6.5-1) ... 1341s Selecting previously unselected package r-cran-pillar. 1341s Preparing to unpack .../118-r-cran-pillar_1.9.0+dfsg-1_all.deb ... 1341s Unpacking r-cran-pillar (1.9.0+dfsg-1) ... 1341s Selecting previously unselected package r-cran-pkgconfig. 1341s Preparing to unpack .../119-r-cran-pkgconfig_2.0.3-2build1_all.deb ... 1341s Unpacking r-cran-pkgconfig (2.0.3-2build1) ... 1341s Selecting previously unselected package r-cran-tibble. 1341s Preparing to unpack .../120-r-cran-tibble_3.2.1+dfsg-2_s390x.deb ... 1341s Unpacking r-cran-tibble (3.2.1+dfsg-2) ... 1341s Selecting previously unselected package r-cran-withr. 1341s Preparing to unpack .../121-r-cran-withr_2.5.0-1_all.deb ... 1341s Unpacking r-cran-withr (2.5.0-1) ... 1341s Selecting previously unselected package r-cran-ggplot2. 1341s Preparing to unpack .../122-r-cran-ggplot2_3.5.1+dfsg-1_all.deb ... 1341s Unpacking r-cran-ggplot2 (3.5.1+dfsg-1) ... 1341s Selecting previously unselected package r-cran-xfun. 1341s Preparing to unpack .../123-r-cran-xfun_0.44+dfsg-1_s390x.deb ... 1341s Unpacking r-cran-xfun (0.44+dfsg-1) ... 1341s Selecting previously unselected package r-cran-highr. 1341s Preparing to unpack .../124-r-cran-highr_0.10+dfsg-2_all.deb ... 1341s Unpacking r-cran-highr (0.10+dfsg-2) ... 1341s Selecting previously unselected package r-cran-yaml. 1341s Preparing to unpack .../125-r-cran-yaml_2.3.8-2_s390x.deb ... 1341s Unpacking r-cran-yaml (2.3.8-2) ... 1341s Selecting previously unselected package libjs-mathjax. 1341s Preparing to unpack .../126-libjs-mathjax_2.7.9+dfsg-1_all.deb ... 1341s Unpacking libjs-mathjax (2.7.9+dfsg-1) ... 1343s Selecting previously unselected package r-cran-knitr. 1343s Preparing to unpack .../127-r-cran-knitr_1.46+dfsg-1_all.deb ... 1343s Unpacking r-cran-knitr (1.46+dfsg-1) ... 1343s Selecting previously unselected package r-cran-markdown. 1343s Preparing to unpack .../128-r-cran-markdown_1.12+dfsg-2_all.deb ... 1343s Unpacking r-cran-markdown (1.12+dfsg-2) ... 1343s Selecting previously unselected package r-cran-matrixstats. 1343s Preparing to unpack .../129-r-cran-matrixstats_1.2.0-1_s390x.deb ... 1343s Unpacking r-cran-matrixstats (1.2.0-1) ... 1343s Selecting previously unselected package autopkgtest-satdep. 1343s Preparing to unpack .../130-2-autopkgtest-satdep.deb ... 1343s Unpacking autopkgtest-satdep (0) ... 1343s Setting up libgraphite2-3:s390x (1.3.14-2build1) ... 1343s Setting up libpixman-1-0:s390x (0.42.2-1build1) ... 1343s Setting up libpaper1:s390x (1.1.29build1) ... 1343s 1343s Creating config file /etc/papersize with new version 1343s Setting up fontconfig (2.15.0-1.1ubuntu2) ... 1345s Regenerating fonts cache... done. 1345s Setting up libjpeg-turbo8-dev:s390x (2.1.5-2ubuntu2) ... 1345s Setting up libncurses-dev:s390x (6.4+20240113-1ubuntu2) ... 1345s Setting up fonts-mathjax (2.7.9+dfsg-1) ... 1345s Setting up libjs-mathjax (2.7.9+dfsg-1) ... 1345s Setting up libxrender1:s390x (1:0.9.10-1.1build1) ... 1345s Setting up libdatrie1:s390x (0.2.13-3build1) ... 1345s Setting up libxcb-render0:s390x (1.17.0-2) ... 1345s Setting up fonts-glyphicons-halflings (1.009~3.4.1+dfsg-3) ... 1345s Setting up unzip (6.0-28ubuntu4) ... 1345s Setting up x11-common (1:7.7+23ubuntu3) ... 1346s Setting up libxcb-shm0:s390x (1.17.0-2) ... 1346s Setting up libpaper-utils (1.1.29build1) ... 1346s Setting up libreadline-dev:s390x (8.2-4build1) ... 1346s Setting up libgomp1:s390x (14.1.0-1ubuntu1) ... 1346s Setting up libcairo2:s390x (1.18.0-3build1) ... 1346s Setting up libpcre2-16-0:s390x (10.42-4ubuntu2) ... 1346s Setting up zip (3.0-13build1) ... 1346s Setting up libpcre2-32-0:s390x (10.42-4ubuntu2) ... 1346s Setting up libblas3:s390x (3.12.0-3build1) ... 1346s update-alternatives: using /usr/lib/s390x-linux-gnu/blas/libblas.so.3 to provide /usr/lib/s390x-linux-gnu/libblas.so.3 (libblas.so.3-s390x-linux-gnu) in auto mode 1346s Setting up libtirpc-dev:s390x (1.3.4+ds-1.3) ... 1346s Setting up libpkgconf3:s390x (1.8.1-2build1) ... 1346s Setting up gcc-13-base:s390x (13.2.0-23ubuntu4) ... 1346s Setting up libmpc3:s390x (1.3.1-1build1) ... 1346s Setting up libatomic1:s390x (14.1.0-1ubuntu1) ... 1346s Setting up libtcl8.6:s390x (8.6.14+dfsg-1build1) ... 1346s Setting up icu-devtools (74.2-1ubuntu3) ... 1346s Setting up pkgconf-bin (1.8.1-2build1) ... 1346s Setting up libgfortran5:s390x (14.1.0-1ubuntu1) ... 1346s Setting up liblzma-dev:s390x (5.6.1+really5.4.5-1) ... 1346s Setting up libubsan1:s390x (14.1.0-1ubuntu1) ... 1346s Setting up zlib1g-dev:s390x (1:1.3.dfsg-3.1ubuntu2) ... 1346s Setting up libpcre2-posix3:s390x (10.42-4ubuntu2) ... 1346s Setting up libjs-highlight.js (9.18.5+dfsg1-2) ... 1346s Setting up libasan8:s390x (14.1.0-1ubuntu1) ... 1346s Setting up libharfbuzz0b:s390x (8.3.0-2build2) ... 1346s Setting up libthai-data (0.1.29-2build1) ... 1346s Setting up libxss1:s390x (1:1.2.3-1build3) ... 1346s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 1346s Setting up libjpeg8-dev:s390x (8c-2ubuntu11) ... 1346s Setting up libisl23:s390x (0.26-3build1) ... 1346s Setting up libdeflate-dev:s390x (1.20-1) ... 1346s Setting up node-normalize.css (8.0.1-5) ... 1346s Setting up libicu-dev:s390x (74.2-1ubuntu3) ... 1346s Setting up xdg-utils (1.1.3-4.1ubuntu3) ... 1346s update-alternatives: using /usr/bin/xdg-open to provide /usr/bin/open (open) in auto mode 1346s Setting up libcc1-0:s390x (14.1.0-1ubuntu1) ... 1346s Setting up libblas-dev:s390x (3.12.0-3build1) ... 1346s update-alternatives: using /usr/lib/s390x-linux-gnu/blas/libblas.so to provide /usr/lib/s390x-linux-gnu/libblas.so (libblas.so-s390x-linux-gnu) in auto mode 1346s Setting up dctrl-tools (2.24-3build3) ... 1346s Setting up libjs-bootstrap (3.4.1+dfsg-3) ... 1346s Setting up libitm1:s390x (14.1.0-1ubuntu1) ... 1346s Setting up libbz2-dev:s390x (1.0.8-5.1) ... 1346s Setting up libice6:s390x (2:1.0.10-1build3) ... 1346s Setting up liblapack3:s390x (3.12.0-3build1) ... 1346s update-alternatives: using /usr/lib/s390x-linux-gnu/lapack/liblapack.so.3 to provide /usr/lib/s390x-linux-gnu/liblapack.so.3 (liblapack.so.3-s390x-linux-gnu) in auto mode 1346s Setting up libxft2:s390x (2.3.6-1build1) ... 1346s Setting up libpcre2-dev:s390x (10.42-4ubuntu2) ... 1346s Setting up libtk8.6:s390x (8.6.14-1build1) ... 1346s Setting up libpng-dev:s390x (1.6.43-5build1) ... 1346s Setting up libjpeg-dev:s390x (8c-2ubuntu11) ... 1346s Setting up libjs-jquery-datatables (1.11.5+dfsg-2) ... 1346s Setting up pkgconf:s390x (1.8.1-2build1) ... 1346s Setting up libthai0:s390x (0.1.29-2build1) ... 1346s Setting up cpp-13-s390x-linux-gnu (13.2.0-23ubuntu4) ... 1346s Setting up liblapack-dev:s390x (3.12.0-3build1) ... 1346s update-alternatives: using /usr/lib/s390x-linux-gnu/lapack/liblapack.so to provide /usr/lib/s390x-linux-gnu/liblapack.so (liblapack.so-s390x-linux-gnu) in auto mode 1346s Setting up libgcc-13-dev:s390x (13.2.0-23ubuntu4) ... 1346s Setting up libgfortran-13-dev:s390x (13.2.0-23ubuntu4) ... 1346s Setting up libsm6:s390x (2:1.2.3-1build3) ... 1346s Setting up libstdc++-13-dev:s390x (13.2.0-23ubuntu4) ... 1346s Setting up cpp-13 (13.2.0-23ubuntu4) ... 1346s Setting up cpp-s390x-linux-gnu (4:13.2.0-7ubuntu1) ... 1346s Setting up libpango-1.0-0:s390x (1.52.2+ds-1) ... 1346s Setting up gcc-13-s390x-linux-gnu (13.2.0-23ubuntu4) ... 1346s Setting up gcc-s390x-linux-gnu (4:13.2.0-7ubuntu1) ... 1346s Setting up g++-13-s390x-linux-gnu (13.2.0-23ubuntu4) ... 1346s Setting up libxt6t64:s390x (1:1.2.1-1.2build1) ... 1346s Setting up gcc-13 (13.2.0-23ubuntu4) ... 1346s Setting up cpp (4:13.2.0-7ubuntu1) ... 1346s Setting up gfortran-13-s390x-linux-gnu (13.2.0-23ubuntu4) ... 1346s Setting up libpangoft2-1.0-0:s390x (1.52.2+ds-1) ... 1346s Setting up libpangocairo-1.0-0:s390x (1.52.2+ds-1) ... 1346s Setting up g++-13 (13.2.0-23ubuntu4) ... 1346s Setting up gfortran-s390x-linux-gnu (4:13.2.0-7ubuntu1) ... 1346s Setting up g++-s390x-linux-gnu (4:13.2.0-7ubuntu1) ... 1346s Setting up gcc (4:13.2.0-7ubuntu1) ... 1346s Setting up gfortran-13 (13.2.0-23ubuntu4) ... 1346s Setting up r-base-core (4.4.0-2) ... 1346s 1346s Creating config file /etc/R/Renviron with new version 1346s Setting up r-cran-labeling (0.4.3-1) ... 1346s Setting up r-cran-lattice (0.22-6-1) ... 1346s Setting up r-cran-nlme (3.1.164-1build1) ... 1346s Setting up r-cran-farver (2.1.1-2) ... 1346s Setting up g++ (4:13.2.0-7ubuntu1) ... 1346s update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode 1346s Setting up r-cran-viridislite (0.4.2-2) ... 1346s Setting up build-essential (12.10ubuntu1) ... 1346s Setting up r-cran-commonmark (1.9.1-1) ... 1346s Setting up r-cran-r6 (2.5.1-1) ... 1346s Setting up r-cran-magrittr (2.0.3-1) ... 1346s Setting up r-cran-rlang (1.1.3-1) ... 1346s Setting up r-cran-matrixstats (1.2.0-1) ... 1346s Setting up r-cran-xfun (0.44+dfsg-1) ... 1346s Setting up r-cran-withr (2.5.0-1) ... 1346s Setting up r-cran-base64enc (0.1-3-3) ... 1346s Setting up r-cran-yaml (2.3.8-2) ... 1346s Setting up r-cran-evaluate (0.23-1) ... 1346s Setting up r-cran-highr (0.10+dfsg-2) ... 1346s Setting up r-cran-fansi (1.0.5-1) ... 1346s Setting up r-cran-mass (7.3-60.2-1) ... 1346s Setting up r-cran-glue (1.7.0-1) ... 1346s Setting up r-cran-cli (3.6.2-1) ... 1346s Setting up gfortran (4:13.2.0-7ubuntu1) ... 1346s update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f95 (f95) in auto mode 1346s update-alternatives: warning: skip creation of /usr/share/man/man1/f95.1.gz because associated file /usr/share/man/man1/gfortran.1.gz (of link group f95) doesn't exist 1346s update-alternatives: using /usr/bin/gfortran to provide /usr/bin/f77 (f77) in auto mode 1346s update-alternatives: warning: skip creation of /usr/share/man/man1/f77.1.gz because associated file /usr/share/man/man1/gfortran.1.gz (of link group f77) doesn't exist 1346s Setting up r-cran-lifecycle (1.0.4+dfsg-1) ... 1346s Setting up r-cran-pkgconfig (2.0.3-2build1) ... 1346s Setting up r-cran-utf8 (1.2.4-1) ... 1346s Setting up r-cran-colorspace (2.1-0+dfsg-1) ... 1346s Setting up r-cran-markdown (1.12+dfsg-2) ... 1346s Setting up r-cran-rcolorbrewer (1.1-3-1build1) ... 1346s Setting up r-cran-isoband (0.2.7-1) ... 1346s Setting up r-cran-gtable (0.3.4+dfsg-1) ... 1346s Setting up r-cran-matrix (1.6-5-1) ... 1346s Setting up r-cran-knitr (1.46+dfsg-1) ... 1346s Setting up r-cran-mgcv (1.9-1-1) ... 1346s Setting up r-cran-vctrs (0.6.5-1) ... 1346s Setting up r-cran-pillar (1.9.0+dfsg-1) ... 1346s Setting up r-base-dev (4.4.0-2) ... 1346s Setting up r-cran-munsell (0.5.0-2build1) ... 1346s Setting up r-cran-tibble (3.2.1+dfsg-2) ... 1346s Setting up r-cran-scales (1.3.0-1) ... 1346s Setting up pkg-r-autopkgtest (20231212ubuntu1) ... 1346s Setting up r-cran-ggplot2 (3.5.1+dfsg-1) ... 1346s Setting up autopkgtest-satdep (0) ... 1346s Processing triggers for man-db (2.12.1-1) ... 1348s Processing triggers for install-info (7.1-3build2) ... 1348s Processing triggers for libc-bin (2.39-0ubuntu8.1) ... 1365s (Reading database ... 67337 files and directories currently installed.) 1365s Removing autopkgtest-satdep (0) ... 1369s autopkgtest [10:15:06]: test pkg-r-autopkgtest: /usr/share/dh-r/pkg-r-autopkgtest 1369s autopkgtest [10:15:06]: test pkg-r-autopkgtest: [----------------------- 1369s Test: Try to load the R library matrixStats 1369s 1369s R version 4.4.0 (2024-04-24) -- "Puppy Cup" 1369s Copyright (C) 2024 The R Foundation for Statistical Computing 1369s Platform: s390x-ibm-linux-gnu 1369s 1369s R is free software and comes with ABSOLUTELY NO WARRANTY. 1369s You are welcome to redistribute it under certain conditions. 1369s Type 'license()' or 'licence()' for distribution details. 1369s 1369s R is a collaborative project with many contributors. 1369s Type 'contributors()' for more information and 1369s 'citation()' on how to cite R or R packages in publications. 1369s 1369s Type 'demo()' for some demos, 'help()' for on-line help, or 1369s 'help.start()' for an HTML browser interface to help. 1369s Type 'q()' to quit R. 1369s 1369s > library('matrixStats') 1369s > 1369s > 1369s Other tests are currently unsupported! 1369s They will be progressively added. 1370s autopkgtest [10:15:07]: test pkg-r-autopkgtest: -----------------------] 1370s pkg-r-autopkgtest PASS 1370s autopkgtest [10:15:07]: test pkg-r-autopkgtest: - - - - - - - - - - results - - - - - - - - - - 1371s autopkgtest [10:15:08]: @@@@@@@@@@@@@@@@@@@@ summary 1371s run-unit-test PASS 1371s pkg-r-autopkgtest PASS 1410s Creating nova instance adt-oracular-s390x-r-cran-matrixstats-20240524-095217-juju-7f2275-prod-proposed-migration-environment-3-a099fe50-f611-4cce-b3d8-efc19362545e from image adt/ubuntu-oracular-s390x-server-20240523.img (UUID f3fa0984-6aa1-4fa9-90a8-be979b298e64)... 1410s Creating nova instance adt-oracular-s390x-r-cran-matrixstats-20240524-095217-juju-7f2275-prod-proposed-migration-environment-3-a099fe50-f611-4cce-b3d8-efc19362545e from image adt/ubuntu-oracular-s390x-server-20240523.img (UUID f3fa0984-6aa1-4fa9-90a8-be979b298e64)...