From bedd1f8332f390ca0586f1c297a07db138a429e8 Mon Sep 17 00:00:00 2001
From: Mark Driver <mdd31@cam.ac.uk>
Date: Wed, 26 Jul 2017 23:21:32 +0100
Subject: [PATCH] updated input data for solvation plot to match required
 format for matplotlib contour plot function.

---
 .../solvationmapgenerator.py                   |  4 ++--
 .../solvationplotinformation.py                |  6 +++---
 .../solvationmapgeneratortest.py               | 12 ++++++------
 .../solvationplotinformationtest.py            | 18 +++++++++---------
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/solventmapcreator/solvationcalculation/solvationmapgenerator.py b/solventmapcreator/solvationcalculation/solvationmapgenerator.py
index 02472c1..f129910 100644
--- a/solventmapcreator/solvationcalculation/solvationmapgenerator.py
+++ b/solventmapcreator/solvationcalculation/solvationmapgenerator.py
@@ -31,9 +31,9 @@ def create_solvation_plot(epsilon_i_list, epsilon_j_list,
     return plot_and_write_contour_map(input_data, **kwargs)
 
 def plot_and_write_contour_map(input_data, **kwargs):
-    """This creates and plots a contour map wit hthe input given.
+    """This creates and plots a contour map wit the input given.
     """
-    return plottinginput.create_and_write_contour_plot(input_data, **kwargs)
+    return plottinginput.create_and_write_contour_plot(input_data, kwargs.get("fileformat", "eps"))
 
 def create_plot_input_data_from_files(epsilon_i_list, epsilon_j_list,
                                       solvent_filename, solvent_id,
diff --git a/solventmapcreator/solvationcalculation/solvationplotinformation.py b/solventmapcreator/solvationcalculation/solvationplotinformation.py
index a7db1e4..9122ea9 100644
--- a/solventmapcreator/solvationcalculation/solvationplotinformation.py
+++ b/solventmapcreator/solvationcalculation/solvationplotinformation.py
@@ -37,13 +37,13 @@ def create_input_data_values(epsilon_i_list, epsilon_j_list, temperature, theta,
 def get_axis_range(epsilon_i_list, epsilon_j_list):
     """This gets the range of the values in the x and y data.
     """
-    return ((epsilon_i_list.min(), epsilon_i_list.max()),
-            (epsilon_j_list.min(), epsilon_j_list.max()))
+    return (epsilon_i_list.min(), epsilon_i_list.max(),
+            epsilon_j_list.min(), epsilon_j_list.max())
 
 def create_meshgrids(epsilon_i_list, epsilon_j_list):
     """This creates the mesh grids of the x and y coordinates, to get the right dimensionality for plotting.
     """
-    return np.meshgrid(epsilon_i_list, epsilon_j_list)
+    return np.meshgrid(epsilon_i_list, epsilon_j_list, indexing='ij')
 
 def calculate_association_energy_matrix(epsilon_i_list, epsilon_j_list, temperature, theta, polynomial_coefficients):
     """This creates the matrix of association constants.
diff --git a/solventmapcreator/test/solvationcalculationtest/solvationmapgeneratortest.py b/solventmapcreator/test/solvationcalculationtest/solvationmapgeneratortest.py
index 856a75e..f31bf33 100644
--- a/solventmapcreator/test/solvationcalculationtest/solvationmapgeneratortest.py
+++ b/solventmapcreator/test/solvationcalculationtest/solvationmapgeneratortest.py
@@ -37,13 +37,13 @@ class SolvationMapGeneratorTestCase(unittest.TestCase):
     def test_create_plot_input_data_from_files(self):
         """Test to see if expected dictionary is produced.
         """
-        expected_dict = {'x_data':np.array([[0, 1, 2],[0, 1, 2]]),
-                         'y_data':np.array([[0, 0, 0], [1, 1, 1]]),
+        expected_dict = {'x_data':np.array([[0, 0], [1, 1], [2, 2]]),
+                         'y_data':np.array([[0, 1], [0, 1], [0, 1]]),
                          'z_data':np.array([[-4.532289, -3.46086],
                                             [-3.46086, -1.671915],
                                             [-2.389432,  0.06058]]),
                          "x_label":"\\beta", "y_label":"\\alpha",
-                         "plot_axis_range":((0.0, 2.0), (0.0, 1.0)),
+                         "plot_axis_range":(0.0, 2.0, 0.0, 1.0),
                          "figure_label":"water_solv_map"}
         actual_dict = solvationmapgenerator.create_plot_input_data_from_files(self.epsilon_i_list, self.epsilon_j_list,
                                                                               "resources/watersolvent.xml", "water",
@@ -75,13 +75,13 @@ class SolvationMapGeneratorTestCase(unittest.TestCase):
     def test_create_plot_input_data(self):
         """Test to see if expected input data is returned.
         """
-        expected_dict = {'x_data':np.array([[0, 1, 2],[0, 1, 2]]),
-                         'y_data':np.array([[0, 0, 0], [1, 1, 1]]),
+        expected_dict = {'x_data':np.array([[0, 0], [1, 1], [2, 2]]),
+                         'y_data':np.array([[0, 1], [0, 1], [0, 1]]),
                          'z_data':np.array([[-4.004792, -3.004792],
                                             [-3.004792, -1.250065],
                                             [-2.004792,  0.454246]]),
                          "x_label":"x_label", "y_label":"y_label",
-                         "plot_axis_range":((0.0, 2.0), (0.0, 1.0))}
+                         "plot_axis_range":(0.0, 2.0, 0.0, 1.0)}
         actual_dict = solvationmapgenerator.create_plot_input_data(self.epsilon_i_list,
                                                                    self.epsilon_j_list,
                                                                    298.0, 1.0,
diff --git a/solventmapcreator/test/solvationcalculationtest/solvationplotinformationtest.py b/solventmapcreator/test/solvationcalculationtest/solvationplotinformationtest.py
index 569bd61..7000a50 100644
--- a/solventmapcreator/test/solvationcalculationtest/solvationplotinformationtest.py
+++ b/solventmapcreator/test/solvationcalculationtest/solvationplotinformationtest.py
@@ -31,13 +31,13 @@ class SolvationPlotInformationTestCase(unittest.TestCase):
     def test_create_plot_input_data(self):
         """Test to see if expected dictionary is produced.
         """
-        expected_dict = {'x_data':np.array([[0, 1, 2],[0, 1, 2]]),
-                         'y_data':np.array([[0, 0, 0], [1, 1, 1]]),
+        expected_dict = {'x_data':np.array([[0, 0], [1, 1], [2, 2]]),
+                         'y_data':np.array([[0, 1], [0, 1], [0, 1]]),
                          'z_data':np.array([[-4.004792, -3.004792],
                                             [-3.004792, -1.250065],
                                             [-2.004792,  0.454246]]),
                          "x_label":"x_label", "y_label":"y_label",
-                         "plot_axis_range":((0.0, 2.0), (0.0, 1.0))}
+                         "plot_axis_range":(0.0, 2.0, 0.0, 1.0)}
         actual_dict = solvationplotinformation.create_plot_input_data(self.epsilon_i_list, self.epsilon_j_list, 298.0, 1.0, np.array([0.5, 1.0]), "x_label", "y_label")
         self.assertListEqual(sorted(expected_dict.keys()), sorted(actual_dict.keys()))
         for key in expected_dict.keys():
@@ -51,7 +51,7 @@ class SolvationPlotInformationTestCase(unittest.TestCase):
         """Test to see if expected dictionary is produced.
         """
         expected_dict = {"x_label":"x_label", "y_label":"y_label",
-                         "plot_axis_range":((0.0, 2.0), (0.0, 1.0))}
+                         "plot_axis_range":(0.0, 2.0, 0.0, 1.0)}
         actual_dict = solvationplotinformation.create_input_data_labels(self.epsilon_i_list, self.epsilon_j_list, "x_label", "y_label")
         self.assertListEqual(sorted(expected_dict.keys()), sorted(actual_dict.keys()))
         for key in expected_dict.keys():
@@ -62,8 +62,8 @@ class SolvationPlotInformationTestCase(unittest.TestCase):
     def test_create_input_data_values(self):
         """Test to see if expected dictionary is produced.
         """
-        expected_dict = {'x_data':np.array([[0, 1, 2],[0, 1, 2]]),
-                         'y_data':np.array([[0, 0, 0], [1, 1, 1]]),
+        expected_dict = {'x_data':np.array([[0, 0], [1, 1], [2, 2]]),
+                         'y_data':np.array([[0, 1], [0, 1], [0, 1]]),
                          'z_data':np.array([[-4.004792, -3.004792],
                                             [-3.004792, -1.250065],
                                             [-2.004792,  0.454246]])}
@@ -74,14 +74,14 @@ class SolvationPlotInformationTestCase(unittest.TestCase):
     def test_get_axis_range(self):
         """Test to see if expected axis range is returned.
         """
-        expected_range = ((0.0, 2.0),(0.0, 1.0))
+        expected_range = (0.0, 2.0, 0.0, 1.0)
         actual_range = solvationplotinformation.get_axis_range(self.epsilon_i_list, self.epsilon_j_list)
         np.testing.assert_array_almost_equal(np.array(expected_range), np.array(actual_range))
     def test_create_meshgrids(self):
         """Test to see if expected arrays are produced.
         """
-        expected_x = np.array([[0, 1, 2],[0, 1, 2]])
-        expected_y = np.array([[0, 0, 0], [1, 1, 1]])
+        expected_x = np.array([[0, 0], [1, 1], [2, 2]])
+        expected_y = np.array([[0, 1], [0, 1], [0, 1]])
         actual_x, actual_y = solvationplotinformation.create_meshgrids(self.epsilon_i_list, self.epsilon_j_list)
         np.testing.assert_array_almost_equal(expected_x, actual_x)
         np.testing.assert_array_almost_equal(expected_y, actual_y)
-- 
GitLab