Skip to content

unable to change dim #30

Closed
Closed

Description

@mikejiang

I am trying to adapt the in-memory-matrix code to support DelayedArray, but run into the following error when it tries to coerce 2d matrix to 3d array

> a <- array(runif(10), dim=c(2, 5))
> A <- DelayedArray(a)
> dim(a) <- c(dim(a), 1)
> a
, , 1

          [,1]      [,2]      [,3]      [,4]       [,5]
[1,] 0.8584375 0.3051332 0.5198660 0.1106134 0.87002666
[2,] 0.4446721 0.6195048 0.3658824 0.1589915 0.01943329

> dim(A) <- c(dim(A), 1)
Error in .normalize_dim_replacement_value(value, x_dim) : 
  too many dimensions supplied
> packageVersion("DelayedArray")
[1] ‘0.7.41’

Activity

  1. hpages commented on Sep 20, 2018

    @hpages
    Contributor

    Ah, perfect! DelayedArray objects didn't support this so far and I was thinking in adding it. It's on the TODO list:

    DelayedArray/TODO

    Lines 14 to 16 in 998fa6a

    - dim() setter allows dropping ineffective dimensions so should also allow
    adding ineffective dimensions e.g. if dim(A) is c(2, 10, 8) we should be
    able to do dim(A) <- c(1, 1, 2, 10, 1, 8).

    I think it should be easy. Great that you have a use case. I'll try to have this ready today or tomorrow.

  2. mikejiang commented on Sep 20, 2018

    @mikejiang
    Author

    Great!

  3. hpages commented on Sep 21, 2018

    @hpages
    Contributor

    This should work with DelayedArray 0.7.42: b8a6103

    Note that, unlike with an ordinary array, the are still restrictions w.r.t. what the dim() setter can do on a DelayedArray object x. For example if dim(x) is c(5, 4), you can't do dim(x) <- c(10, 2). However you can change the order of the dims with aperm() (generalized transposition).

  4. mikejiang commented on Sep 21, 2018

    @mikejiang
    Author

    Nice! Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions