Here are the examples of the python api numpy.lib.stride_tricks.as_strided taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : test_stride_tricks.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def as_strided_writeable():
arr = np.ones(10)
view = as_strided(arr, writeable=False)
astert_(not view.flags.writeable)
# Check that writeable also is fine:
view = as_strided(arr, writeable=True)
astert_(view.flags.writeable)
view[...] = 3
astert_array_equal(arr, np.full_like(arr, 3))
# Test that things do not break down for readonly:
arr.flags.writeable = False
view = as_strided(arr, writeable=False)
view = as_strided(arr, writeable=True)
astert_(not view.flags.writeable)
3
View Complete Implementation : test_stride_tricks.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def as_strided_writeable():
arr = np.ones(10)
view = as_strided(arr, writeable=False)
astert_(not view.flags.writeable)
# Check that writeable also is fine:
view = as_strided(arr, writeable=True)
astert_(view.flags.writeable)
view[...] = 3
astert_array_equal(arr, np.full_like(arr, 3))
# Test that things do not break down for readonly:
arr.flags.writeable = False
view = as_strided(arr, writeable=False)
view = as_strided(arr, writeable=True)
astert_(not view.flags.writeable)
3
View Complete Implementation : test_stride_tricks.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def as_strided_writeable():
arr = np.ones(10)
view = as_strided(arr, writeable=False)
astert_(not view.flags.writeable)
# Check that writeable also is fine:
view = as_strided(arr, writeable=True)
astert_(view.flags.writeable)
view[...] = 3
astert_array_equal(arr, np.full_like(arr, 3))
# Test that things do not break down for readonly:
arr.flags.writeable = False
view = as_strided(arr, writeable=False)
view = as_strided(arr, writeable=True)
astert_(not view.flags.writeable)
3
View Complete Implementation : test_stride_tricks.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def as_strided_writeable():
arr = np.ones(10)
view = as_strided(arr, writeable=False)
astert_(not view.flags.writeable)
# Check that writeable also is fine:
view = as_strided(arr, writeable=True)
astert_(view.flags.writeable)
view[...] = 3
astert_array_equal(arr, np.full_like(arr, 3))
# Test that things do not break down for readonly:
arr.flags.writeable = False
view = as_strided(arr, writeable=False)
view = as_strided(arr, writeable=True)
astert_(not view.flags.writeable)
3
View Complete Implementation : test_stride_tricks.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def as_strided_writeable():
arr = np.ones(10)
view = as_strided(arr, writeable=False)
astert_(not view.flags.writeable)
# Check that writeable also is fine:
view = as_strided(arr, writeable=True)
astert_(view.flags.writeable)
view[...] = 3
astert_array_equal(arr, np.full_like(arr, 3))
# Test that things do not break down for readonly:
arr.flags.writeable = False
view = as_strided(arr, writeable=False)
view = as_strided(arr, writeable=True)
astert_(not view.flags.writeable)
3
View Complete Implementation : test_stride_tricks.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def as_strided_writeable():
arr = np.ones(10)
view = as_strided(arr, writeable=False)
astert_(not view.flags.writeable)
# Check that writeable also is fine:
view = as_strided(arr, writeable=True)
astert_(view.flags.writeable)
view[...] = 3
astert_array_equal(arr, np.full_like(arr, 3))
# Test that things do not break down for readonly:
arr.flags.writeable = False
view = as_strided(arr, writeable=False)
view = as_strided(arr, writeable=True)
astert_(not view.flags.writeable)
3
View Complete Implementation : index_tricks.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def __init__(self, *shape):
if len(shape) == 1 and isinstance(shape[0], tuple):
shape = shape[0]
x = as_strided(_nx.zeros(1), shape=shape,
strides=_nx.zeros_like(shape))
self._it = _nx.nditer(x, flags=['multi_index', 'zerosize_ok'],
order='C')
3
View Complete Implementation : index_tricks.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def __init__(self, *shape):
if len(shape) == 1 and isinstance(shape[0], tuple):
shape = shape[0]
x = as_strided(_nx.zeros(1), shape=shape,
strides=_nx.zeros_like(shape))
self._it = _nx.nditer(x, flags=['multi_index', 'zerosize_ok'],
order='C')
3
View Complete Implementation : index_tricks.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def __init__(self, *shape):
if len(shape) == 1 and isinstance(shape[0], tuple):
shape = shape[0]
x = as_strided(_nx.zeros(1), shape=shape,
strides=_nx.zeros_like(shape))
self._it = _nx.nditer(x, flags=['multi_index', 'zerosize_ok'],
order='C')
3
View Complete Implementation : index_tricks.py
Copyright MIT License
Author : PacktPublishing
Copyright MIT License
Author : PacktPublishing
def __init__(self, *shape):
if len(shape) == 1 and isinstance(shape[0], tuple):
shape = shape[0]
x = as_strided(_nx.zeros(1), shape=shape,
strides=_nx.zeros_like(shape))
self._it = _nx.nditer(x, flags=['multi_index', 'zerosize_ok'],
order='C')