From 18bb94ec6a5489f8731b3b818039a1723950e48d Mon Sep 17 00:00:00 2001 From: Graeme Watt Date: Wed, 5 Jun 2019 17:44:51 +0100 Subject: [PATCH] root writer: skip defining histogram bins for non-numeric y values * Skip defining bins for non-numeric y values unless alphanumeric bins. * Needed for ROOT export of https://www.hepdata.net/record/ins1392456 Signed-off-by: Graeme Watt --- hepdata_converter/writers/root_writer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hepdata_converter/writers/root_writer.py b/hepdata_converter/writers/root_writer.py index 2b6a1ec..ce06f9b 100644 --- a/hepdata_converter/writers/root_writer.py +++ b/hepdata_converter/writers/root_writer.py @@ -40,11 +40,15 @@ def match(cls, independent_variables_map, dependent_variable): def _create_empty_hist(self, dependent_var_title, index, yval): + is_number_list = self.is_number_var(self.dependent_variable) + xval = [] for i in xrange(self.dim): xval.append([]) i_var = self.independent_variables[i]['values'] - for x in i_var: + for ix, x in enumerate(i_var): + if not is_number_list[ix] and 'labels' not in self.independent_variables[i]: + continue # skip defining bins for non-numeric y values unless alphanumeric bin labels are present if x['low'] not in xval[i]: xval[i].append(x['low']) if x['high'] not in xval[i]: @@ -235,7 +239,9 @@ def create_objects(self): for i in xrange(self.dim): xval.append([]) i_var = self.independent_variables[i]['values'] - for x in i_var: + for ix, x in enumerate(i_var): + if not is_number_list[ix] and 'labels' not in self.independent_variables[i]: + continue # skip defining bins for non-numeric y values unless alphanumeric bin labels are present if x['low'] not in xval[i]: xval[i].append(x['low']) if x['high'] not in xval[i]: