greta-dev / greta-dev/greta

error retrieving diagonal from rectangular matrix

Open
#583 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
607
Forks
67
Avg merge
3d 8h
Merged PRs (30d)
1

Description

Greta overloads the R base diag function, but the greta version does not seem to function as advertised; it should extract the main diagonal of a rectangular matrix but instead throws an error. Example from https://greta-stats.org/reference/extract-replace-combine.html below.

``` r
x <- greta::as_data(matrix(1:12, 3, 4))
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
x[1:3, ]
#> greta array (operation)
#>
#> [,1] [,2] [,3] [,4]
#> [1,] 1 4 7 10
#> [2,] 2 5 8 11
#> [3,] 3 6 9 12
x[, 2:4] <- 1:9
e <- greta::diag(x)
#> Error: diagonal elements can only be extracted from square matrices
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.