<div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:Helvetica;color:#000000;font-size:13px">I think we should “soft support” i.e. allow but consider unsupported, the case where one of NumPy’s functions is implemented in terms of others and “passing through” an array results in the correct behaviour for that array.</div></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>I don't think we have or want such a concept as "soft support". We intend to not break anything that now has asanyarray, i.e. it's supported and ideally we have regression tests for all such functions. For anything we transition over from asarray to asanyarray, PRs should come with new tests.</div></div></div></blockquote><div><br></div><div>The problem with asanyarray() is that there isn't any well defined subclass API for NumPy, beyond "mostly works like a NumPy array." If every NumPy subclass strictly obeyed the Liskov Substitution Principle asanyarray() would be fine, but in practice every subclass I've encountered deviates from  the behavior of numpy.ndarray in some way.</div><div><br></div><div>The means the NumPy codebase has ended up littered with hacks/workarounds to support various specific subclasses, and new subclasses still don't work reliably. This makes it challenging to change existing code. For an example of how bad this is gotten, look at all the work-arounds I had to add to support np.testing.assert_array_equal() on ndarray subclasses in this recent PR:</div><div><a href="https://github.com/numpy/numpy/pull/12119">https://github.com/numpy/numpy/pull/12119</a><br></div><div><br></div><div>My hope is that __array_function__ will finally let us put a stop to this by offering a better alternative to subclassing.</div></div></div>