Convert Sage List of list of list to R list of list of list -


i have sage list of list of list result of function applied on r list of list of list (converted sage format)

the code goes this:

%r my_r_list<-load("my_r_list.rdata")  d in range(d):     s in range(s):         c in range(c):             my_sage_list[d][s][c] = ("my_r_list")[[d+1]][[s+1]][[c+1]]._sage_()             output_my_sage_list[d][s][c] = some_function(my_sage_list[d][s][c]) 

i convert output_my_sage_list r list save .rdata file

documentation on interface sage r going r sage not other way around.this question concerns converting sagemath matrix r matrix using r.matrix()' tried using 'r.list()' no luck. tried simpleoutput_my_r_list = r(output_my_sage_list)which gives no error output not correct doingoutput_my_r_list[0][0]` doesn't give last level of list directly values.

a reproducible code (bypassing r sage part) be:

    output_d = [[] _ in range(9)]     d in range(9):         output_s = [[] _ in range(4)]         output_d[d] = output_s         s in range(4):             output_c = [[] _ in range(2)]             output_s[s] = output_c              k in range(2):                 res = random()                 output_c[k] = res 

i convert output_d r list

the key here statement

i tried simple output_my_r_list = r(output_my_sage_list) gives no error output not correct doing output_my_r_list[0][0] doesn't give last level of list directly values.

sage documents make list 1 concatenated list, or more r vector:

    sage: x = r([10.4,5.6,3.1,6.4,21.7]); x     [1] 10.4  5.6  3.1  6.4 21.7  following assignment creates vector $y$ 11 entries consists of 2 copies of $x$ 0 in between::      sage: y = r([x,0,x]); y     [1] 10.4  5.6  3.1  6.4 21.7  0.0 10.4  5.6  3.1  6.4 21.7 

this directly modeled upon r usage, , presumably (via nesting procedure) comes it:

the further assignment  > y <- c(x, 0, x)  create vector y 11 entries consisting of 2 copies of  0 in middle place. 

so beef not sage, r, (somehow) sage gets 'right' thing here. sage because here says

def _left_list_delim(self):     return "c(" 

and r behavior follows done recursively , makes vector of vectors.

a hack around return "list(" there. hack try use r.eval("list(something)") didn't experience lot of success this.

it nice find way deal more easily, of course, , in return direction sage attempts take nested r stuff , keep nested (with success, don't know).


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -