本文整理汇总了Python中datarray.datarray.DataArray.squeeze方法的典型用法代码示例。如果您正苦于以下问题:Python DataArray.squeeze方法的具体用法?Python DataArray.squeeze怎么用?Python DataArray.squeeze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datarray.datarray.DataArray
的用法示例。
在下文中一共展示了DataArray.squeeze方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_squeeze
# 需要导入模块: from datarray.datarray import DataArray [as 别名]
# 或者: from datarray.datarray.DataArray import squeeze [as 别名]
def test_squeeze():
"Test squeeze method"
d = DataArray(np.random.randn(3, 2, 9), "xyz")
d2 = d[None, :, None, :, :, None]
nt.assert_true(d2.shape == (1, 3, 1, 2, 9, 1), "newaxis slicing failed")
d3 = d.squeeze()
nt.assert_true(d3.shape == d.shape, "squeezing length-1 dimensions failed")
nt.assert_true(d3.names == d.names, "Axes got lost in squeeze")
示例2: test_squeeze
# 需要导入模块: from datarray.datarray import DataArray [as 别名]
# 或者: from datarray.datarray.DataArray import squeeze [as 别名]
def test_squeeze():
"Test squeeze method"
d = DataArray(np.random.randn(3,2,9), 'xyz')
d2 = d[None,:,None,:,:,None]
yield nt.assert_true, d2.shape == (1,3,1,2,9,1), 'newaxis slicing failed'
d3 = d.squeeze()
yield nt.assert_true, d3.shape == d.shape, \
'squeezing length-1 dimensions failed'
yield nt.assert_true, d3.labels == d.labels, 'Axes got lost in squeeze'