From 0c1a3aafb036930b3558d8465066fc3dee8a6165 Mon Sep 17 00:00:00 2001 From: Mark Driver <mdd31@cam.ac.uk> Date: Tue, 1 Aug 2017 10:55:12 +0100 Subject: [PATCH] update names and docstrings to match what is actually read. --- .../clusteringanalysis/dendrogramplotting.py | 6 ++++++ solventmapcreator/clusteringanalysis/matrixinput.py | 9 +++++---- .../test/clusteringanalysistest/matrixinputtest.py | 8 ++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/solventmapcreator/clusteringanalysis/dendrogramplotting.py b/solventmapcreator/clusteringanalysis/dendrogramplotting.py index bbe2709..46aee67 100644 --- a/solventmapcreator/clusteringanalysis/dendrogramplotting.py +++ b/solventmapcreator/clusteringanalysis/dendrogramplotting.py @@ -16,6 +16,12 @@ logging.basicConfig() LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.WARN) +def create_dendogram(linkage_matrix, labels, figsize): + """Creates a + """ + dendrogram_plot, dendrogram_plot_axis = create_plot_with_axis(figsize) + cluster.dendrogram(linkage_matrix, labels=labels, ax=dendrogram_plot_axis) + def create_plot_with_axis(figsize): """Function creates plot and plot axis. """ diff --git a/solventmapcreator/clusteringanalysis/matrixinput.py b/solventmapcreator/clusteringanalysis/matrixinput.py index 5e5185d..a29b4f1 100644 --- a/solventmapcreator/clusteringanalysis/matrixinput.py +++ b/solventmapcreator/clusteringanalysis/matrixinput.py @@ -16,20 +16,21 @@ logging.basicConfig() LOGGER = logging.getLogger(__name__) LOGGER.setLevel(logging.WARN) -def parse_similarity_matrix_file_trig_matrix(filename): - """This reads a file into a dictionary, then appends the trigonal dictionary. +def parse_similarity_matrix_file_condensed_matrix(filename): + """This reads a file into a dictionary, then appends the condensed matrix + to the dictionary. """ similarity_matrix_info = parse_similarity_matrix_file(filename) append_condensed_matrix(similarity_matrix_info) return similarity_matrix_info def append_condensed_matrix(similarity_matrix_info): - """This appends a triagonal matrix to the input dict. + """This appends a condensed matrix to the input dict. """ similarity_matrix_info["condensed_matrix"] = convert_to_condensed_matrix(similarity_matrix_info["value_matrix"]) def convert_to_condensed_matrix(similarity_matrix): - """This converts the matrix to a triangular matrix. + """This converts the matrix to a condensed matrix. """ return scidist.squareform(similarity_matrix) diff --git a/solventmapcreator/test/clusteringanalysistest/matrixinputtest.py b/solventmapcreator/test/clusteringanalysistest/matrixinputtest.py index a364bc9..73c57a1 100644 --- a/solventmapcreator/test/clusteringanalysistest/matrixinputtest.py +++ b/solventmapcreator/test/clusteringanalysistest/matrixinputtest.py @@ -31,7 +31,7 @@ class MatrixInputTestCase(unittest.TestCase): """ del self.input_filename del self.expected_dict - def test_parse_similarity_matrix_file_trig_matrix(self): + def test_parse_similarity_matrix_file_condensed_matrix(self): """Test to see if expected dictionary is produced. """ expected_dict = {"labels":["poly_fit", "poly_fit2", "poly_fit3"], @@ -39,14 +39,14 @@ class MatrixInputTestCase(unittest.TestCase): [1.0, 0.0, 3.0], [4.0, 3.0, 0.0]]), "condensed_matrix":np.array([1.0, 4.0, 3.0])} - actual_dict = matrixinput.parse_similarity_matrix_file_trig_matrix(self.input_filename) + actual_dict = matrixinput.parse_similarity_matrix_file_condensed_matrix(self.input_filename) self.assertListEqual(sorted(expected_dict.keys()), sorted(actual_dict.keys())) self.assertListEqual(expected_dict["labels"], actual_dict["labels"]) np.testing.assert_array_almost_equal(expected_dict["value_matrix"], actual_dict["value_matrix"]) np.testing.assert_array_almost_equal(expected_dict["condensed_matrix"], actual_dict["condensed_matrix"]) - def test_append_trigonal_matrix(self): + def test_append_condensed_matrix(self): """Test to see if matrix is appended as expected. """ expected_dict = {"labels":["poly_fit", "poly_fit2", "poly_fit3"], @@ -61,7 +61,7 @@ class MatrixInputTestCase(unittest.TestCase): expected_dict["value_matrix"]) np.testing.assert_array_almost_equal(self.expected_dict["condensed_matrix"], expected_dict["condensed_matrix"]) - def test_convert_to_triangular_matrix(self): + def test_convert_to_condensed_matrix(self): """Test to see if expected matrix is returned. """ expected_matrix = np.array([1.0, 4.0, 3.0]) -- GitLab