Skip to content

Commit 566e8ec

Browse files
committed
BUG: fixes for Dask
[skip cirrus] [skip circle]
1 parent e003b61 commit 566e8ec

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

scipy/cluster/hierarchy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4157,7 +4157,7 @@ def leaders(Z, T):
41574157
if T.shape[0] != Z.shape[0] + 1:
41584158
raise ValueError('Mismatch: len(T)!=Z.shape[0] + 1.')
41594159

4160-
n_clusters = int(xp.unique_values(T).shape[0])
4160+
n_clusters = int(np.asarray(xp.unique_values(T)).shape[0])
41614161
n_obs = int(Z.shape[0] + 1)
41624162
L = np.zeros(n_clusters, dtype=np.int32)
41634163
M = np.zeros(n_clusters, dtype=np.int32)

scipy/cluster/vq.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,9 @@ def _kmeans(obs, guess, thresh=1e-5, xp=None):
317317
# recalc code_book as centroids of associated obs
318318
obs = np.asarray(obs)
319319
obs_code = np.asarray(obs_code)
320+
code_book_len = np.asarray(code_book).shape[0]
320321
code_book, has_members = _vq.update_cluster_means(obs, obs_code,
321-
code_book.shape[0])
322+
code_book_len)
322323
obs = xp.asarray(obs)
323324
obs_code = xp.asarray(obs_code)
324325
code_book = xp.asarray(code_book)

scipy/differentiate/tests/test_differentiate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
@pytest.mark.skip_xp_backends('array_api_strict', reason=array_api_strict_skip_reason)
2323
@pytest.mark.skip_xp_backends('jax.numpy',reason=jax_skip_reason)
24+
@pytest.mark.skip_xp_backends('dask.array', reason='boolean indexing assignment')
2425
class TestDerivative:
2526

2627
def f(self, x):

scipy/integrate/tests/test_tanhsinh.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def wrapped(*arg_arrays):
4848
@pytest.mark.skip_xp_backends(
4949
'array_api_strict', reason='Currently uses fancy indexing assignment.'
5050
)
51+
@pytest.mark.skip_xp_backends(
52+
'dask.array', reason='boolean indexing assignment'
53+
)
5154
@pytest.mark.skip_xp_backends(
5255
'jax.numpy', reason='JAX arrays do not support item assignment.'
5356
)

scipy/ndimage/_morphology.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,7 @@ def morphological_laplace(input, size=None, footprint=None, structure=None,
18031803
tmp2 = grey_erosion(input, size, footprint, structure, None, mode,
18041804
cval, origin, axes=axes)
18051805
np.add(tmp1, tmp2, tmp2)
1806+
input = np.asarray(input)
18061807
np.subtract(tmp2, input, tmp2)
18071808
np.subtract(tmp2, input, tmp2)
18081809
return tmp2

scipy/optimize/_chandrupatla.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def _chandrupatla(func, a, b, *, args=(), xatol=None, xrtol=None,
134134
func, xs, fs, args, shape, dtype, xp = temp
135135
x1, x2 = xs
136136
f1, f2 = fs
137-
status = xp.full_like(x1, xp.asarray(eim._EINPROGRESS),
137+
status = xp.full_like(x1, eim._EINPROGRESS,
138138
dtype=xp.int32) # in progress
139139
nit, nfev = 0, 2 # two function evaluations performed above
140140
finfo = xp.finfo(dtype)
@@ -219,7 +219,7 @@ def post_termination_check(work):
219219
j = ((1 - xp.sqrt(1 - xi1)) < phi1) & (phi1 < xp.sqrt(xi1))
220220

221221
f1j, f2j, f3j, alphaj = work.f1[j], work.f2[j], work.f3[j], alpha[j]
222-
t = xp.full_like(alpha, xp.asarray(0.5))
222+
t = xp.full_like(alpha, 0.5)
223223
t[j] = (f1j / (f1j - f2j) * f3j / (f3j - f2j)
224224
- alphaj * f1j / (f3j - f1j) * f2j / (f2j - f3j))
225225

@@ -401,8 +401,7 @@ def _chandrupatla_minimize(func, x1, x2, x3, *, args=(), xatol=None,
401401
x1, x2, x3 = xs
402402
f1, f2, f3 = fs
403403
phi = xp.asarray(0.5 + 0.5*5**0.5, dtype=dtype)[()] # golden ratio
404-
status = xp.full_like(x1, xp.asarray(eim._EINPROGRESS),
405-
dtype=xp.int32) # in progress
404+
status = xp.full_like(x1, eim._EINPROGRESS, dtype=xp.int32) # in progress
406405
nit, nfev = 0, 3 # three function evaluations performed above
407406
fatol = xp.finfo(dtype).smallest_normal if fatol is None else fatol
408407
frtol = xp.finfo(dtype).smallest_normal if frtol is None else frtol

0 commit comments

Comments
 (0)