Fix silent 0.0 return on number parse failure in extract_numbers.py#14
Open
Pran-Ker wants to merge 1 commit intoanthropics:mainfrom
Open
Fix silent 0.0 return on number parse failure in extract_numbers.py#14Pran-Ker wants to merge 1 commit intoanthropics:mainfrom
Pran-Ker wants to merge 1 commit intoanthropics:mainfrom
Conversation
normalize_number() returned 0.0 when float conversion failed, silently converting invalid data into a meaningful financial value. In financial contexts, zero and invalid are very different — a false zero could create incorrect inconsistency groupings or mask data quality issues. Changes: - Return None instead of 0.0 on parse failure - Skip unparseable numbers in extract_numbers() pipeline - Guard division in find_inconsistencies() against None values - Update type annotations to reflect Optional[float]
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.
Summary
normalize_number()returned0.0whenfloat()conversion failed, silently converting invalid input into a meaningful financial valuefind_inconsistencies()or mask data quality issuesNoneon parse failure; unparseable entries are skipped entirely from the extraction pipelineChanges
normalize_number(): ReturnsNoneinstead of0.0onValueError, with updated return typeOptional[float]NumberInstance.normalized: Type updated toOptional[float]to reflect that values may not always be parseableextract_numbers(): Skips entries wherenormalized is Noneso invalid data never enters the pipelinefind_inconsistencies(): AddedNoneguard on the division used for percentage-diff groupingTest plan
extract_numbers.pyon a presentation with valid numbers — output unchanged--checkflag — inconsistency detection still works correctly🤖 Generated with Claude Code