From cf9a0702b6d11499744b711c3d0f351eb5676747 Mon Sep 17 00:00:00 2001
From: "gregory.ashton" <gregory.ashton@ligo.org>
Date: Thu, 13 Oct 2016 18:02:20 +0200
Subject: [PATCH] Forces user to specify idxs for flattening

This is not ideal, it would be better to calculate the idxs for the
keys, but I don't see an easy to way to do it at the momemt.
---
 pyfstat.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pyfstat.py b/pyfstat.py
index 64642db..322a076 100755
--- a/pyfstat.py
+++ b/pyfstat.py
@@ -1599,8 +1599,8 @@ class GridSearch(BaseSearchClass):
         fig.savefig('{}/{}_1D.png'.format(self.outdir, self.label))
 
     def plot_2D(self, xkey, ykey, ax=None, save=True, vmin=None, vmax=None,
-                add_mismatch=None, xN=None, yN=None, flat_keys=[],
-                flatten_method=np.max):
+                add_mismatch=None, xN=None, yN=None, flat_keys=[], 
+                rel_flat_idxs=[], flatten_method=np.max):
         """ Plots a 2D grid of 2F values
 
         Parameters
@@ -1626,8 +1626,8 @@ class GridSearch(BaseSearchClass):
         shape = [len(x), len(y)] + [len(v) for v in flat_vals]
         Z = z.reshape(shape)
 
-        while Z.ndim > 2:
-            Z = flatten_method(Z, axis=-1)
+        if len(rel_flat_idxs) > 0:
+            Z = flatten_method(Z, axis=tuple(rel_flat_idxs))
 
         pax = ax.pcolormesh(X, Y, Z, cmap=plt.cm.viridis, vmin=vmin, vmax=vmax)
         plt.colorbar(pax, ax=ax)
-- 
GitLab