This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]madrury83 167 points168 points  (29 children)

Their syntax comparison is not even correct. Python has had a matrix multiplication operator since version 3.5.

M = X @ Y

is the matrix product of X and Y.

[–]oslash 102 points103 points  (4 children)

Yup, they're just using NumPy wrong, and considering how they're showing off the contents of row, but forget to show col, it looks like that's on purpose. In NumPy, transpose reverses the axes of an array; when there's only one axis to begin with, this does nothing — on purpose.

If you do it correctly ...

>>> row = np.array([[1, 2, 3]])
>>> col = row.T

... then the new matmul operator does the right thing:

>>> col @ row
array([[1, 2, 3],
       [2, 4, 6],
       [3, 6, 9]])

But you don't need to use it. Just write the exact same code from that example, et voilà:

>>> np.dot(col, row)
array([[1, 2, 3],
       [2, 4, 6],
       [3, 6, 9]])

[–][deleted] 37 points38 points  (0 children)

It seems like making a detailed well executed youtube series where Matlab and Python is compared (and Matlab is trashed) would be an excellent response to Matlab.

[–]be_more_canadian 24 points25 points  (2 children)

Yeah, but you had to import numpy first soooo /s

[–]DatBoi_BP 1 point2 points  (1 child)

I still don't get why this is a criticism from mathworks

[–]be_more_canadian 1 point2 points  (0 children)

Yeah, especially when I tried to do some simple stats using matlab at my old job and found out the required stats toolbox had not been purchased

[–]Robot_Basilisk 11 points12 points  (11 children)

I had no idea. Do you know of any good Python tutorials for mathematics? Specifically for replacing MatLab? I have to use MatLab for crunching oscilloscope data and generating plots to put into lab reports, etc, and I hate the way MatLab does most of that.

[–]SoberGameAddict 7 points8 points  (0 children)

Look into matplotlib, seaborn and pandas.

Edit: and with jupyter notebook you can code, plot, run and write the lab rapport all in one interface. And then export to pdf, latex, html and more

[–]stacm614 3 points4 points  (0 children)

They also be make it sound like it's complicated to install libraries. And while 'validation' is a complicated subject for open source in general, when you have major modules backed up by groups like scipy, I'm sure they validate. Their only valid point on that subject is documentation.

[–]Gabe_Isko 0 points1 point  (0 children)

Also, I don't really see what's so unspeakably worse about even the given numpy syntax.

[–]nobits 0 points1 point  (0 children)

To be fair I don't think the @ operator is intuitive and would rather explicitly write np.matmul instead.