Skip to content

Commit

Permalink
root writer: skip defining histogram bins for non-numeric y values
Browse files Browse the repository at this point in the history
* 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 <graeme.watt@durham.ac.uk>
  • Loading branch information
GraemeWatt committed Jun 5, 2019
1 parent 3542714 commit 18bb94e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hepdata_converter/writers/root_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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]:
Expand Down

0 comments on commit 18bb94e

Please sign in to comment.