<div dir="ltr"><div>Duck typing is great and all for classes that implement some or all of the ndarray interface.... but remember what the main reason for asarray() and asanyarray(): to automatically promote lists and tuples and other "array-likes" to ndarrays. Ignoring the use-case of lists of lists is problematic at best.<br><br></div>Ben Root<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 2, 2017 at 5:05 PM, Marten van Kerkwijk <span dir="ltr"><<a href="mailto:m.h.vankerkwijk@gmail.com" target="_blank">m.h.vankerkwijk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">My 2ยข here is that all code should feel free to assume certain type of<br>
input, as long as it is documented properly, but there is no reason to<br>
enforce that by, e.g., putting `asarray` everywhere. Then, for some<br>
pieces ducktypes and subclasses will just work like magic, and uses<br>
you might never have foreseen become possible. For others, whoever<br>
wants to use them has to do work (and up to a package maintainers to<br>
decide whether or not to accept PRs that implement hooks, etc.)<br>
<br>
I do see the argument that this way one becomes constrained in the<br>
internal implementation, as a change may break an outward-looking<br>
function, but while at times this may be inconvenient, in my<br>
experience at others it may just make one realize an even better<br>
implementation is possible. But then, I really like duck-typing...<br>
<span class="HOEnZb"><font color="#888888"><br>
-- Marten<br>
</font></span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@python.org">NumPy-Discussion@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/numpy-<wbr>discussion</a><br>
</div></div></blockquote></div><br></div>