本文整理汇总了Python中matplotlib.mlab.stride_repeat方法的典型用法代码示例。如果您正苦于以下问题:Python mlab.stride_repeat方法的具体用法?Python mlab.stride_repeat怎么用?Python mlab.stride_repeat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.mlab
的用法示例。
在下文中一共展示了mlab.stride_repeat方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stride_ensure_integer_type
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_ensure_integer_type(self):
N = 100
x = np.empty(N + 20, dtype='>f4')
x.fill(np.NaN)
y = x[10:-10]
y.fill(0.3)
# previous to #3845 lead to corrupt access
y_strided = mlab.stride_windows(y, n=33, noverlap=0.6)
assert_array_equal(y_strided, 0.3)
# previous to #3845 lead to corrupt access
y_strided = mlab.stride_windows(y, n=33.3, noverlap=0)
assert_array_equal(y_strided, 0.3)
# even previous to #3845 could not find any problematic
# configuration however, let's be sure it's not accidentally
# introduced
y_strided = mlab.stride_repeat(y, n=33.815)
assert_array_equal(y_strided, 0.3)
示例2: test_stride_repeat_2D_ValueError
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat_2D_ValueError(self):
x = np.arange(10)[np.newaxis]
assert_raises(ValueError, mlab.stride_repeat, x, 5)
示例3: test_stride_repeat_axis_lt_0_ValueError
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat_axis_lt_0_ValueError(self):
x = np.array(0)
assert_raises(ValueError, mlab.stride_repeat, x, 5, axis=-1)
示例4: test_stride_repeat_axis_gt_1_ValueError
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat_axis_gt_1_ValueError(self):
x = np.array(0)
assert_raises(ValueError, mlab.stride_repeat, x, 5, axis=2)
示例5: test_stride_repeat_n_lt_1_ValueError
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat_n_lt_1_ValueError(self):
x = np.arange(10)
assert_raises(ValueError, mlab.stride_repeat, x, 0)
示例6: test_stride_repeat_n1_axis0
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat_n1_axis0(self):
x = np.arange(10)
y = mlab.stride_repeat(x, 1)
assert_equal((1, ) + x.shape, y.shape)
assert_array_equal(x, y.flat)
assert_true(self.get_base(y) is x)
示例7: test_stride_repeat_n5_axis0
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat_n5_axis0(self):
x = np.arange(10)
y = mlab.stride_repeat(x, 5)
yr = np.repeat(x[np.newaxis], 5, axis=0)
assert_equal(yr.shape, y.shape)
assert_array_equal(yr, y)
assert_equal((5, ) + x.shape, y.shape)
assert_true(self.get_base(y) is x)
示例8: test_stride_repeat_n5_axis1
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat_n5_axis1(self):
x = np.arange(10)
y = mlab.stride_repeat(x, 5, axis=1)
yr = np.repeat(x[np.newaxis], 5, axis=0).T
assert_equal(yr.shape, y.shape)
assert_array_equal(yr, y)
assert_equal(x.shape + (5, ), y.shape)
assert_true(self.get_base(y) is x)
示例9: test_stride_repeat_invalid_input_shape
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat_invalid_input_shape(self, shape):
x = np.arange(np.prod(shape)).reshape(shape)
with pytest.raises(ValueError):
mlab.stride_repeat(x, 5)
示例10: test_stride_repeat_invalid_axis
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat_invalid_axis(self, axis):
x = np.array(0)
with pytest.raises(ValueError):
mlab.stride_repeat(x, 5, axis=axis)
示例11: test_stride_repeat_n_lt_1_ValueError
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat_n_lt_1_ValueError(self):
x = np.arange(10)
with pytest.raises(ValueError):
mlab.stride_repeat(x, 0)
示例12: test_stride_repeat
# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import stride_repeat [as 别名]
def test_stride_repeat(self, n, axis):
x = np.arange(10)
y = mlab.stride_repeat(x, n, axis=axis)
expected_shape = [10, 10]
expected_shape[axis] = n
yr = np.repeat(np.expand_dims(x, axis), n, axis=axis)
assert yr.shape == y.shape
assert_array_equal(yr, y)
assert tuple(expected_shape) == y.shape
assert self.get_base(y) is x