ValueError: Linkage 'Z' uses the same cluster more than once in Python scipy fcluster
<p>I'm getting <code>ValueError: Linkage 'Z' uses the same cluster more than once.</code> when trying to get flat clusters in Python with scipy.cluster.hierarchy.fcluster. This error happens only sometimes, usually only with really big matrices ie 10000x10000. </p>

<pre><code>import scipy.cluster.hierarchy as sch
Z = sch.linkage(d, method="ward")
# some computation here, returning n (usually between 5-30)
clusters = sch.fcluster(Z, t=n, criterion='maxclust')
</code></pre>

<p>Why does it happen? How can I avoid it? Unfortunately I couldn't find any useful info by googling... </p>

<p><strong>EDIT</strong> Error occurs also when trying to get dendrogram. 
No such error appear if <code>method='average'</code> is used. </p>