On Thu, Feb 6, 2014 at 5:46 AM, Alan G Isaac <[email protected]> wrote:
> NumPy matrix construction includes as a convenience feature
> the construction of matrices with a Matlab-like syntax.
> E.g., np.mat('1 2;3 4').
>
> Is it correct that this syntax is not supported for
> direct (i.e., not using `mat`) ndarray creation?
>
> You may ask, where would this possibly matter?
> The answer: in the undergraduate classroom.
>
> Compare np.mat('1 2; 3 4')
> to np.array([[1, 2], [3, 4]])
> for readability and intimidation factor.
> Little things matter when getting started
> with students who lack programming background.
>
1) so use np.mat !
2) The "right" way involves a few more keystrokes -- is this really a big
deal?
"Commas separate elements, each row is enclosed in square brackets"
vs:
"whitespace separates elements, semi-colons separate rows."
I'm not sure it's that much harder to understand for a newbie. I'm sure
it is for someone used to MATLAB, but do we really want to encourage folks
to keep their MATLAB habits?
3) Even if it is substantially easier for a newbie, I think we need to be
very careful in teaching to select for "easy to learn first" over "the
right way to do it" -- in general, I think it's more important to establish
good habits and understanding of what's under the covers
than maximizing the ability to type in their first array literal.
4) we really don't want to go down the perl-esque route of "strings
are interpreted as numbers if they happen to be numbers"
IMHO, and all that....
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
[email protected]
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion