Giter VIP home page Giter VIP logo

Comments (3)

kuwisdelu avatar kuwisdelu commented on August 28, 2024 1

These should behave more as expected in version >= 1.9.8, with the exception that subsetting a matter_arr always produces an array and never a matrix.

from matter.

PeteHaitch avatar PeteHaitch commented on August 28, 2024

Another small inconsistency: the [<- method for base::array supports NULL indices but the method for matter does not:

suppressPackageStartupMessages(library(matter))

array <- array(1:8, dim = c(2, 2, 2))
matter <- matter_arr(array, dim = dim(array))

# base: Returns empty array of appropriate dimension
array[NULL, NULL, NULL]
#> <0 x 0 x 0 array of integer>
#> 
# matter: errors
matter[NULL, NULL, NULL]
#> Error in matter[NULL, NULL, NULL]: incorrect number of dimensions

# base: Returns empty array of appropriate dimension
array[NULL, NULL, 1]
#> <0 x 0 matrix>
# matter: errors
matter[NULL, NULL, 1]
#> Error in matter[NULL, NULL, 1]: incorrect number of dimensions

# base: Returns empty array of appropriate dimension
array[NULL, , NULL]
#> <0 x 2 x 0 array of integer>
#>      [,1] [,2]
# matter: errors
matter[NULL, , NULL]
#> Error in FUN(if (length(d.call) < 2L) newX[, 1] else array(newX[, 1L], : subscript out of bounds
Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                                             
#>  version  R Under development (unstable) (2017-12-12 r73903)
#>  system   x86_64, darwin15.6.0                              
#>  ui       X11                                               
#>  language (EN)                                              
#>  collate  en_AU.UTF-8                                       
#>  tz       Australia/Melbourne                               
#>  date     2017-12-27
#> Packages -----------------------------------------------------------------
#>  package      * version date       source        
#>  backports      1.1.2   2017-12-13 CRAN (R 3.5.0)
#>  base         * 3.5.0   2017-12-13 local         
#>  biglm        * 0.9-1   2013-05-16 CRAN (R 3.5.0)
#>  BiocGenerics   0.25.1  2017-12-17 Bioconductor  
#>  compiler       3.5.0   2017-12-13 local         
#>  datasets     * 3.5.0   2017-12-13 local         
#>  DBI          * 0.7     2017-06-18 CRAN (R 3.5.0)
#>  devtools       1.13.4  2017-11-09 CRAN (R 3.5.0)
#>  digest         0.6.13  2017-12-14 CRAN (R 3.5.0)
#>  evaluate       0.10.1  2017-06-24 CRAN (R 3.5.0)
#>  graphics     * 3.5.0   2017-12-13 local         
#>  grDevices    * 3.5.0   2017-12-13 local         
#>  grid           3.5.0   2017-12-13 local         
#>  htmltools      0.3.6   2017-04-28 CRAN (R 3.5.0)
#>  irlba          2.3.1   2017-10-18 CRAN (R 3.5.0)
#>  knitr          1.17    2017-08-10 CRAN (R 3.5.0)
#>  lattice        0.20-35 2017-03-25 CRAN (R 3.5.0)
#>  magrittr       1.5     2014-11-22 CRAN (R 3.5.0)
#>  Matrix         1.2-12  2017-11-20 CRAN (R 3.5.0)
#>  matter       * 1.5.4   2017-12-04 Bioconductor  
#>  memoise        1.1.0   2017-04-21 CRAN (R 3.5.0)
#>  methods      * 3.5.0   2017-12-13 local         
#>  parallel       3.5.0   2017-12-13 local         
#>  Rcpp           0.12.14 2017-11-23 CRAN (R 3.5.0)
#>  rmarkdown      1.8     2017-11-17 CRAN (R 3.5.0)
#>  rprojroot      1.3-1   2017-12-18 CRAN (R 3.5.0)
#>  stats        * 3.5.0   2017-12-13 local         
#>  stringi        1.1.6   2017-11-17 CRAN (R 3.5.0)
#>  stringr        1.2.0   2017-02-18 CRAN (R 3.5.0)
#>  tools          3.5.0   2017-12-13 local         
#>  utils        * 3.5.0   2017-12-13 local         
#>  withr          2.1.1   2017-12-19 CRAN (R 3.5.0)
#>  yaml           2.1.16  2017-12-12 CRAN (R 3.5.0)

from matter.

PeteHaitch avatar PeteHaitch commented on August 28, 2024

Sorry, another corner case: the [<- method for base::array supports integer(0) indices but the method for matter does not:

suppressPackageStartupMessages(library(matter))

array <- array(1:8, dim = c(2, 2, 2))
matter <- matter_arr(array)
# base: Returns an array of appropriate dimension
array[integer(0), integer(0), integer(0)]
#> <0 x 0 x 0 array of integer>
#> 
# matter: errors
matter[integer(0), integer(0), integer()]
#> Error in FUN(if (length(d.call) < 2L) newX[, 1] else array(newX[, 1L], : subscript out of bounds

# base: Returns an array (I don't quite understand the dimensions)
array[integer(0), 1, integer(0)]
#> <0 x 0 matrix>
# matter: errors
matter[1, 1, integer(0)]
#> Error in FUN(if (length(d.call) < 2L) newX[, 1] else array(newX[, 1L], : subscript out of bounds
Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                                             
#>  version  R Under development (unstable) (2017-12-12 r73903)
#>  system   x86_64, darwin15.6.0                              
#>  ui       X11                                               
#>  language (EN)                                              
#>  collate  en_AU.UTF-8                                       
#>  tz       Australia/Melbourne                               
#>  date     2017-12-27
#> Packages -----------------------------------------------------------------
#>  package      * version date       source        
#>  backports      1.1.2   2017-12-13 CRAN (R 3.5.0)
#>  base         * 3.5.0   2017-12-13 local         
#>  biglm        * 0.9-1   2013-05-16 CRAN (R 3.5.0)
#>  BiocGenerics   0.25.1  2017-12-17 Bioconductor  
#>  compiler       3.5.0   2017-12-13 local         
#>  datasets     * 3.5.0   2017-12-13 local         
#>  DBI          * 0.7     2017-06-18 CRAN (R 3.5.0)
#>  devtools       1.13.4  2017-11-09 CRAN (R 3.5.0)
#>  digest         0.6.13  2017-12-14 CRAN (R 3.5.0)
#>  evaluate       0.10.1  2017-06-24 CRAN (R 3.5.0)
#>  graphics     * 3.5.0   2017-12-13 local         
#>  grDevices    * 3.5.0   2017-12-13 local         
#>  grid           3.5.0   2017-12-13 local         
#>  htmltools      0.3.6   2017-04-28 CRAN (R 3.5.0)
#>  irlba          2.3.1   2017-10-18 CRAN (R 3.5.0)
#>  knitr          1.17    2017-08-10 CRAN (R 3.5.0)
#>  lattice        0.20-35 2017-03-25 CRAN (R 3.5.0)
#>  magrittr       1.5     2014-11-22 CRAN (R 3.5.0)
#>  Matrix         1.2-12  2017-11-20 CRAN (R 3.5.0)
#>  matter       * 1.5.4   2017-12-04 Bioconductor  
#>  memoise        1.1.0   2017-04-21 CRAN (R 3.5.0)
#>  methods      * 3.5.0   2017-12-13 local         
#>  parallel       3.5.0   2017-12-13 local         
#>  Rcpp           0.12.14 2017-11-23 CRAN (R 3.5.0)
#>  rmarkdown      1.8     2017-11-17 CRAN (R 3.5.0)
#>  rprojroot      1.3-1   2017-12-18 CRAN (R 3.5.0)
#>  stats        * 3.5.0   2017-12-13 local         
#>  stringi        1.1.6   2017-11-17 CRAN (R 3.5.0)
#>  stringr        1.2.0   2017-02-18 CRAN (R 3.5.0)
#>  tools          3.5.0   2017-12-13 local         
#>  utils        * 3.5.0   2017-12-13 local         
#>  withr          2.1.1   2017-12-19 CRAN (R 3.5.0)
#>  yaml           2.1.16  2017-12-12 CRAN (R 3.5.0)

from matter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.