From 1b74ec63f8f03cc6ead3427d10538fd69cb7b042 Mon Sep 17 00:00:00 2001
From: Jameson Graef Rollins <jrollins@finestructure.net>
Date: Sat, 7 Jul 2018 07:36:53 -0700
Subject: [PATCH] struct: handle lists in txt export

---
 gwinc/struct.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gwinc/struct.py b/gwinc/struct.py
index 0998fba4..5a4c264b 100644
--- a/gwinc/struct.py
+++ b/gwinc/struct.py
@@ -156,7 +156,7 @@ class Struct(object):
         """Return text represenation of Struct, one element per line.
 
         Struct keys use '.' to indicate hierarchy.  The `fmt` keyword
-        controls the formatting of numeric values.  MATLAB code can
+        controls the formatting of numeric values.  MATLAB code can be
         generated with the following parameters:
 
         >>> ifo.to_txt(delimiter=' = ', end=';')
@@ -168,7 +168,9 @@ class Struct(object):
         for k, v in sorted(self.walk()):
             if isinstance(v, (int, float, complex)):
                 base = fmt
-            elif isinstance(v, np.ndarray):
+            elif isinstance(v, (list, np.ndarray)):
+                if isinstance(v, list):
+                    v = np.array(v)
                 v = np.array2string(v, separator='', max_line_width=np.Inf, formatter={'all':lambda x: "{:0.6e} ".format(x)})
                 base = 's'
             else:
-- 
GitLab