FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 0c1a3aaf authored by M.D. Driver's avatar M.D. Driver
Browse files

update names and docstrings to match what is actually read.

parent b8dc8b42
No related branches found
No related tags found
No related merge requests found
......@@ -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.
"""
......
......@@ -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)
......
......@@ -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])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment