Repository navigation
Conversation
`num2bool` fell back to `Piecewise((True, x != 0.0), (False, True))`, where `x != 0.0` is Python's structural inequality, so any non-constant operand of `&&`, `||`, `!` or a `piecewise` condition was treated as `true`. Return `Ne(x, 0)` instead. Also convert symbols (which are sympy `Boolean`s as well) and Boolean-valued `Piecewise` operands. Fixes PEtab-dev#581. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #583 +/- ##
==========================================
+ Coverage 79.48% 79.51% +0.02%
==========================================
Files 70 70
Lines 8278 8278
Branches 1498 1498
==========================================
+ Hits 6580 6582 +2
+ Misses 1207 1206 -1
+ Partials 491 490 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dilpath
approved these changes
Nov 12, 2026
Comment on lines
338
to
341
| if x.is_zero is True: | ||
| return sp.false | ||
| if x.is_zero is False: | ||
| return sp.true |
Member
There was a problem hiding this comment.
Can this be deleted? Since we now have return sp.Ne(x, 0)?
This branch has not been deployed
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.
Fix non-constant numeric expressions used as Booleans (operands of
&&,||,!,piecewiseconditions) being treated as alwaystrue. Per the PEtab v2 spec,0.0isfalseand any other value istrue.num2boolnow returnsNe(x, 0)instead ofPiecewise((True, x != 0.0), (False, True)), wherex != 0.0was Python's structural inequality. It also converts bare symbols (previously passed through, sincesp.Symbolis a sympyBoolean) and Boolean-valuedpiecewiseoperands.For example,
!(x + 1)was parsed to0.0and is now parsed tox + 1 == 0.Fixes #581. The reverse direction (non-constant Booleans in numeric context) is #582 and not addressed here.
🤖 Generated with Claude Code