<p dir="auto">As discussed in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="9798557" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/1549" data-hovercard-type="issue" data-hovercard-url="/scikit-learn/scikit-learn/issues/1549/hovercard" href="https://github.com/scikit-learn/scikit-learn/issues/1549">#1549</a>, utils.check_arrays() does not check the shape or ndim of input arrays.  However, the docstring suggests that it should: "Checks whether all objects in arrays have the same shape or length."</p>
<p dir="auto">To me, I think what we need is to break check_arrays() into several sub-functions or maybe a class:</p>
<ol dir="auto">
<li>Check sparse / dense</li>
<li>Check dtype</li>
<li>Check first dimension</li>
<li>Check all dimensions</li>
</ol>
<p dir="auto">This issue is about agreeing on what to do about common tests for estimators that support the Array API.</p>
<p dir="auto">There are two things we need to test for every estimator for which we add Array API support:</p>
<ol dir="auto">
<li>does it work with a selection of Array API implementations. I think testing with <code class="notranslate">numpy.array_api</code>, <code class="notranslate">pytorch</code> (CPU) as default and <code class="notranslate">pytoch</code> (GPU) and <code class="notranslate">cupy</code> when a GPU is available would be good and cover most bases.</li>
<li>do the results change when a Array API namespace is used compared to a vanilla Numpy array</li>
</ol>
<p dir="auto">There is a 2.5 point as well: different dtypes (<code class="notranslate">float64</code>, <code class="notranslate">float32</code>, <code class="notranslate">float16</code> (when supported)). Not sure what to do about that in terms of common test.</p>
<p dir="auto">is there something else we should test in the common tests?</p>
<p dir="auto">Implementation wise I think it would be good to add a estimator tag that we can use to mark estimators that support Array API. Something like <code class="notranslate">"array_api_support": True</code>?</p>
<p dir="auto">Then I'd add one test that checks if the result of vanilla Numpy match the results of <code class="notranslate">numpy.array_api</code> (to cover (2)). And then maybe two more common tests. One to check that <code class="notranslate">numpy.array_api</code> and <code class="notranslate">pytorch</code> (CPU) work and another one for the GPU based tests in (1)? I'm wondering if having some code duplication between tests for (1) is worth it in terms of making the tests easier to read compared to trying to do it all via parametrisation.</p>
<p dir="auto">Depending on how far <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1678503814" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/26243" data-hovercard-type="pull_request" data-hovercard-url="/scikit-learn/scikit-learn/pull/26243/hovercard" href="https://github.com/scikit-learn/scikit-learn/pull/26243">#26243</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1691482846" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/26315" data-hovercard-type="pull_request" data-hovercard-url="/scikit-learn/scikit-learn/pull/26315/hovercard" href="https://github.com/scikit-learn/scikit-learn/pull/26315">#26315</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1144910293" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/22554" data-hovercard-type="pull_request" data-hovercard-url="/scikit-learn/scikit-learn/pull/22554/hovercard" href="https://github.com/scikit-learn/scikit-learn/pull/22554">#22554</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1638147187" data-permission-text="Title is private" data-url="https://github.com/scikit-learn/scikit-learn/issues/25956" data-hovercard-type="pull_request" data-hovercard-url="/scikit-learn/scikit-learn/pull/25956/hovercard" href="https://github.com/scikit-learn/scikit-learn/pull/25956">#25956</a> are we should also clean up the tests that check this that were added in those PRs.</p>
<p dir="auto">What do you think <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ogrisel/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ogrisel">@ogrisel</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/thomasjpfan/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/thomasjpfan">@thomasjpfan</a> ?</p>