Skip to content

fix(model): correctly parse tau flag from LCN sentence files - #9

Open
ThinkerDesigns wants to merge 1 commit into
IBM:mainfrom
ThinkerDesigns:fix/lcn-tau-parsing
Open

fix(model): correctly parse tau flag from LCN sentence files#9
ThinkerDesigns wants to merge 1 commit into
IBM:mainfrom
ThinkerDesigns:fix/lcn-tau-parsing

Conversation

@ThinkerDesigns

Copy link
Copy Markdown

Fixes #5

Bug: The from_lcn() parser in lcn/model.py used bool(string) to parse the tau flag. In Python, bool("False") returns True because any non-empty string is truthy. This meant writing ; tau=False in a sentence file silently set tau = True.

Fix: Split the value on "=" and compare with "true" instead of using bool().

Example — before:

s1: [0.5 <= P(A) <= 0.8 | ; tau=False]   # tau was True (WRONG)

After:

s1: [0.5 <= P(A) <= 0.8 | ; tau=False]   # tau is False (correct)

The parser used bool() on the string after ";", but bool("False")
returns True since any non-empty string is truthy. This means writing
"; tau=False" in a sentence file silently set tau=True instead of False.

Fix: split on "=" to extract the actual boolean value string, then compare
with "true". Fixes IBM#5 which requested debugging this parsing issue.
Copilot AI lite review requested due to automatic review settings August 4, 2026 09:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes boolean parsing of the tau flag when loading LCN sentence files via LCN.from_lcn() in lcn/model.py, ensuring that textual false values don’t incorrectly evaluate to True.

Changes:

  • Replaces bool(string) parsing of the tau suffix with explicit string parsing intended to recognize tau=true / tau=false.
  • Adds inline comments documenting why bool("False") is incorrect for this use case.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lcn/model.py
Comment on lines +895 to 900
tau_str = line[pos+1:].strip()
# Parse "tau=true" or "tau=false" correctly — bool() of any
# non-empty string (including "False") returns True, so we
# must split on "=" to get the actual boolean value.
tau = tau_str.split("=")[1].lower() == 'true'
line = line[:pos]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug the Causal Bounds

2 participants