|
271 | 271 | support the array API. Rather, it is intended to be used in the test suites of |
272 | 272 | consuming libraries to test their array API usage.</p> |
273 | 273 | <section id="module-array_api_strict._flags"> |
274 | | -<span id="array-api-strict-flags"></span><h2>Array API Strict Flags<a class="headerlink" href="#module-array_api_strict._flags" title="Link to this heading">¶</a></h2> |
| 274 | +<span id="id1"></span><span id="array-api-strict-flags"></span><h2>Array API Strict Flags<a class="headerlink" href="#module-array_api_strict._flags" title="Link to this heading">¶</a></h2> |
275 | 275 | <p>These functions configure global flags that allow array-api-strict to be |
276 | 276 | used in different “modes”. These modes include</p> |
277 | 277 | <ul class="simple"> |
|
291 | 291 | <p>This function is <strong>not</strong> part of the array API standard. It only exists |
292 | 292 | in array-api-strict.</p> |
293 | 293 | </div> |
| 294 | +<div class="admonition note"> |
| 295 | +<p class="admonition-title">Note</p> |
| 296 | +<p>The <a class="reference external" href="https://data-apis.org/array-api/latest/API_specification/inspection.html">inspection API</a> |
| 297 | +provides a portable way to access most of this information. However, it |
| 298 | +is only present in standard versions starting with 2023.12. The array |
| 299 | +API version can be accessed portably using <code class="code docutils literal notranslate"><span class="pre">xp.__array_api_version__</span></code>.</p> |
| 300 | +</div> |
294 | 301 | <dl class="field-list simple"> |
295 | 302 | <dt class="field-odd">Returns<span class="colon">:</span></dt> |
296 | 303 | <dd class="field-odd"><p><em>dict</em> – A dictionary containing the current array-api-strict flags.</p> |
|
326 | 333 | <dd><p>Set the array-api-strict flags to the specified values.</p> |
327 | 334 | <p>Flags are global variables that enable or disable array-api-strict |
328 | 335 | behaviors.</p> |
| 336 | +<p>The flags can also be changed by setting <a class="reference internal" href="#environment-variables"><span class="std std-ref">environment variables</span></a>.</p> |
329 | 337 | <div class="admonition note"> |
330 | 338 | <p class="admonition-title">Note</p> |
331 | 339 | <p>This function is <strong>not</strong> part of the array API standard. It only exists |
332 | 340 | in array-api-strict.</p> |
333 | 341 | </div> |
334 | | -<ul> |
335 | | -<li><p><code class="code docutils literal notranslate"><span class="pre">api_version</span></code>: The version of the standard to use. Supported |
336 | | -versions are: <code class="docutils literal notranslate"><span class="pre">('2021.12',</span> <span class="pre">'2022.12')</span></code>. The default version number is |
| 342 | +<dl class="field-list"> |
| 343 | +<dt class="field-odd">Parameters<span class="colon">:</span></dt> |
| 344 | +<dd class="field-odd"><ul> |
| 345 | +<li><p><strong>api_version</strong> (<em>str, optional</em>) – The version of the standard to use. Supported versions are: |
| 346 | +<code class="docutils literal notranslate"><span class="pre">('2021.12',</span> <span class="pre">'2022.12',</span> <span class="pre">'2023.12')</span></code>. The default version number is |
337 | 347 | <code class="docutils literal notranslate"><span class="pre">'2022.12'</span></code>.</p> |
338 | 348 | <p>Note that 2021.12 is supported, but currently gives the same thing as |
339 | 349 | 2022.12 (except that the fft extension will be disabled).</p> |
| 350 | +<p>2023.12 support is experimental. Some features in 2023.12 may still be |
| 351 | +missing, and it hasn’t been fully tested. A future version of |
| 352 | +array-api-strict will change the default version to 2023.12.</p> |
340 | 353 | </li> |
341 | | -<li><p><code class="code docutils literal notranslate"><span class="pre">boolean_indexing</span></code>: Whether indexing by a boolean array is supported. |
342 | | -Note that although boolean array indexing does result in data-dependent |
343 | | -shapes, this flag is independent of the <code class="code docutils literal notranslate"><span class="pre">data_dependent_shapes</span></code> flag |
344 | | -(see below).</p></li> |
345 | | -<li><p><code class="code docutils literal notranslate"><span class="pre">data_dependent_shapes</span></code>: Whether data-dependent shapes are enabled in |
346 | | -array-api-strict.</p> |
347 | | -<p>This flag is enabled by default. Array libraries that use computation |
| 354 | +<li><p><strong>boolean_indexing</strong> (<em>bool, optional</em>) – Whether indexing by a boolean array is supported. |
| 355 | +Note that although boolean array indexing does result in |
| 356 | +data-dependent shapes, this flag is independent of the |
| 357 | +<code class="code docutils literal notranslate"><span class="pre">data_dependent_shapes</span></code> flag (see below).</p></li> |
| 358 | +<li><p><strong>data_dependent_shapes</strong> (<em>bool, optional</em>) – Whether data-dependent shapes are enabled in array-api-strict. |
| 359 | +This flag is enabled by default. Array libraries that use computation |
348 | 360 | graphs may not be able to support functions whose output shapes depend |
349 | 361 | on the input data.</p> |
350 | 362 | <p>The functions that make use of data-dependent shapes, and are therefore |
351 | 363 | disabled by setting this flag to False are</p> |
352 | 364 | <ul class="simple"> |
353 | | -<li><p><code class="code docutils literal notranslate"><span class="pre">unique_all</span></code>, <code class="code docutils literal notranslate"><span class="pre">unique_counts</span></code>, <code class="code docutils literal notranslate"><span class="pre">unique_inverse</span></code>, and <code class="code docutils literal notranslate"><span class="pre">unique_values</span></code>.</p></li> |
354 | | -<li><p><code class="code docutils literal notranslate"><span class="pre">nonzero</span></code></p></li> |
355 | | -<li><p><code class="code docutils literal notranslate"><span class="pre">repeat</span></code> when the <code class="code docutils literal notranslate"><span class="pre">repeats</span></code> argument is an array (requires 2023.12 |
356 | | -version of the standard)</p></li> |
| 365 | +<li><p><code class="code docutils literal notranslate"><span class="pre">unique_all()</span></code>, <code class="code docutils literal notranslate"><span class="pre">unique_counts()</span></code>, <code class="code docutils literal notranslate"><span class="pre">unique_inverse()</span></code>, and <code class="code docutils literal notranslate"><span class="pre">unique_values()</span></code>.</p></li> |
| 366 | +<li><p><code class="code docutils literal notranslate"><span class="pre">nonzero()</span></code></p></li> |
| 367 | +<li><p><code class="code docutils literal notranslate"><span class="pre">repeat()</span></code> when the <code class="code docutils literal notranslate"><span class="pre">repeats</span></code> argument is an array (requires the |
| 368 | +2023.12 version of the standard)</p></li> |
357 | 369 | </ul> |
358 | 370 | <p>Note that while boolean indexing is also data-dependent, it is |
359 | 371 | controlled by a separate <code class="code docutils literal notranslate"><span class="pre">boolean_indexing</span></code> flag (see above).</p> |
360 | 372 | <p>See |
361 | 373 | <a class="reference external" href="https://data-apis.org/array-api/latest/design_topics/data_dependent_output_shapes.html">https://data-apis.org/array-api/latest/design_topics/data_dependent_output_shapes.html</a> |
362 | 374 | for more details.</p> |
363 | 375 | </li> |
364 | | -<li><p><code class="code docutils literal notranslate"><span class="pre">enabled_extensions</span></code>: A list of extensions that are enabled in |
365 | | -array-api-strict. The default is <code class="docutils literal notranslate"><span class="pre">('linalg',</span> <span class="pre">'fft')</span></code>. Note that |
366 | | -some extensions require a minimum version of the standard.</p></li> |
| 376 | +<li><p><strong>enabled_extensions</strong> (<em>list of str, optional</em>) – A list of extensions that are enabled in array-api-strict. The default |
| 377 | +is <code class="docutils literal notranslate"><span class="pre">('linalg',</span> <span class="pre">'fft')</span></code>. Note that some extensions require a |
| 378 | +minimum version of the standard.</p></li> |
367 | 379 | </ul> |
368 | | -<p>The flags can also be changed by setting <a class="reference internal" href="#environment-variables"><span class="std std-ref">environment variables</span></a>.</p> |
| 380 | +</dd> |
| 381 | +</dl> |
369 | 382 | <p class="rubric">Examples</p> |
370 | 383 | <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">array_api_strict</span> <span class="kn">import</span> <span class="n">set_array_api_strict_flags</span> |
371 | 384 | </pre></div> |
|
451 | 464 | </dd></dl> |
452 | 465 |
|
453 | 466 | <section id="environment-variables"> |
454 | | -<span id="id1"></span><h3>Environment Variables<a class="headerlink" href="#environment-variables" title="Link to this heading">¶</a></h3> |
| 467 | +<span id="id2"></span><h3>Environment Variables<a class="headerlink" href="#environment-variables" title="Link to this heading">¶</a></h3> |
455 | 468 | <p>Flags can also be set with environment variables. |
456 | 469 | <a class="reference internal" href="#array_api_strict.set_array_api_strict_flags" title="array_api_strict.set_array_api_strict_flags"><code class="xref py py-func docutils literal notranslate"><span class="pre">set_array_api_strict_flags()</span></code></a> will override the values set by environment |
457 | 470 | variables. Note that the environment variables will only change the defaults |
|
0 commit comments