<h3 dir="auto">Description</h3>
<p dir="auto">JAX configures the root logger facility what is a little breaking behavior since using JAX in a third-party application changes logging configuration of the whole app! In my opinion, such side-effects are not desirable and should be fixed.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import logging, jax
# The next line does nothing since the root logger is already created. We need
# to reset the root logger with force=True option.
logging.basicConfig(level=logging.INFO)
logging.error('error')
logging.info('info')"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">logging</span>, <span class="pl-s1">jax</span>
<span class="pl-c"># The next line does nothing since the root logger is already created. We need</span>
<span class="pl-c"># to reset the root logger with force=True option.</span>
<span class="pl-s1">logging</span>.<span class="pl-en">basicConfig</span>(<span class="pl-s1">level</span><span class="pl-c1">=</span><span class="pl-s1">logging</span>.<span class="pl-v">INFO</span>)
<span class="pl-s1">logging</span>.<span class="pl-en">error</span>(<span class="pl-s">'error'</span>)
<span class="pl-s1">logging</span>.<span class="pl-en">info</span>(<span class="pl-s">'info'</span>)</pre></div>
<h4 dir="auto">Expected output</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR:root:error
INFO:root:info"><pre class="notranslate"><code class="notranslate">ERROR:root:error
INFO:root:info
</code></pre></div>
<h4 dir="auto">Actual output</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR:root:error"><pre class="notranslate"><code class="notranslate">ERROR:root:error
</code></pre></div>
<h3 dir="auto">What jax/jaxlib version are you using?</h3>
<p dir="auto">jax v0.3.17, jaxlib v0.3.15</p>
<h3 dir="auto">Which accelerator(s) are you using?</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Additional System Info</h3>
<p dir="auto"><em>No response</em></p>
<p dir="auto">Hi. There is some (very minor) deviations in the output of <code class="notranslate">jax.numpy.percentile</code> between <code class="notranslate">jax</code> <a href="https://github.com/google/jax/compare/jax-v0.2.20...jax-v0.2.21"><code class="notranslate">v0.2.20</code> and <code class="notranslate">v0.2.21</code></a> in the case that linear interpolation is used (the default). Interestingly, it is really in <code class="notranslate">jax.numpy.percentile</code> and not in <code class="notranslate">jax.numpy.quantile</code> as can be shown in the included example (for convenience this Issue also exists as <a href="https://gist.github.com/matthewfeickert/d8364201ddad6653315a62dc9b921318">a GitHub Gist</a>).</p>
<h2 dir="auto">Minimal failing example</h2>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="# example.py
import jax
import jax.numpy as jnp
import numpy as np
from jax.config import config

config.update(&quot;jax_enable_x64&quot;, True)

