Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce VectorArray views #299

Merged
merged 7 commits into from Oct 19, 2016
Merged

Introduce VectorArray views #299

merged 7 commits into from Oct 19, 2016

Conversation

sdrave
Copy link
Member

@sdrave sdrave commented Oct 16, 2016

This pull requests removes the ind (o_ind, x_ind) arguments from the VectorArrayInterface and OperatorInterface. Instead, VectorArrays now implement __getitem__ and, thus, can be indexed. Valid indices are positve or negative integers, slices, as well as lists and one-dimensional Numpy arrays of positive or negative integers (as usual, negative numbers count from the end of the array).

In all cases, a new VectorArray of the same space is returned which acts as a view into the original array. As such, calling scal and axpy on the returned array will modify the original array. Apart from the fact, that views cannot be appended to and no vectors can be removed, the view fully satisfies the VectorArrayInterface. While the original array can be appended to, while views into it exist, removing vectors from an array with views will lead to undefined behavior of the views. In general, views should be seen as short-lived objects to facilitate indexing or pass a sub-array to an Operator.
The new is_view attribute signifies whether an VectorArray is a view or not. The remove method has been replaced by __delitem__ which is more convenient when dealing with slices.

Some smaller changes:

  • I have moved DiskVectorArray to the graveyard, as updating the current implementation
    seems not worth the effort. I would hope to have a better implementation until the next release.
  • I have simplified the signature of NumpyVectorArray.__init__ to only accept the array data
    and an optional copy argument (I feel that the other arguments were confusing and unused).
  • I have made some performance improvements to NumpyVectorArray which make the code
    somewhat more complicated but strongly improve performance for small arrays.

This pull request addresses #227.

@sdrave
Copy link
Member Author

sdrave commented Oct 16, 2016

@renemilk, @ftalbrecht, @pmli, this is an important change, which will affect everybody. Please have a close look! (See #227 for some more discussion.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant