@@ -113,38 +113,71 @@ def test_default_dendrogram(self):
113
113
[1 , 1 , 3 , 4 ],
114
114
[1 , 2 , 1 , 4 ],
115
115
[1 , 2 , 3 , 1 ]]))
116
- expected_dendro_data = [{'marker' : {'color' : 'rgb(255,133,27)' },
117
- 'mode' : 'lines' , 'xaxis' : 'xs' ,
118
- 'yaxis' : 'y' ,
119
- 'y' : np .array ([0. , 1. , 1. , 0. ]),
120
- 'x' : np .array ([25. , 25. , 35. , 35. ]),
121
- 'type' : u'scatter' },
122
- {'marker' : {'color' : 'rgb(255,133,27)' },
123
- 'mode' : 'lines' ,
124
- 'xaxis' : 'x' ,
125
- 'yaxis' : 'y' ,
126
- 'y' : np .array ([0. , 2.23606798 ,
127
- 2.23606798 , 1. ]),
128
- 'x' : np .array ([15. , 15. , 30. , 30. ]),
129
- 'type' : u'scatter' },
130
- {'marker' : {'color' : 'blue' },
131
- 'mode' : 'lines' ,
132
- 'xaxis' : 'x' ,
133
- 'yaxis' : 'y' ,
134
- 'y' : np .array ([0. , 3.60555128 ,
135
- 3.60555128 , 2.23606798 ]),
136
- 'x' : np .array ([5. , 5. , 22.5 , 22.5 ]),
137
- 'type' : u'scatter' }]
138
-
139
- self .assertEqual (len (dendro ['data' ]), len (expected_dendro_data ))
140
- self .assertTrue (np .array_equal (dendro ['layout' ]['x' ]['ticktext' ],
141
- np .array (['3' , '2' , '0' , '1' ])))
142
-
116
+ expected_data = [{'marker' : {'color' : 'rgb(255,133,27)' },
117
+ 'mode' : 'lines' , 'xaxis' : 'xs' ,
118
+ 'yaxis' : 'y' ,
119
+ 'y' : np .array ([0. , 1. , 1. , 0. ]),
120
+ 'x' : np .array ([25. , 25. , 35. , 35. ]),
121
+ 'type' : u'scatter' },
122
+ {'marker' : {'color' : 'rgb(255,133,27)' },
123
+ 'mode' : 'lines' ,
124
+ 'xaxis' : 'x' ,
125
+ 'yaxis' : 'y' ,
126
+ 'y' : np .array ([0. , 2.23606798 ,
127
+ 2.23606798 , 1. ]),
128
+ 'x' : np .array ([15. , 15. , 30. , 30. ]),
129
+ 'type' : u'scatter' },
130
+ {'marker' : {'color' : 'blue' },
131
+ 'mode' : 'lines' ,
132
+ 'xaxis' : 'x' ,
133
+ 'yaxis' : 'y' ,
134
+ 'y' : np .array ([0. , 3.60555128 ,
135
+ 3.60555128 , 2.23606798 ]),
136
+ 'x' : np .array ([5. , 5. , 22.5 , 22.5 ]),
137
+ 'type' : u'scatter' }]
138
+ expected_layout = {'width' : '100%' ,
139
+ 'showlegend' : False ,
140
+ 'autoscale' : False ,
141
+ 'x' : {'showticklabels' : True ,
142
+ 'tickmode' : 'array' ,
143
+ 'ticks' : 'outside' ,
144
+ 'showgrid' : False ,
145
+ 'mirror' : 'allticks' ,
146
+ 'zeroline' : False ,
147
+ 'showline' : True ,
148
+ 'ticktext' : np .array (['3' , '2' ,
149
+ '0' , '1' ],
150
+ dtype = '|S1' ),
151
+ 'rangemode' : 'tozero' ,
152
+ 'type' : 'linear' ,
153
+ 'tickvals' : np .array ([5.0 , 15.0 ,
154
+ 25.0 , 35.0 ])},
155
+ 'y' : {'showticklabels' : True ,
156
+ 'ticks' : 'outside' ,
157
+ 'showgrid' : False ,
158
+ 'mirror' : 'allticks' ,
159
+ 'zeroline' : False ,
160
+ 'showline' : True ,
161
+ 'rangemode' : 'tozero' ,
162
+ 'type' : 'linear' },
163
+ 'hovermode' : 'closest' }
164
+
165
+ # Make sure data is as expected
166
+ self .assertEqual (len (dendro ['data' ]), len (expected_data ))
143
167
for i in range (1 , len (dendro ['data' ])):
144
168
self .assertTrue (np .allclose (dendro ['data' ][i ]['x' ],
145
- expected_dendro_data [i ]['x' ]))
169
+ expected_data [i ]['x' ]))
146
170
self .assertTrue (np .allclose (dendro ['data' ][i ]['y' ],
147
- expected_dendro_data [i ]['y' ]))
171
+ expected_data [i ]['y' ]))
172
+
173
+ # Make sure layout is as expected
174
+ self .assertTrue (np .array_equal (dendro ['layout' ]['x' ]['ticktext' ],
175
+ expected_layout ['x' ]['ticktext' ]))
176
+ self .assertTrue (np .array_equal (dendro ['layout' ]['x' ]['tickvals' ],
177
+ expected_layout ['x' ]['tickvals' ]))
178
+ self .assertEqual (dendro ['layout' ]['x' ]['ticks' ], 'outside' )
179
+ self .assertEqual (dendro ['layout' ]['y' ]['ticks' ], 'outside' )
180
+ self .assertEqual (dendro ['layout' ]['width' ], expected_layout ['width' ])
148
181
149
182
def test_dendrogram_random_matrix (self ):
150
183
# create a random uncorrelated matrix
0 commit comments