[MRG] Fix segfault in AgglomerativeClustering with read-only mmaps
This fixes a segfault in AgglomerativeClustering with read-only mmaps that happens inside `ward_tree` when calling `scipy.cluster.hierarchy.ward`.
Closes
(see the above issue for more details)
@@ -230,6 +230,7 @@ def ward_tree(X, connectivity=None, n_clusters=None, return_distance=False):
'retain the lower branches required '
'for the specified number of clusters',
stacklevel=2)
+ X = np.require(X, requirements="W")
out = hierarchy.ward(X)
children_ = out[:, :2].astype(np.intp)
