Skip to content
Snippets Groups Projects
Commit 9207aaec authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Remove Array.base. Fix strides in Array.view.

parent 64260453
No related branches found
No related tags found
No related merge requests found
...@@ -258,7 +258,7 @@ Constructing :class:`Array` Instances ...@@ -258,7 +258,7 @@ Constructing :class:`Array` Instances
.. versionchanged:: 2011.1 .. versionchanged:: 2011.1
*context* argument was deprecated. *context* argument was deprecated.
.. function:: empty(queue, shape, dtype, order="C", allocator=None, base=None, data=None) .. function:: empty(queue, shape, dtype, order="C", allocator=None, data=None)
A synonym for the :class:`Array` constructor. A synonym for the :class:`Array` constructor.
......
...@@ -216,7 +216,7 @@ class Array(object): ...@@ -216,7 +216,7 @@ class Array(object):
""" """
def __init__(self, cqa, shape, dtype, order="C", allocator=None, def __init__(self, cqa, shape, dtype, order="C", allocator=None,
base=None, data=None, queue=None, strides=None): data=None, queue=None, strides=None):
# {{{ backward compatibility for pre-cqa days # {{{ backward compatibility for pre-cqa days
if isinstance(cqa, cl.CommandQueue): if isinstance(cqa, cl.CommandQueue):
...@@ -305,8 +305,6 @@ class Array(object): ...@@ -305,8 +305,6 @@ class Array(object):
else: else:
self.data = data self.data = data
self.base = base
@property @property
def context(self): def context(self):
return self.data.context return self.data.context
...@@ -322,8 +320,7 @@ class Array(object): ...@@ -322,8 +320,7 @@ class Array(object):
warn("Array.mem_size is deprecated. Use Array.size", warn("Array.mem_size is deprecated. Use Array.size",
DeprecationWarning, stacklevel=2) DeprecationWarning, stacklevel=2)
def _new_with_changes(self, data, shape=None, dtype=None, strides=None, queue=None, def _new_with_changes(self, data, shape=None, dtype=None, strides=None, queue=None):
base=None):
if shape is None: if shape is None:
shape = self.shape shape = self.shape
if dtype is None: if dtype is None:
...@@ -332,17 +329,15 @@ class Array(object): ...@@ -332,17 +329,15 @@ class Array(object):
strides = self.strides strides = self.strides
if queue is None: if queue is None:
queue = self.queue queue = self.queue
if base is None and data is self.data:
base = self
if queue is not None: if queue is not None:
return Array(queue, shape, dtype, return Array(queue, shape, dtype,
allocator=self.allocator, strides=strides, base=base) allocator=self.allocator, strides=strides, data=data)
elif self.allocator is not None: elif self.allocator is not None:
return Array(self.allocator, shape, dtype, queue=queue, return Array(self.allocator, shape, dtype, queue=queue,
strides=strides, base=base) strides=strides, data=data)
else: else:
return Array(self.context, shape, dtype, strides=strides, base=base) return Array(self.context, shape, dtype, strides=strides, data=data)
#@memoize_method FIXME: reenable #@memoize_method FIXME: reenable
def get_sizes(self, queue, kernel_specific_max_wg_size=None): def get_sizes(self, queue, kernel_specific_max_wg_size=None):
...@@ -831,8 +826,12 @@ class Array(object): ...@@ -831,8 +826,12 @@ class Array(object):
raise ValueError("new type not compatible with array") raise ValueError("new type not compatible with array")
shape = self.shape[:-1] + (self.shape[-1] * old_itemsize // itemsize,) shape = self.shape[:-1] + (self.shape[-1] * old_itemsize // itemsize,)
strides = tuple(
s * itemsize // old_itemsize
for s in self.strides)
return self._new_with_changes(data=self.data, shape=shape, dtype=dtype) return self._new_with_changes(data=self.data, shape=shape, dtype=dtype,
strides=strides)
# }} # }}
...@@ -849,7 +848,7 @@ def as_strided(ary, shape=None, strides=None): ...@@ -849,7 +848,7 @@ def as_strided(ary, shape=None, strides=None):
strides = strides or ary.strides strides = strides or ary.strides
return Array(ary.queue, shape, ary.dtype, allocator=ary.allocator, return Array(ary.queue, shape, ary.dtype, allocator=ary.allocator,
base=ary.base, data=ary.data, strides=strides) data=ary.data, strides=strides)
# }}} # }}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment