From fc7baaac7bdac93bbda22e978564906bd8677e18 Mon Sep 17 00:00:00 2001
From: Mark Driver <mdd31@cam.ac.uk>
Date: Thu, 6 Jul 2017 19:50:34 +0100
Subject: [PATCH] continued working on functions.

---
 .../polynomialdataanalysis.py                 | 29 +++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/solventmapcreator/polynomialanalysis/polynomialdataanalysis.py b/solventmapcreator/polynomialanalysis/polynomialdataanalysis.py
index 5858d98..615a1fe 100644
--- a/solventmapcreator/polynomialanalysis/polynomialdataanalysis.py
+++ b/solventmapcreator/polynomialanalysis/polynomialdataanalysis.py
@@ -16,7 +16,6 @@ LOGGER = logging.getLogger(__name__)
 LOGGER.setLevel(logging.WARN)
 
 
-
 def get_total_by_fit_order(best_order_dict):
     """This returns a tuple containing the order, and also the number of
     occurances where the corresponding order provided the best fit.
@@ -24,7 +23,33 @@ def get_total_by_fit_order(best_order_dict):
     order_tuple = tuple(sorted(best_order_dict.keys()))
     number_by_order = tuple([len(best_order_dict[order]) for order in order_tuple])
     return (order_tuple, number_by_order)
-    
+
+def extract_lists_by_order_of_alt_metric(solvent_id_list, solvent_ids_by_order):
+    """This returns a dictionary where the solvent IDs are sorted based on the
+    best order from the alternate metric.
+    """
+    solvent_id_alt_metric = {}
+    for order in solvent_ids_by_order.keys():
+        metric_ids_for_order = []
+        for solvent_id in solvent_id_list:
+            if solvent_id in solvent_ids_by_order[order]:
+                metric_ids_for_order.append(solvent_id)
+        solvent_id_alt_metric[order] = metric_ids_for_order
+    return solvent_id_alt_metric
+
+def get_solvent_id_by_order(best_order_dict):
+    """This gets the values from the best order dict and returns lists of
+    solvent IDs group by the order of the polynomial that gives the best fit.
+    """
+    solvent_ids_by_order = {}
+    for order in best_order_dict.keys():
+        solvent_ids_by_order[order] = get_solvent_id(best_order_dict[order])
+    return solvent_ids_by_order
+
+def get_solvent_id(order_info_list):
+    """This gets the values from the order info list about which solvents are in this set.
+    """
+    return [order_info_list[i][0] for i in range(len(order_info_list))]
 
 def get_best_poly_fit_rmse(polynomial_dict_by_solvent_id):
     """This returns a dict with tuples containing the information.
-- 
GitLab