From 8d0307b700cb9e16758613f736caf1d820b18d1e Mon Sep 17 00:00:00 2001 From: Andreas Heger Date: Wed, 13 Jan 2016 19:22:43 +0000 Subject: [PATCH] coerce docutils params to string --- CGATReportPlugins/Transformer.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/CGATReportPlugins/Transformer.py b/CGATReportPlugins/Transformer.py index e1c6277..5db39fd 100644 --- a/CGATReportPlugins/Transformer.py +++ b/CGATReportPlugins/Transformer.py @@ -1193,16 +1193,25 @@ class TransformerPivot(Transformer): def __init__(self, *args, **kwargs): Transformer.__init__(self, *args, **kwargs) - self.pivot_index = kwargs.get("pivot-index", None) - self.pivot_column = kwargs.get("pivot-column", None) - self.pivot_value = kwargs.get("pivot-value", None) - if self.pivot_index is None: + # convert to string, otherwise it is + # docutils.nodes.reprunicode which does not evaluate as a + # scalar in numpy and causes df.pivot() to fail. + if "pivot-index" not in kwargs: raise ValueError('pivot requires a column to use as index') - if self.pivot_column is None: + else: + self.pivot_index = str(kwargs["pivot-index"]) + + if "pivot-column" not in kwargs: raise ValueError('pivot requires a column to use as column') - if self.pivot_value is None: - raise ValueError('pivot requires a column to use as value') + else: + self.pivot_column = str(kwargs["pivot-column"]) + + if "pivot-value" not in kwargs: + raise ValueError('pivot requires a value to use as value') + else: + self.pivot_value = str(kwargs["pivot-value"]) + def __call__(self, data): ''' returns a melted table'''