How to convert Tuples to Arrays



I am trying to understand better the concept of Tuples and Array, and how to convert Tuples to Arrays.

This is What I am doing:

Using StatsBase

# Convert to array here

I dont understand the following:

If I try “length(x)” I get the value 1, where I was actually expecting 101.

In order to obtain 101 I have to do “size(x[:][1])” . Why ?

How to convert the Tuple to Array in order to access its elements ?

thank you


h.edges is a one-element tuple, (0.0:0.01:1.0,), whose only element h.edges[1] == 0.0:0.01:1.0 is a range from 0 to 1.0. If you collect the one-element tuple, you get a one-element array, whereas collecting the range h.edges[1] expands it into the 101-element array you’ve seen.

As for why h.edges is a one-element tuple of range, rather than just a range, you’d have to read the docs to understand that, but it’s undoubtedly this way because sometimes h.edges will be more than just one range (maybe if the input is an N-dimensional arrays, it will return N ranges).

Does that help?


Yes it helps a lot ! thank you so much !