Dimension error with `r_vector`
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start by reproducing the supplied cpp_function example and inspect how r_vector handles R_DimSymbol and validates dimensions. The issue is done when a six-element vector can accept dimensions {2, 3} without reporting length 8, with a regression test covering the example.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi, thanks for this wonderful package. As I was playing around with the r_vector class, I found the following peculiar behavior and I think this might be a bug. Specifically, there should only be 6 elements, but when writing the dimensions to the vector, it returns an error saying there's 8 elements.
cpp11::cpp_function(
"
SEXP test() {
using namespace cpp11;
writable::r_vector<double> vec; // Start empty
// Dynamically add data
vec.push_back(1.0);
vec.push_back(2.0);
vec.push_back(3.0);
vec.push_back(4.0);
vec.push_back(5.0);
vec.push_back(6.0);
message(\"size: %i\", vec.size());
// Now decide dimensions (2 rows by 3 columns)
vec.attr(R_DimSymbol) = writable::r_vector<int>({2, 3});
// Create matrix from the vector
// writable::doubles_matrix<> mat(vec.data());
return(vec.attr(R_DimSymbol));
}
"
)
test()
#> size: 6
#> Error in test(): dims [product 6] do not match the length of object [8]
Created on 2025-07-21 with reprex v2.1.1
Disclaimer: This example was taken from some code snippets from Claude while I was trying to understand the internals of this package.
- Lingua principale
- C++
- Stelle
- 225
- Fork
- 52
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di r-lib/cpp11
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
Issue simili
-
HasBacktrace Priority-Critical
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
azerothcore/azerothcore-wotlk#27921 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
yhirose/cpp-peglib#344 ·
-
bug-unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
shadps4-emu/shadps4-qtlauncher#453 ·
I maintainer di solito rispondono entro 2 giorni