-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
630: Fix unit tests errors with numpy >=1.13 (Fix 577) r=cpascual a=cpascual This PR fixes the 4 test errors/failiures reported in #577 and adds new travis builds with numpy 1.14 3 of the 4 problems are relatively trivial to solve. The remaining one (`test_isreal`) is not so trivial because it involves allowing to compare a *non-dimensionless* quantity against zero. The reason is that `numpy.isreal(x)` essentially does `x.imag !=0` if the `imag` method is implemented in x... and since Quantity reimplements .imag to return units (see #171), the check always returns False if x is a non-dimensionless quantity. As mentioned, this can be solved by allowing comparisons against zero. Actually, this has already been requested in #194, but it was not implemented. In this PR, I implemented the comparison-to-zero feature and provide several new unit tests for it. AFAIK this implementation takes into account the concerns expressed by @hgrecco in #194. But if the feature is not wanted, we can just revert the last 3 commits of this PR and then `test_isreal` will left with an expected failure flag. The rules that I implemented for the comparison-with-zero are: ``` a) comparing against (non-quantity) zero is allowed for any quantity b) comparing against zero-magnitude quantities of incompatible dimensionality raises a Dimensionality error, except for the case of equality, for which it always returns False Notes: 1.- Numpy arrays of zeros are also supported and the comparison rules apply elementwise 2.- In the case of non-multiplicative units, the rules above apply after converting to base units if the autoconvert offset flag is set. Otherwise they raise an OffsetUnitCalculusError. ``` Fixes #577 Co-authored-by: Carlos Pascual <[email protected]>
- Loading branch information
Showing
4 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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