Correctly convert units for a stacked histogram#9654
Conversation
| self._process_unit_info(xdata=x[0], kwargs=kwargs) | ||
| newx = [] | ||
| for xi in x: | ||
| newx.append(self.convert_xunits(xi)) |
There was a problem hiding this comment.
x = [self.convert_xunits(xi) for xi in x] ?
|
|
||
| # Process unit information | ||
| # If doing a stacked histogram, the input is a list of datasets, so | ||
| # we need to do the unit conversion individually on eaach dataset |
f66d5c5 to
a09798e
Compare
a09798e to
c02a84d
Compare
efiring
left a comment
There was a problem hiding this comment.
Maybe I'm missing something, but it looks like this is not handling all the cases it should.
| # we need to do the unit conversion individually on each dataset | ||
| if stacked: | ||
| self._process_unit_info(xdata=x[0], kwargs=kwargs) | ||
| x = [self.convert_xunits(xi) for xi in x] |
There was a problem hiding this comment.
I don't understand: it seems to me that the criterion for needing this step is not whether the histogram is stacked, but whether x is a list of datasets.
There was a problem hiding this comment.
I think you're right, I'll change this and add a test for multiple datasets that aren't stacked
efiring
left a comment
There was a problem hiding this comment.
Sorry, I think I see one more detail.
| # Massage 'x' for processing. | ||
| if input_empty: | ||
| x = np.array([[]]) | ||
| x = [np.array([[]])] |
There was a problem hiding this comment.
Too many square brackets--I think this should be a list with one empty 1-D array, not with an empty 2-D array.
Fixes #5898. Hopefully the comment I've added in the code should make it clear what's going on.