Skip to content

Commit

Permalink
Merge pull request scipy#510 from WarrenWeckesser/cluster-cleanup
Browse files Browse the repository at this point in the history
MAINT: cluster: Remove unused imports, unused variables and commented-out code from hierarchy.py
  • Loading branch information
rgommers committed Apr 14, 2013
2 parents 5085ffb + 1253293 commit ab3ba09
Showing 1 changed file with 1 addition and 42 deletions.
43 changes: 1 addition & 42 deletions scipy/cluster/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import types
import warnings

import numpy as np
Expand Down Expand Up @@ -974,19 +973,16 @@ def cophenet(Z, Y=None):
return zz

Y = np.asarray(Y, order='c')
Ys = Y.shape
distance.is_valid_y(Y, throw=True, name='Y')

z = zz.mean()
y = Y.mean()
Yy = Y - y
Zz = zz - z
#print Yy.shape, Zz.shape
numerator = (Yy * Zz)
denomA = Yy ** 2
denomB = Zz ** 2
c = numerator.sum() / np.sqrt((denomA.sum() * denomB.sum()))
#print c, numerator.sum()
return (c, zz)


Expand Down Expand Up @@ -1029,8 +1025,6 @@ def inconsistent(Z, d=2):
if (not d == np.floor(d)) or d < 0:
raise ValueError('The second argument d must be a nonnegative '
'integer value.')
# if d == 0:
# d = 1

# Since the C code does not support striding using strides.
# The dimensions are used instead.
Expand Down Expand Up @@ -1350,12 +1344,6 @@ def is_valid_linkage(Z, warning=False, throw=False, name=None):
else:
raise ValueError('Linkage uses the same cluster more than '
'once.')
# if _check_hierarchy_not_all_clusters_used(Z):
# if name:
# raise ValueError('Linkage \'%s\' does not use all clusters.'
# % name)
# else:
# raise ValueError('Linkage does not use all clusters.')
except Exception as e:
if throw:
raise
Expand Down Expand Up @@ -1733,8 +1721,7 @@ def _plot_dendrogram(icoords, dcoords, ivl, p, n, mh, orientation,
else:
matplotlib.pylab.setp(lbls, 'size',
float(_get_tick_text_size(len(ivl))))
# txt.set_fontsize()
# txt.set_rotation(45)

# Make the tick marks invisible because they cover up the links
for line in axis.get_xticklines():
line.set_visible(False)
Expand Down Expand Up @@ -1836,8 +1823,6 @@ def _plot_dendrogram(icoords, dcoords, ivl, p, n, mh, orientation,
axis.add_collection(colors_to_collections['b'])

if contraction_marks is not None:
#xs=[x for (x, y) in contraction_marks]
#ys=[y for (x, y) in contraction_marks]
if orientation in ('left', 'right'):
for (x, y) in contraction_marks:
e = matplotlib.patches.Ellipse((y, x),
Expand All @@ -1855,11 +1840,6 @@ def _plot_dendrogram(icoords, dcoords, ivl, p, n, mh, orientation,
e.set_alpha(0.5)
e.set_facecolor('k')

#matplotlib.pylab.plot(xs, ys, 'go', markeredgecolor='k',
# markersize=3)

#matplotlib.pylab.plot(ys, xs, 'go', markeredgecolor='k',
# markersize=3)
matplotlib.pylab.draw_if_interactive()

_link_line_colors = ['g', 'r', 'c', 'm', 'y', 'k']
Expand Down Expand Up @@ -2140,7 +2120,6 @@ def dendrogram(Z, p=30, truncate_mode=None, color_threshold=None,
color_threshold = max(Z[:, 2]) * 0.7
R = {'icoord': icoord_list, 'dcoord': dcoord_list, 'ivl': ivl,
'leaves': lvs, 'color_list': color_list}
props = {'cbt': False, 'cc': 0}
if show_contracted:
contraction_marks = []
else:
Expand Down Expand Up @@ -2392,22 +2371,6 @@ def _dendrogram_calculate_info(Z, p, truncate_mode, \
ua = aa
ub = ab

# The distance of the cluster to draw to the left (ua) is uad
# and its count is uan. Likewise, the cluster to draw to the
# right has distance ubd and count ubn.
if ua < n:
uad = 0.0
uan = 1
else:
uad = Z[ua - n, 2]
uan = Z[ua - n, 3]
if ub < n:
ubd = 0.0
ubn = 1
else:
ubd = Z[ub - n, 2]
ubn = Z[ub - n, 3]

# Updated iv variable and the amount of space used.
(uiva, uwa, uah, uamd) = \
_dendrogram_calculate_info(
Expand Down Expand Up @@ -2462,10 +2425,6 @@ def _dendrogram_calculate_info(Z, p, truncate_mode, \
level=level + 1, contraction_marks=contraction_marks,
link_color_func=link_color_func)

# The height of clusters a and b
ah = uad
bh = ubd

max_dist = max(uamd, ubmd, h)

icoord_list.append([uiva, uiva, uivb, uivb])
Expand Down

0 comments on commit ab3ba09

Please sign in to comment.