Conversation
The current implementation would have to be updated to the new VectorArrayInterface. A complete rewrite would probably be a better idea, however.
Member
Author
|
@renemilk, @ftalbrecht, @pmli, this is an important change, which will affect everybody. Please have a close look! (See #227 for some more discussion.) |
This was referenced Oct 19, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull requests removes the ind (o_ind, x_ind) arguments from the
VectorArrayInterfaceandOperatorInterface. 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
scalandaxpyon the returned array will modify the original array. Apart from the fact, that views cannot beappended to and no vectors can be removed, the view fully satisfies theVectorArrayInterface. 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_viewattribute signifies whether an VectorArray is a view or not. Theremovemethod has been replaced by__delitem__which is more convenient when dealing with slices.Some smaller changes:
DiskVectorArrayto the graveyard, as updating the current implementationseems not worth the effort. I would hope to have a better implementation until the next release.
NumpyVectorArray.__init__to only accept the array dataand an optional
copyargument (I feel that the other arguments were confusing and unused).NumpyVectorArraywhich make the codesomewhat more complicated but strongly improve performance for small arrays.
This pull request addresses #227.