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])
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])
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']))
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'])
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])
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])
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'])
def testValuesAreListofLists(self): metadata = projector_plugin.EmbeddingMetadata(3) values = [[1, 2, 3], [4, 5, 6]] with self.assertRaises(ValueError): metadata.add_column('Labels', values)
def testValuesNot1D(self): metadata = projector_plugin.EmbeddingMetadata(3) values = np.array([[1, 2, 3]]) with self.assertRaises(ValueError): metadata.add_column('Labels', values)
def testLengthDoesNotMatch(self): metadata = projector_plugin.EmbeddingMetadata(10) with self.assertRaises(ValueError): metadata.add_column('Labels', [''] * 11)
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"])
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"])