if __name__ == &quot;__main__&quot;:

    # percentile interpolation options:
    # This optional parameter specifies the interpolation method to use when the desired percentile lies between two data points i &lt; j:
    # * ’linear’: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j.
    # * ’lower’: i.
    # * ’higher’: j.
    # * ’nearest’: i or j, whichever is nearest.
    # * ’midpoint’: (i + j) / 2.

    input = [[10, 7, 4], [3, 2, 1]]
    print(f&quot;input list: {input}&quot;)
    print(f&quot;input list ravel: {np.asarray(input).ravel()}&quot;)
    # [10  7  4  3  2  1]

    print(f&quot;\nNumPy v{np.__version__}&quot;)
    print(f&quot;JAX v{jax.__version__}\n&quot;)
    numpy_array = np.asarray(input)
    print(f&quot;{numpy_array=}&quot;)
    jax_array = jnp.asarray(input, dtype=&quot;float&quot;)
    print(f&quot;{jax_array=}&quot;)

    print(&quot;\n# Checking quantile\n&quot;)
    assert np.quantile(numpy_array, 0) == 1.0
    assert np.quantile(numpy_array, 0.50) == 3.5
    assert np.quantile(numpy_array, 1) == 10
    assert np.quantile(numpy_array, 0.50, axis=1).tolist() == [7.0, 2.0]

    assert np.quantile(numpy_array, 0.50, interpolation=&quot;linear&quot;) == 3.5
    assert np.quantile(numpy_array, 0.50, interpolation=&quot;nearest&quot;) == 3.0
    assert np.quantile(numpy_array, 0.50, interpolation=&quot;lower&quot;) == 3.0
    assert np.quantile(numpy_array, 0.50, interpolation=&quot;midpoint&quot;) == 3.5
    assert np.quantile(numpy_array, 0.50, interpolation=&quot;higher&quot;) == 4.0

    assert jnp.quantile(jax_array, 0) == 1.0
    assert jnp.quantile(jax_array, 0.50) == 3.5
    assert jnp.quantile(jax_array, 1) == 10
    assert jnp.quantile(jax_array, 0.50, axis=1).tolist() == [7.0, 2.0]

    assert jnp.quantile(jax_array, 0.50, interpolation=&quot;linear&quot;) == 3.5
    assert jnp.quantile(jax_array, 0.50, interpolation=&quot;nearest&quot;) == 3.0
    assert jnp.quantile(jax_array, 0.50, interpolation=&quot;lower&quot;) == 3.0
    assert jnp.quantile(jax_array, 0.50, interpolation=&quot;midpoint&quot;) == 3.5
    assert jnp.quantile(jax_array, 0.50, interpolation=&quot;higher&quot;) == 4.0

    print(&quot;# Checking percentile&quot;)
    assert np.percentile(numpy_array, 0) == 1.0
    assert np.percentile(numpy_array, 50) == 3.5
    assert np.percentile(numpy_array, 100) == 10
    assert np.percentile(numpy_array, 50, axis=1).tolist() == [7.0, 2.0]

    assert np.percentile(numpy_array, 50, interpolation=&quot;linear&quot;) == 3.5
    assert np.percentile(numpy_array, 50, interpolation=&quot;nearest&quot;) == 3.0
    assert np.percentile(numpy_array, 50, interpolation=&quot;lower&quot;) == 3.0
    assert np.percentile(numpy_array, 50, interpolation=&quot;midpoint&quot;) == 3.5
    assert np.percentile(numpy_array, 50, interpolation=&quot;higher&quot;) == 4.0

    # default interpolation method is &quot;linear&quot;
    assert jnp.percentile(jax_array, 0) == 1.0
    assert jnp.percentile(jax_array, 50) == 3.5  # 3.499999761581421
    assert jnp.percentile(jax_array, 100) == 10  # 9.999998092651367
    assert jnp.percentile(jax_array, 50, axis=1).tolist() == [7.0, 2.0]

    assert jnp.percentile(jax_array, 50, interpolation=&quot;linear&quot;) == 3.5  # 3.499999761581421
    assert jnp.percentile(jax_array, 50, interpolation=&quot;nearest&quot;) == 3.0
    assert jnp.percentile(jax_array, 50, interpolation=&quot;lower&quot;) == 3.0
    assert jnp.percentile(jax_array, 50, interpolation=&quot;midpoint&quot;) == 3.5
    assert jnp.percentile(jax_array, 50, interpolation=&quot;higher&quot;) == 4.0"><pre class="notranslate"><span class="pl-c"># example.py</span>
<span class="pl-k">import</span> <span class="pl-s1">jax</span>
<span class="pl-k">import</span> <span class="pl-s1">jax</span>.<span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">jnp</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">from</span> <span class="pl-s1">jax</span>.<span class="pl-s1">config</span> <span class="pl-k">import</span> <span class="pl-s1">config</span>

<span class="pl-s1">config</span>.<span class="pl-en">update</span>(<span class="pl-s">"jax_enable_x64"</span>, <span class="pl-c1">True</span>)

<span class="pl-k">if</span> <span class="pl-s1">__name__</span> <span class="pl-c1">==</span> <span class="pl-s">"__main__"</span>:

    <span class="pl-c"># percentile interpolation options:</span>
    <span class="pl-c"># This optional parameter specifies the interpolation method to use when the desired percentile lies between two data points i &lt; j:</span>
    <span class="pl-c"># * ’linear’: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j.</span>
    <span class="pl-c"># * ’lower’: i.</span>
    <span class="pl-c"># * ’higher’: j.</span>
    <span class="pl-c"># * ’nearest’: i or j, whichever is nearest.</span>
    <span class="pl-c"># * ’midpoint’: (i + j) / 2.</span>

    <span class="pl-s1">input</span> <span class="pl-c1">=</span> [[<span class="pl-c1">10</span>, <span class="pl-c1">7</span>, <span class="pl-c1">4</span>], [<span class="pl-c1">3</span>, <span class="pl-c1">2</span>, <span class="pl-c1">1</span>]]
    <span class="pl-en">print</span>(<span class="pl-s">f"input list: <span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">input</span><span class="pl-kos">}</span></span>"</span>)
    <span class="pl-en">print</span>(<span class="pl-s">f"input list ravel: <span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">np</span>.<span class="pl-en">asarray</span>(<span class="pl-s1">input</span>).<span class="pl-en">ravel</span>()<span class="pl-kos">}</span></span>"</span>)
    <span class="pl-c"># [10  7  4  3  2  1]</span>

    <span class="pl-en">print</span>(<span class="pl-s">f"<span class="pl-cce">\n</span>NumPy v<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">np</span>.<span class="pl-s1">__version__</span><span class="pl-kos">}</span></span>"</span>)
    <span class="pl-en">print</span>(<span class="pl-s">f"JAX v<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">jax</span>.<span class="pl-s1">__version__</span><span class="pl-kos">}</span></span><span class="pl-cce">\n</span>"</span>)
    <span class="pl-s1">numpy_array</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">asarray</span>(<span class="pl-s1">input</span>)
    <span class="pl-en">print</span>(<span class="pl-s">f"<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">numpy_array</span><span class="pl-c1">=</span><span class="pl-kos">}</span></span>"</span>)
    <span class="pl-s1">jax_array</span> <span class="pl-c1">=</span> <span class="pl-s1">jnp</span>.<span class="pl-en">asarray</span>(<span class="pl-s1">input</span>, <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">"float"</span>)
    <span class="pl-en">print</span>(<span class="pl-s">f"<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">jax_array</span><span class="pl-c1">=</span><span class="pl-kos">}</span></span>"</span>)

    <span class="pl-en">print</span>(<span class="pl-s">"<span class="pl-cce">\n</span># Checking quantile<span class="pl-cce">\n</span>"</span>)
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">0</span>) <span class="pl-c1">==</span> <span class="pl-c1">1.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">0.50</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">1</span>) <span class="pl-c1">==</span> <span class="pl-c1">10</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>).<span class="pl-en">tolist</span>() <span class="pl-c1">==</span> [<span class="pl-c1">7.0</span>, <span class="pl-c1">2.0</span>]

    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"linear"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"nearest"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"lower"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"midpoint"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"higher"</span>) <span class="pl-c1">==</span> <span class="pl-c1">4.0</span>

    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">0</span>) <span class="pl-c1">==</span> <span class="pl-c1">1.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">0.50</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">1</span>) <span class="pl-c1">==</span> <span class="pl-c1">10</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>).<span class="pl-en">tolist</span>() <span class="pl-c1">==</span> [<span class="pl-c1">7.0</span>, <span class="pl-c1">2.0</span>]

    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"linear"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"nearest"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"lower"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"midpoint"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">quantile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">0.50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"higher"</span>) <span class="pl-c1">==</span> <span class="pl-c1">4.0</span>

    <span class="pl-en">print</span>(<span class="pl-s">"# Checking percentile"</span>)
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">0</span>) <span class="pl-c1">==</span> <span class="pl-c1">1.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">50</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">100</span>) <span class="pl-c1">==</span> <span class="pl-c1">10</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>).<span class="pl-en">tolist</span>() <span class="pl-c1">==</span> [<span class="pl-c1">7.0</span>, <span class="pl-c1">2.0</span>]

    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"linear"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"nearest"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"lower"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"midpoint"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>
    <span class="pl-k">assert</span> <span class="pl-s1">np</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">numpy_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"higher"</span>) <span class="pl-c1">==</span> <span class="pl-c1">4.0</span>

    <span class="pl-c"># default interpolation method is "linear"</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">0</span>) <span class="pl-c1">==</span> <span class="pl-c1">1.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">50</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>  <span class="pl-c"># 3.499999761581421</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">100</span>) <span class="pl-c1">==</span> <span class="pl-c1">10</span>  <span class="pl-c"># 9.999998092651367</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>).<span class="pl-en">tolist</span>() <span class="pl-c1">==</span> [<span class="pl-c1">7.0</span>, <span class="pl-c1">2.0</span>]

    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"linear"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>  <span class="pl-c"># 3.499999761581421</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"nearest"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"lower"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.0</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"midpoint"</span>) <span class="pl-c1">==</span> <span class="pl-c1">3.5</span>
    <span class="pl-k">assert</span> <span class="pl-s1">jnp</span>.<span class="pl-en">percentile</span>(<span class="pl-s1">jax_array</span>, <span class="pl-c1">50</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"higher"</span>) <span class="pl-c1">==</span> <span class="pl-c1">4.0</span></pre></div>
<div class="highlight highlight-text-shell-session notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="user@machine:~$ python --version
Python 3.9.6
user@machine:~$ python -m venv /tmp/venv &amp;&amp; . /tmp/venv/bin/activate
(venv) user@machine:~$ python -m pip install --upgrade pip setuptools wheel
(venv) user@machine:~$ cat requirements_passing.txt
jax==0.2.20
jaxlib==0.1.69
(venv) user@machine:~$ python -m pip install -r requirements_passing.txt
(venv) user@machine:~$ python example.py
input list: [[10, 7, 4], [3, 2, 1]]
input list ravel: [10  7  4  3  2  1]

NumPy v1.21.4
JAX v0.2.20

numpy_array=array([[10,  7,  4],
       [ 3,  2,  1]])
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
jax_array=DeviceArray([[10.,  7.,  4.],
             [ 3.,  2.,  1.]], dtype=float64)

# Checking quantile

# Checking percentile
(venv) user@machine:~$ cat requirements_failing.txt
jax==0.2.21
jaxlib==0.1.69
(venv) user@machine:~$ python -m pip install -r requirements_failing.txt
(venv) user@machine:~$ python example.py
input list: [[10, 7, 4], [3, 2, 1]]
input list ravel: [10  7  4  3  2  1]

NumPy v1.21.4
JAX v0.2.21

numpy_array=array([[10,  7,  4],
       [ 3,  2,  1]])
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
jax_array=DeviceArray([[10.,  7.,  4.],
             [ 3.,  2.,  1.]], dtype=float64)

# Checking quantile

# Checking percentile
Traceback (most recent call last):
  File &quot;/home/feickert/Code/debug/jax-percentile-drift/example.py&quot;, line 67, in &lt;module&gt;
    assert jnp.percentile(jax_array, 50) == 3.5  # 3.499999761581421
AssertionError"><pre class="notranslate"><span class="pl-e">user@machine:~</span>$ <span class="pl-s1">python --version</span>
<span class="pl-c1">Python 3.9.6</span>
<span class="pl-e">user@machine:~</span>$ <span class="pl-s1">python -m venv /tmp/venv <span class="pl-k">&amp;&amp;</span> <span class="pl-c1">.</span> /tmp/venv/bin/activate</span>
<span class="pl-e">(venv) user@machine:~</span>$ <span class="pl-s1">python -m pip install --upgrade pip setuptools wheel</span>
<span class="pl-e">(venv) user@machine:~</span>$ <span class="pl-s1">cat requirements_passing.txt</span>
<span class="pl-c1">jax==0.2.20</span>
<span class="pl-c1">jaxlib==0.1.69</span>
<span class="pl-e">(venv) user@machine:~</span>$ <span class="pl-s1">python -m pip install -r requirements_passing.txt</span>
<span class="pl-e">(venv) user@machine:~</span>$ <span class="pl-s1">python example.py</span>
<span class="pl-c1">input list: [[10, 7, 4], [3, 2, 1]]</span>
<span class="pl-c1">input list ravel: [10  7  4  3  2  1]</span>

<span class="pl-c1">NumPy v1.21.4</span>
<span class="pl-c1">JAX v0.2.20</span>

<span class="pl-c1">numpy_array=array([[10,  7,  4],</span>
<span class="pl-c1">       [ 3,  2,  1]])</span>
<span class="pl-c1">WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)</span>
<span class="pl-c1">jax_array=DeviceArray([[10.,  7.,  4.],</span>
<span class="pl-c1">             [ 3.,  2.,  1.]], dtype=float64)</span>

# <span class="pl-s1">Checking quantile</span>

# <span class="pl-s1">Checking percentile</span>
<span class="pl-e">(venv) user@machine:~</span>$ <span class="pl-s1">cat requirements_failing.txt</span>
<span class="pl-c1">jax==0.2.21</span>
<span class="pl-c1">jaxlib==0.1.69</span>
<span class="pl-e">(venv) user@machine:~</span>$ <span class="pl-s1">python -m pip install -r requirements_failing.txt</span>
<span class="pl-e">(venv) user@machine:~</span>$ <span class="pl-s1">python example.py</span>
<span class="pl-c1">input list: [[10, 7, 4], [3, 2, 1]]</span>
<span class="pl-c1">input list ravel: [10  7  4  3  2  1]</span>

<span class="pl-c1">NumPy v1.21.4</span>
<span class="pl-c1">JAX v0.2.21</span>

<span class="pl-c1">numpy_array=array([[10,  7,  4],</span>
<span class="pl-c1">       [ 3,  2,  1]])</span>
<span class="pl-c1">WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)</span>
<span class="pl-c1">jax_array=DeviceArray([[10.,  7.,  4.],</span>
<span class="pl-c1">             [ 3.,  2.,  1.]], dtype=float64)</span>

# <span class="pl-s1">Checking quantile</span>

