On Mi, 2016-01-13 at 10:33 -0500, Marten van Kerkwijk wrote: > Just thought I would add here a general comment I made in the thread: > replacing scalars everywhere with array scalars (i.e., ndim=0) would > be great also from the perspective of ndarray subclasses; as is, it > is quite annoying to have to special-case, e.g., getting a single > subclass element, and rewrapping the scalar in the subclass. > -- Marten
I understand the sentiment, and right now I think we usually give the subclass the chance to rewrap itself around 0-d arrays. But ideally I think this is incorrect. Either you want the scalar to be a scalar, or the array actually holds information which is associated with the dtype (i.e. units) and thus should survive conversion to scalar. To me personally, I don't think that we can really remove scalars, due to things such as mutability, sequence ABC registration and with that also hashability. My gut feeling is that there is actually an advantage in having a scalar object, even if internally this scalar object could reuse a lot. Note that a, e.g. 0-d write-only array would raise an error on `a += 1`.... Now practicality beating purity and all that, but to me it is not obvious that it would be the best thing to get rid of scalars completly (getting rid of the code duplication is a different issue). - Sebastian > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > https://mail.scipy.org/mailman/listinfo/numpy-discussion
signature.asc
Description: This is a digitally signed message part
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion