擅长:python、mysql、java
<p>您的<code>f</code>可调用参数采用<code>assume_sorted</code>参数:</p>
<pre><code>assume_sorted : bool, optional
If False, values of `x` and `y` can be in any order and they are
sorted first.
If True, `x` and `y` have to be arrays of monotonically
increasing values.
</code></pre>
<p>所以,是的,输入是内部排序的,如果你事先没有排序的话。我看不到坐标的倒数。在</p>
<p>在使用之前,<code>x</code>,<code>y</code>输入到<code>interp2d</code>也被排序。显然插值计算需要排序数组。在</p>
<p>可以使用双<code>argsort</code>索引恢复预排序顺序</p>
<p>制作一个数组并洗牌:</p>
^{pr2}$
<p>获取恢复索引:</p>
<pre><code>In [419]: idx = np.argsort(np.argsort(xnew))
In [420]: idx
Out[420]: array([ 5, 6, 8, 4, 10, 3, 9, 1, 0, 2, 7], dtype=int32)
</code></pre>
<p>测试一下:</p>
<pre><code>In [421]: np.sort(xnew)[idx]
Out[421]: array([ 0, 2, 6, -2, 10, -4, 8, -8, -10, -6, 4])
</code></pre>