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

Conversation

Projects
None yet
1 participant
@sdrave
Copy link
Member

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 added some commits Oct 11, 2016

move DiskVectorArray to the graveyard
The current implementation would have to be updated to the
new VectorArrayInterface. A complete rewrite would probably
be a better idea, however.
@sdrave

This comment has been minimized.

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.)

@sdrave sdrave merged commit 1866f73 into master Oct 19, 2016

3 of 4 checks passed

coverage/coveralls Coverage decreased (-0.2%) to 81.532%
Details
code-quality/landscape Landscape has completed the code quality check
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@sdrave sdrave deleted the indexing branch Dec 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment