本文整理汇总了Python中datarray.datarray.DataArray.swapaxes方法的典型用法代码示例。如果您正苦于以下问题:Python DataArray.swapaxes方法的具体用法?Python DataArray.swapaxes怎么用?Python DataArray.swapaxes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datarray.datarray.DataArray
的用法示例。
在下文中一共展示了DataArray.swapaxes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_swapaxes
# 需要导入模块: from datarray.datarray import DataArray [as 别名]
# 或者: from datarray.datarray.DataArray import swapaxes [as 别名]
def test_swapaxes():
n_arr = np.random.randn(2,4,3)
a = DataArray(n_arr, 'xyz')
b = a.swapaxes('x', 'z')
c = DataArray(n_arr.transpose(2,1,0), 'zyx')
yield nt.assert_true, (c==b).all(), 'data not equal in swapaxes test'
for ax1, ax2 in zip(b.axes, c.axes):
yield nt.assert_true, ax1==ax2, 'axes not equal in swapaxes test'
示例2: test_swapaxes
# 需要导入模块: from datarray.datarray import DataArray [as 别名]
# 或者: from datarray.datarray.DataArray import swapaxes [as 别名]
def test_swapaxes():
n_arr = np.random.randn(2, 4, 3)
a = DataArray(n_arr, "xyz")
b = a.swapaxes("x", "z")
c = DataArray(n_arr.transpose(2, 1, 0), "zyx")
nt.assert_true((c == b).all(), "data not equal in swapaxes test")
for ax1, ax2 in zip(b.axes, c.axes):
nt.assert_true(ax1 == ax2, "axes not equal in swapaxes test")