scikit-hep / hist

Histogramming for analysis powered by boost-histogram
https://hist.readthedocs.io
BSD 3-Clause "New" or "Revised" License
128 stars 25 forks source link

[FEATURE] .T shortcut for .project(1,0) of a 2D hist #513

Closed andrzejnovak closed 1 year ago

andrzejnovak commented 1 year ago

I was trying to flip x/y axes of a 2d hist and was pointed to #133 after initially trying some guesswork. One of the things I reached for was a .T method which incidentally is also mentioned in #133. Is that perhaps enough of a suggestion that this would be a good API shortcut to have?

henryiii commented 1 year ago

@fabriceMUKARAGE, could you do this? It would be something like this:

@property
def T(self) -> Self:
    return self.project(*reversed(range(self.ndim)))

Plus a test or two.

fabriceMUKARAGE commented 1 year ago

@henryiii sure, noted! I am going to work on that.