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 PR removes numeric in-place operations from
expressions.py
(string+=
ops are left in tact).The motivation for this PR is a change in
numpy
's behavior, illustrated below:Prior to numpy
1.10
(I believe), numpy was happy to re-cast arrays to arrays of a different type, in-place.This becomes a problem for us in situations like:
Maybe not necessary ...
Really, people shouldn't be using
np.array
, they should be using ourMathArray
. It turns out that this change in numpy behavior is not a problem forMathArray
since it's "in-place" operations (__iadd__
, etc) are fake: they return new objects instead of modifying the original.Still, this inconsistency in behavior makes me uncomfortable and I'd rather get rid of it. Maybe someone in the future will make
MathArray
's__iadd__
method truly in-place, or might find a reason to use numpy variables directly, or ...(Footnote: discoved while trying to fix test https://github.com/mitodl/mitx-grading-library/blob/32a66e19b1ea0b7939e0e88adc9edf4de6a3fe3c/tests/helpers/calc/test_expressions.py#L150)