本文整理匯總了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