CARVIEW |
Navigation Menu
-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(core): make comparisons of Integer(0) and Float(0) consistent. #26948
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
fix(core): make comparisons of Integer(0) and Float(0) consistent. #26948
Conversation
Previously Floats were made to compare unequal to Rational but there was still a special case check in Rational.__eq__ for the rhs to be falsey. This commit removes that check to make comparisons between Rational and Float always False including in the case of Integer(0) == Float(0).
✅ Hi, I am the SymPy bot. I'm here to help you write a release notes entry. Please read the guide on how to write release notes. Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.13.2. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
Benchmark results from GitHub Actions Lower numbers are good, higher numbers are bad. A ratio less than 1 Significantly changed benchmark results (PR vs master) Significantly changed benchmark results (master vs previous release) | Change | Before [a36a8b23] <sympy-1.12.1^0> | After [863fc643] | Ratio | Benchmark (Parameter) |
|----------|--------------------------------------|---------------------|---------|----------------------------------------------------------------------|
| - | 67.9±1ms | 43.9±0.4ms | 0.65 | integrate.TimeIntegrationRisch02.time_doit_risch(10) |
| + | 18.7±0.2μs | 30.3±0.4μs | 1.62 | integrate.TimeIntegrationRisch03.time_doit(1) |
| - | 5.46±0.03ms | 2.92±0.04ms | 0.54 | logic.LogicSuite.time_load_file |
| - | 73.7±0.1ms | 28.4±0.2ms | 0.39 | polys.TimeGCD_GaussInt.time_op(1, 'dense') |
| - | 26.4±0.3ms | 17.0±0.1ms | 0.65 | polys.TimeGCD_GaussInt.time_op(1, 'expr') |
| - | 72.3±0.8ms | 28.7±0.2ms | 0.4 | polys.TimeGCD_GaussInt.time_op(1, 'sparse') |
| - | 255±1ms | 123±0.9ms | 0.48 | polys.TimeGCD_GaussInt.time_op(2, 'dense') |
| - | 254±1ms | 124±0.7ms | 0.49 | polys.TimeGCD_GaussInt.time_op(2, 'sparse') |
| - | 654±2ms | 368±1ms | 0.56 | polys.TimeGCD_GaussInt.time_op(3, 'dense') |
| - | 662±3ms | 368±2ms | 0.56 | polys.TimeGCD_GaussInt.time_op(3, 'sparse') |
| - | 498±1μs | 296±5μs | 0.59 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(1, 'dense') |
| - | 1.80±0.01ms | 1.08±0.01ms | 0.6 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(2, 'dense') |
| - | 5.82±0.03ms | 3.13±0.04ms | 0.54 | polys.TimeGCD_LinearDenseQuadraticGCD.time_op(3, 'dense') |
| - | 456±6μs | 234±4μs | 0.51 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(1, 'dense') |
| - | 1.47±0.01ms | 692±7μs | 0.47 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(2, 'dense') |
| - | 4.91±0.03ms | 1.70±0.01ms | 0.35 | polys.TimeGCD_QuadraticNonMonicGCD.time_op(3, 'dense') |
| - | 379±4μs | 217±3μs | 0.57 | polys.TimeGCD_SparseGCDHighDegree.time_op(1, 'dense') |
| - | 2.47±0.02ms | 1.27±0.01ms | 0.51 | polys.TimeGCD_SparseGCDHighDegree.time_op(3, 'dense') |
| - | 10.1±0.1ms | 4.43±0.05ms | 0.44 | polys.TimeGCD_SparseGCDHighDegree.time_op(5, 'dense') |
| - | 361±1μs | 174±2μs | 0.48 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(1, 'dense') |
| - | 2.49±0.01ms | 910±4μs | 0.37 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(3, 'dense') |
| - | 9.70±0.2ms | 2.72±0.02ms | 0.28 | polys.TimeGCD_SparseNonMonicQuadratic.time_op(5, 'dense') |
| - | 1.04±0.02ms | 429±3μs | 0.41 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'dense') |
| - | 1.75±0.03ms | 503±1μs | 0.29 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'sparse') |
| - | 5.94±0.05ms | 1.76±0.01ms | 0.3 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'dense') |
| - | 8.38±0.07ms | 1.49±0ms | 0.18 | polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'sparse') |
| - | 287±2μs | 64.6±0.5μs | 0.23 | polys.TimePREM_QuadraticNonMonicGCD.time_op(1, 'sparse') |
| - | 3.36±0.02ms | 386±4μs | 0.12 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'dense') |
| - | 4.01±0.01ms | 280±1μs | 0.07 | polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'sparse') |
| - | 6.85±0.07ms | 1.24±0.01ms | 0.18 | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'dense') |
| - | 8.68±0.2ms | 843±2μs | 0.1 | polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'sparse') |
| - | 5.04±0.02ms | 2.96±0.01ms | 0.59 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(2, 'sparse') |
| - | 12.0±0.08ms | 6.55±0.01ms | 0.55 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'dense') |
| - | 23.2±0.3ms | 9.04±0.02ms | 0.39 | polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'sparse') |
| - | 5.28±0.02ms | 880±10μs | 0.17 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(1, 'sparse') |
| - | 12.6±0.08ms | 7.08±0.06ms | 0.56 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(2, 'sparse') |
| - | 102±0.4ms | 26.1±0.2ms | 0.26 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'dense') |
| - | 167±1ms | 54.0±0.1ms | 0.32 | polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'sparse') |
| - | 174±1μs | 112±0.2μs | 0.65 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(1, 'dense') |
| - | 366±2μs | 212±1μs | 0.58 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(1, 'sparse') |
| - | 4.27±0.06ms | 850±30μs | 0.2 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'dense') |
| - | 5.23±0.1ms | 380±2μs | 0.07 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'sparse') |
| - | 19.6±0.2ms | 2.78±0.01ms | 0.14 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'dense') |
| - | 22.8±0.3ms | 620±2μs | 0.03 | polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'sparse') |
| - | 484±2μs | 136±0.9μs | 0.28 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(1, 'sparse') |
| - | 4.75±0.02ms | 610±4μs | 0.13 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'dense') |
| - | 5.31±0.03ms | 138±2μs | 0.03 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'sparse') |
| - | 12.9±0.04ms | 1.29±0.02ms | 0.1 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'dense') |
| - | 14.0±0.1ms | 142±2μs | 0.01 | polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'sparse') |
| - | 134±0.4μs | 79.1±0.2μs | 0.59 | solve.TimeMatrixOperations.time_rref(3, 0) |
| - | 251±1μs | 90.8±1μs | 0.36 | solve.TimeMatrixOperations.time_rref(4, 0) |
| - | 24.5±0.1ms | 10.4±0.04ms | 0.42 | solve.TimeSolveLinSys189x49.time_solve_lin_sys |
| - | 28.3±0.2ms | 15.4±0.2ms | 0.54 | solve.TimeSparseSystem.time_linsolve_Aaug(20) |
| - | 54.2±0.3ms | 25.2±0.2ms | 0.47 | solve.TimeSparseSystem.time_linsolve_Aaug(30) |
| - | 28.2±0.2ms | 15.6±0.1ms | 0.55 | solve.TimeSparseSystem.time_linsolve_Ab(20) |
| - | 54.4±0.5ms | 24.8±0.3ms | 0.46 | solve.TimeSparseSystem.time_linsolve_Ab(30) |
Full benchmark results can be found as artifacts in GitHub Actions |
SymPy 1.13.2 no longer considers `Integer(0) == Float(0.0)` https://github.com/sympy/sympy/wiki/release-notes-for-1.13.2 sympy/sympy#26948
Previously Floats were made to compare unequal to Rational but there was still a special case check in Rational.eq for the rhs to be falsey. This commit removes that check to make comparisons between Rational and Float always False including in the case of Integer(0) == Float(0).
References to other Issues or PRs
Backport of gh-26910
Brief description of what is fixed or changed
Other comments
Release Notes
Rational(n) != Float(n)
but this was inconsistent in the case ofRational(0) == Float(0)
andFloat(0) == Rational(0)
which gave different results. Now both giveFalse
.