# <span class="pl-s1">Checking percentile</span>
<span class="pl-c1">Traceback (most recent call last):</span>
<span class="pl-c1">  File "/home/feickert/Code/debug/jax-percentile-drift/example.py", line 67, in &lt;module&gt;</span>
<span class="pl-c1">    assert jnp.percentile(jax_array, 50) == 3.5  # 3.499999761581421</span>
<span class="pl-c1">AssertionError</span></pre></div>
<h2 dir="auto">Notes</h2>
<p dir="auto">Comparing the code for <a href="https://github.com/google/jax/blob/jax-v0.2.20/jax/_src/numpy/lax_numpy.py#L5905-L5912"><code class="notranslate">v0.2.20</code></a></p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/google/jax/blob/a7b61c0e00d1b535df8a30a82edc0074884d5f4c/jax/_src/numpy/lax_numpy.py#L5905-L5912">jax/jax/_src/numpy/lax_numpy.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 5905 to 5912
      in
      <a data-pjax="true" class="commit-tease-sha" href="/google/jax/commit/a7b61c0e00d1b535df8a30a82edc0074884d5f4c">a7b61c0</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L5905" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="5905"></td>
          <td id="LC5905" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-en">@<span class="pl-en">_wraps</span>(<span class="pl-s1">np</span>.<span class="pl-s1">percentile</span>, <span class="pl-s1">skip_params</span><span class="pl-c1">=</span>[<span class="pl-s">'out'</span>, <span class="pl-s">'overwrite_input'</span>])</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L5906" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="5906"></td>
          <td id="LC5906" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">def</span> <span class="pl-en">percentile</span>(<span class="pl-s1">a</span>, <span class="pl-s1">q</span>, <span class="pl-s1">axis</span>: <span class="pl-v">Optional</span>[<span class="pl-v">Union</span>[<span class="pl-s1">int</span>, <span class="pl-v">Tuple</span>[<span class="pl-s1">int</span>, ...]]] <span class="pl-c1">=</span> <span class="pl-c1">None</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L5907" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="5907"></td>
          <td id="LC5907" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">                <span class="pl-s1">out</span><span class="pl-c1">=</span><span class="pl-c1">None</span>, <span class="pl-s1">overwrite_input</span><span class="pl-c1">=</span><span class="pl-c1">False</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"linear"</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L5908" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="5908"></td>
          <td id="LC5908" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">                <span class="pl-s1">keepdims</span><span class="pl-c1">=</span><span class="pl-c1">False</span>): </td>
        </tr>

        <tr class="border-0">
          <td id="L5909" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="5909"></td>
          <td id="LC5909" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-en">_check_arraylike</span>(<span class="pl-s">"percentile"</span>, <span class="pl-s1">a</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L5910" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="5910"></td>
          <td id="LC5910" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-s1">q</span> <span class="pl-c1">=</span> <span class="pl-en">true_divide</span>(<span class="pl-en">asarray</span>(<span class="pl-s1">q</span>), <span class="pl-en">float32</span>(<span class="pl-c1">100.0</span>)) </td>
        </tr>

        <tr class="border-0">
          <td id="L5911" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="5911"></td>
          <td id="LC5911" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-k">return</span> <span class="pl-en">quantile</span>(<span class="pl-s1">a</span>, <span class="pl-s1">q</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-s1">axis</span>, <span class="pl-s1">out</span><span class="pl-c1">=</span><span class="pl-s1">out</span>, <span class="pl-s1">overwrite_input</span><span class="pl-c1">=</span><span class="pl-s1">overwrite_input</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L5912" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="5912"></td>
          <td id="LC5912" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">                   <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s1">interpolation</span>, <span class="pl-s1">keepdims</span><span class="pl-c1">=</span><span class="pl-s1">keepdims</span>) </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">and <a href="https://github.com/google/jax/blob/jax-v0.2.21/jax/_src/numpy/lax_numpy.py#L6420-L6429"><code class="notranslate">v0.2.21</code></a></p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/google/jax/blob/dbeb97d394740bfd122a46249c967139c10d3f11/jax/_src/numpy/lax_numpy.py#L6420-L6429">jax/jax/_src/numpy/lax_numpy.py</a>
    </p>
    <p class="mb-0 color-fg-muted">
        Lines 6420 to 6429
      in
      <a data-pjax="true" class="commit-tease-sha" href="/google/jax/commit/dbeb97d394740bfd122a46249c967139c10d3f11">dbeb97d</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L6420" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6420"></td>
          <td id="LC6420" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-en">@<span class="pl-en">_wraps</span>(<span class="pl-s1">np</span>.<span class="pl-s1">percentile</span>, <span class="pl-s1">skip_params</span><span class="pl-c1">=</span>[<span class="pl-s">'out'</span>, <span class="pl-s">'overwrite_input'</span>])</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L6421" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6421"></td>
          <td id="LC6421" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-en">@<span class="pl-en">partial</span>(<span class="pl-s1">jit</span>, <span class="pl-s1">static_argnames</span><span class="pl-c1">=</span>(<span class="pl-s">'axis'</span>, <span class="pl-s">'overwrite_input'</span>, <span class="pl-s">'interpolation'</span>,</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L6422" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6422"></td>
          <td id="LC6422" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-en">                               <span class="pl-s">'keepdims'</span>))</span> </td>
        </tr>

        <tr class="border-0">
          <td id="L6423" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6423"></td>
          <td id="LC6423" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-k">def</span> <span class="pl-en">percentile</span>(<span class="pl-s1">a</span>, <span class="pl-s1">q</span>, <span class="pl-s1">axis</span>: <span class="pl-v">Optional</span>[<span class="pl-v">Union</span>[<span class="pl-s1">int</span>, <span class="pl-v">Tuple</span>[<span class="pl-s1">int</span>, ...]]] <span class="pl-c1">=</span> <span class="pl-c1">None</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L6424" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6424"></td>
          <td id="LC6424" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">                <span class="pl-s1">out</span><span class="pl-c1">=</span><span class="pl-c1">None</span>, <span class="pl-s1">overwrite_input</span><span class="pl-c1">=</span><span class="pl-c1">False</span>, <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s">"linear"</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L6425" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6425"></td>
          <td id="LC6425" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">                <span class="pl-s1">keepdims</span><span class="pl-c1">=</span><span class="pl-c1">False</span>): </td>
        </tr>

        <tr class="border-0">
          <td id="L6426" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6426"></td>
          <td id="LC6426" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-en">_check_arraylike</span>(<span class="pl-s">"percentile"</span>, <span class="pl-s1">a</span>, <span class="pl-s1">q</span>) </td>
        </tr>

        <tr class="border-0">
          <td id="L6427" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6427"></td>
          <td id="LC6427" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-s1">q</span> <span class="pl-c1">=</span> <span class="pl-en">true_divide</span>(<span class="pl-s1">q</span>, <span class="pl-en">float32</span>(<span class="pl-c1">100.0</span>)) </td>
        </tr>

        <tr class="border-0">
          <td id="L6428" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6428"></td>
          <td id="LC6428" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">   <span class="pl-k">return</span> <span class="pl-en">quantile</span>(<span class="pl-s1">a</span>, <span class="pl-s1">q</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-s1">axis</span>, <span class="pl-s1">out</span><span class="pl-c1">=</span><span class="pl-s1">out</span>, <span class="pl-s1">overwrite_input</span><span class="pl-c1">=</span><span class="pl-s1">overwrite_input</span>, </td>
        </tr>

        <tr class="border-0">
          <td id="L6429" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="6429"></td>
          <td id="LC6429" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line">                   <span class="pl-s1">interpolation</span><span class="pl-c1">=</span><span class="pl-s1">interpolation</span>, <span class="pl-s1">keepdims</span><span class="pl-c1">=</span><span class="pl-s1">keepdims</span>) </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">It seems (at first glance as I haven't dug into this yet) that the only relevant difference is the removal of <code class="notranslate">asarray(q)</code> in the <code class="notranslate">true_divide</code> call in PR <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="981633498" data-permission-text="Title is private" data-url="https://github.com/google/jax/issues/7747" data-hovercard-type="pull_request" data-hovercard-url="/google/jax/pull/7747/hovercard" href="https://github.com/google/jax/pull/7747">#7747</a> (though I would think given the point of that PR that nothing should have changed)</p>
<div class="highlight highlight-source-diff notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="-q = true_divide(asarray(q), float32(100.0))
+q = true_divide(q, float32(100.0))"><pre class="notranslate"><span class="pl-md"><span class="pl-md">-</span>q = true_divide(asarray(q), float32(100.0))</span>
<span class="pl-mi1"><span class="pl-mi1">+</span>q = true_divide(q, float32(100.0))</span></pre></div>
<p dir="auto">This effect is quite minor, and probably poses no real significance in most cases, but it deviates from the docstring described behavior. Maybe the most obvious example is the extremes where the q-th percentile is 1 — which should return the element of the array object which is the maxima (in the example <code class="notranslate">10</code>) but instead returns the floating point approximation of that element (<code class="notranslate">9.999998092651367</code>).</p>
<h2 dir="auto">Request</h2>
<p dir="auto">Would it be possible to revert to the <code class="notranslate">v0.2.20</code> behavior? This would be more consistent with both the docstring and NumPy.</p>
<h2 dir="auto">JAX Issues checklist</h2>
<p dir="auto">Please:</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Check for duplicate issues.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Provide a complete example of how to reproduce the bug, wrapped in triple backticks</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> If applicable, include full error messages/tracebacks.</li>
</ul>