def test_heatmap_construct_and_sort(self):
     data = [(chr(65+i),chr(97+j), i*j) for i in range(3) for j in [2, 0, 1] if i!=j]
     hmap = HeatMap(data).sort()
     dataset = Dataset({'x': ['A', 'B', 'C'], 'y': ['a', 'b', 'c'],
                        'z': [[np.NaN, 0, 0], [0, np.NaN, 2], [0, 2, np.NaN]]},
                       kdims=['x', 'y'], vdims=['z'])
     self.assertEqual(hmap.gridded, dataset)
Exemplo n.º 2
0
 def test_heatmap_construct_unsorted(self):
     hmap = HeatMap([('B', 'b', 2), ('A', 'a', 1)])
     dataset = Dataset(
         {
             'x': ['B', 'A'],
             'y': ['b', 'a'],
             'z': [[2, np.NaN], [np.NaN, 1]]
         },
         kdims=['x', 'y'],
         vdims=['z'])
     self.assertEqual(hmap.gridded, dataset)
Exemplo n.º 3
0
 def test_heatmap_construct(self):
     hmap = HeatMap([('A', 'a', 1), ('B', 'b', 2)])
     dataset = Dataset(
         {
             'x': ['A', 'B'],
             'y': ['a', 'b'],
             'z': [[1, np.NaN], [np.NaN, 2]]
         },
         kdims=['x', 'y'],
         vdims=['z'])
     self.assertEqual(hmap.gridded, dataset)
Exemplo n.º 4
0
 def test_heatmap_construct_partial_sorted(self):
     data = [(chr(65 + i), chr(97 + j), i * j) for i in range(3)
             for j in [2, 0, 1] if i != j]
     hmap = HeatMap(data)
     dataset = Dataset(
         {
             'x': ['A', 'B', 'C'],
             'y': ['c', 'b', 'a'],
             'z': [[0, 2, np.NaN], [np.NaN, 0, 0], [0, np.NaN, 2]]
         },
         kdims=['x', 'y'],
         vdims=['z'],
         label='unique')
     self.assertEqual(hmap.gridded, dataset)
Exemplo n.º 5
0
 def test_heatmap_string_signature(self):
     heatmap = HeatMap([], ['a', 'b'], 'c')
     self.assertEqual(heatmap.kdims, [Dimension('a'), Dimension('b')])
     self.assertEqual(heatmap.vdims, [Dimension('c')])
        def view(self):
            if self.reordering == "none":
                result = to_liquid(df_original.copy().values)

                hm = HeatMap(result).opts(tools=['tap', 'box_select', 'hover'],
                                          active_tools=['box_select'],
                                          height=self.height,
                                          width=self.width,
                                          xaxis=None,
                                          yaxis=None,
                                          cmap=self.color_palette,
                                          colorbar=True,
                                          toolbar='above')

                # FOR LINKING TESTING
                # current_data = hm.data
                # table = Table(current_data)
                # table.opts(height=500)
                #
                # if self.show_only_selection:
                #     SelectedDataLink(hm, table)
                # else:
                #     SelectLink(hm, table)
                #     SelectLink(table, hm)

                # return pn.Row(hm, table)
                return hm

            else:
                inverted = invert_df(df.copy())

                res_order, res_linkage = compute_serial_matrix(
                    inverted,
                    self.reordering,
                    dist_metric=self.metric,
                    calc_pdist=self.calc_pdist)

                reordered_matrix_col = reordercol(inverted, res_order)
                reordered_matrix = reorderrow(reordered_matrix_col, res_order)
                dis_to_similarity(reordered_matrix)

                result = to_liquid_2(reordered_matrix, inverted, res_order)

                hm = HeatMap(result).opts(tools=['tap', 'box_select', 'hover'],
                                          active_tools=['box_select'],
                                          height=self.height,
                                          width=self.width,
                                          xaxis=None,
                                          yaxis=None,
                                          cmap=self.color_palette,
                                          colorbar=True,
                                          toolbar='above')
                # FOR LINKING TESTING
                # table = Table(hm.data)
                # table.opts(height=500)
                #
                # if self.show_only_selection:
                #     SelectedDataLink(hm, table)
                # else:
                #     SelectLink(hm, table)
                #     SelectLink(table, hm)
                #
                # return pn.Row(hm, table)
                return hm