Skip to content

Commit

Permalink
feat: adding more tests for a .T shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriceMUKARAGE committed Aug 2, 2023
1 parent 7216c9d commit 6c5eb23
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,3 +973,26 @@ def test_T_empty():
hist_empty = hist.Hist()
hist_T_empty = hist_empty.T
assert hist_empty == hist_T_empty

def test_T_1D():
# Create a 1D histogram with some data
hist_data_1D = np.array([1, 2, 3, 4, 5])
h_1D = hist.Hist(hist.axis.Regular(5, 0, 1, flow=False), data=hist_data_1D)

assert h_1D.T.values() == approx(h_1D.values().T)
assert h_1D.T.axes[0] == h_1D.axes[0]

def test_T_3D():
# Create a 3D histogram with some data
hist_data_3D = np.random.rand(1, 3, 4)
h_3D = hist.Hist(
hist.axis.Regular(2, 0, 1, flow=False),
hist.axis.Regular(3, 2, 3, flow=False),
hist.axis.Regular(4, 5, 6, flow=False),
data=hist_data_3D,
)

assert h_3D.T.values() == approx(h_3D.values().T)
assert h_3D.T.axes[0] == h_3D.axes[2]
assert h_3D.T.axes[1] == h_3D.axes[1]
assert h_3D.T.axes[2] == h_3D.axes[0]

0 comments on commit 6c5eb23

Please sign in to comment.