示例#1
0
 def testMultipleColumnsRetrieval(self):
     metadata = projector_plugin.EmbeddingMetadata(3)
     metadata.add_column('Sizes', [1, 2, 3])
     metadata.add_column('Labels', ['a', 'b', 'c'])
     self.assertEqual(metadata.column_names, ['Sizes', 'Labels'])
     self.assertEqual(metadata.name_to_values['Labels'], ['a', 'b', 'c'])
     self.assertEqual(metadata.name_to_values['Sizes'], [1, 2, 3])
示例#2
0
 def testMultipleColumnsRetrieval(self):
     metadata = projector_plugin.EmbeddingMetadata(3)
     metadata.add_column("Sizes", [1, 2, 3])
     metadata.add_column("Labels", ["a", "b", "c"])
     self.assertEqual(metadata.column_names, ["Sizes", "Labels"])
     self.assertEqual(metadata.name_to_values["Labels"], ["a", "b", "c"])
     self.assertEqual(metadata.name_to_values["Sizes"], [1, 2, 3])
示例#3
0
 def testDuplicateColumnName(self):
     metadata = projector_plugin.EmbeddingMetadata(2)
     metadata.add_column('Labels', np.array(['a', 'b']))
     with self.assertRaises(ValueError):
         metadata.add_column('Labels', np.array(['a', 'b']))
示例#4
0
 def testStringNdArrayRetrieval(self):
     metadata = projector_plugin.EmbeddingMetadata(2)
     metadata.add_column('Labels', np.array(['a', 'b']))
     self.assertEqual(metadata.name_to_values['Labels'].tolist(),
                      ['a', 'b'])
示例#5
0
 def testNumericNdArrayRetrieval(self):
     metadata = projector_plugin.EmbeddingMetadata(3)
     metadata.add_column('Labels', np.array([1, 2, 3]))
     self.assertEqual(metadata.name_to_values['Labels'].tolist(), [1, 2, 3])
示例#6
0
 def testNumericListRetrieval(self):
     metadata = projector_plugin.EmbeddingMetadata(3)
     metadata.add_column('Labels', [1, 2, 3])
     self.assertEqual(metadata.name_to_values['Labels'], [1, 2, 3])
示例#7
0
 def testStringListRetrieval(self):
     metadata = projector_plugin.EmbeddingMetadata(3)
     metadata.add_column('Labels', ['a', 'B', 'c'])
     self.assertEqual(metadata.name_to_values['Labels'], ['a', 'B', 'c'])
     self.assertEqual(metadata.column_names, ['Labels'])
示例#8
0
 def testValuesAreListofLists(self):
     metadata = projector_plugin.EmbeddingMetadata(3)
     values = [[1, 2, 3], [4, 5, 6]]
     with self.assertRaises(ValueError):
         metadata.add_column('Labels', values)
示例#9
0
    def testValuesNot1D(self):
        metadata = projector_plugin.EmbeddingMetadata(3)
        values = np.array([[1, 2, 3]])

        with self.assertRaises(ValueError):
            metadata.add_column('Labels', values)
示例#10
0
    def testLengthDoesNotMatch(self):
        metadata = projector_plugin.EmbeddingMetadata(10)

        with self.assertRaises(ValueError):
            metadata.add_column('Labels', [''] * 11)
示例#11
0
 def testStringNdArrayRetrieval(self):
     metadata = projector_plugin.EmbeddingMetadata(2)
     metadata.add_column("Labels", np.array(["a", "b"]))
     self.assertEqual(metadata.name_to_values["Labels"].tolist(),
                      ["a", "b"])
示例#12
0
 def testStringListRetrieval(self):
     metadata = projector_plugin.EmbeddingMetadata(3)
     metadata.add_column("Labels", ["a", "B", "c"])
     self.assertEqual(metadata.name_to_values["Labels"], ["a", "B", "c"])
     self.assertEqual(metadata.column_names, ["Labels"])