Example #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])
Example #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])
Example #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']))
Example #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'])
Example #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])
Example #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])
Example #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'])
Example #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)
Example #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)
Example #10
0
    def testLengthDoesNotMatch(self):
        metadata = projector_plugin.EmbeddingMetadata(10)

        with self.assertRaises(ValueError):
            metadata.add_column('Labels', [''] * 11)
Example #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"])
Example #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"])