You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#2. The updates to num-bigint and num-rational are necessary to match the versions expected by PyO3. Note that this bumps the required Python version from 3.5 to 3.7 (released 2018-06-27) and the MSRV from nightly-2020-01-21 to 1.40.0 (released 2019-12-19).
This broke the python tests. PyNumberProtocol appears to have automatically implemented the __radd__-like functions in terms of the __add__-like functions, switching to just plain methods broke that.
test commands:
pip3 install .
python3 -m unittest
unittest output:
.E...E......E.E..E...
======================================================================
ERROR: test_add (tests.test_real_algebraic_number.TestRealAlgebraicNumber)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jacob/projects/algebraics/tests/test_real_algebraic_number.py", line 188, in test_add
self.assertEqual(1 + RealAlgebraicNumber(2), 3)
TypeError: unsupported operand type(s) for +: 'int' and 'algebraics.RealAlgebraicNumber'
======================================================================
ERROR: test_div (tests.test_real_algebraic_number.TestRealAlgebraicNumber)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jacob/projects/algebraics/tests/test_real_algebraic_number.py", line 204, in test_div
self.assertEqual(1 / RealAlgebraicNumber(2),
TypeError: unsupported operand type(s) for /: 'int' and 'algebraics.RealAlgebraicNumber'
======================================================================
ERROR: test_mul (tests.test_real_algebraic_number.TestRealAlgebraicNumber)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jacob/projects/algebraics/tests/test_real_algebraic_number.py", line 198, in test_mul
self.assertEqual(1 * RealAlgebraicNumber(2), 2)
TypeError: unsupported operand type(s) for *: 'int' and 'algebraics.RealAlgebraicNumber'
======================================================================
ERROR: test_pow (tests.test_real_algebraic_number.TestRealAlgebraicNumber)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jacob/projects/algebraics/tests/test_real_algebraic_number.py", line 219, in test_pow
self.assertEqual(1 ** RealAlgebraicNumber(2), 1)
TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'algebraics.RealAlgebraicNumber'
======================================================================
ERROR: test_sub (tests.test_real_algebraic_number.TestRealAlgebraicNumber)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/jacob/projects/algebraics/tests/test_real_algebraic_number.py", line 193, in test_sub
self.assertEqual(1 - RealAlgebraicNumber(2), -1)
TypeError: unsupported operand type(s) for -: 'int' and 'algebraics.RealAlgebraicNumber'
----------------------------------------------------------------------
Ran 21 tests in 0.014s
FAILED (errors=5)
Just got the __r*__ methods working with a From<&'_ PyCell<RealAlgebraicNumberPy2>> for SharedNumber impl. I cleaned up the other impls while I was at it, and renamed RealAlgebraicNumberWrapper to SharedNumber to reduce clutter since it appears over 50 times in the file. Also, the Arc::from_mut() in try_arithmetic_helper was useless, since the RealAlgebraicNumberPy2 always holds its own strong reference, so I replaced it with a standard return.
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
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.
Fixes #2. The updates to
num-bigintandnum-rationalare necessary to match the versions expected by PyO3. Note that this bumps the required Python version from 3.5 to 3.7 (released 2018-06-27) and the MSRV from nightly-2020-01-21 to 1.40.0 (released 2019-12-19).