Julia type displaying change between versions

This is the opposite of my point. An array in julia is not a vector of vectors. These are different concepts; they are different in memory layout, implementation, which operations they support, and also from a linear algebra perspective. They are similar, and therefore a Vector is a subtype of Array, but they are not identical.

And what if they don’t? After all, each element in a list can be totally distinct in length. Is it really fair to say, at a type level, that an object that has direct correspondence with math and tensors is the same as all lists of lists? If you do this, everywhere you use a Matrix you must check it is valid before e.g. accessing indices. No thanks.

The only point I agree with you on in this thread is that numpy isn’t easy to use in this regard:

In [57]: x = np.array([[1,2], [1,2]])

In [58]: y = np.array([[1,2], [1,2,3]])

In [59]: x.ndim
Out[59]: 2

In [60]: y.ndim
Out[60]: 1

In [61]: x[0,0]
Out[61]: 1

In [62]: y[0,0]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-62-74d735007e1b> in <module>()
----> 1 y[0,0]

IndexError: too many indices for array

It is confusing to me that the above constructor makes two completely different objects in the two cases. x is a Matrix, in the julia sense, while y is a 1-d np.ndarray containing two regular python lists. In my opinion (coming from julia), whether I want a list of lists in the first case, or whether I am asking for a matrix in the second (and an error should be thrown) is something that should be more explicit, and after the construction, I should be certain what I have created.

It’s worth noting that your original post in this thread was based on a misunderstanding of what changed between julia versions. It seems that you believed that in past versions, matrices were stored as a list of lists, because the printout said Array{Float64, 2}, and the word array shows up in other languages as well. As I hope is clear by now: this was never the case. Julia has always distinguished between these concepts, and that distinction is fundamental to its usefulness in mathematical programming. The only thing that changed is the word Matrix shows up in the printout now, to help users quickly understand what the object is (and always was).

I’m not sure how much exposure you have to the language so far, but I think that greater immersion in the language, including reading documentation and previous discussions, here and on github, will demonstrate that the core decisions behind julia are all perfectly sound, to say the least.

15 Likes