role-model / roleR

R package implementing the RoLE model
https://role-model.github.io/roleR
GNU General Public License v3.0
1 stars 2 forks source link

review of indexing across R and C++ #93

Closed ajrominger closed 1 year ago

ajrominger commented 1 year ago

We should just dedicate time to going over indexing once and for all! a few questions:

jidec commented 1 year ago

the approach currently is that all objects living in R should be 1 indexed and all objects living in Cpp or Python are 0 indexed

currently indSpecies, which contains indices for species should start at 1 while in R and start at 0 while in Cpp. We subtract one in C++ right after indSpecies enters C++ (in roleDataCpp constructor) and add 1 in runRole immediately after the model is run

the edges in the phylo also need to be indexed starting at 1 in R and starting at 0 in Cpp, so we also decrement in C++ in the roleDataCpp constructor and increment the edges by 1 in runRole immediately after the model is run

we may want to do this for tipNames, which contains species indices as strings of the form "t1","t2", etc. but I haven't bothered because tipNames is currently not used at all within Cpp.

ajrominger commented 1 year ago

all sounds good! as discussed, let's leave tipNames as they are for now. i'm leaving this issue open in case we need to deal with tipNames in the near future