Skip to content
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

Handle floating point numbers in update_qai.py #1075

Merged
merged 1 commit into from
Apr 12, 2024
Merged

Conversation

Donaim
Copy link
Member

@Donaim Donaim commented Apr 12, 2024

This commit addresses an issue in update_qai.py where the script failed when encountering floating point numbers instead of exact integers, which became apparent when running the script independently outside of its typical pipeline.

The problem lies in the strict interpretation of certain numeric fields (namely 'count', 'demultiplexed', 'v3loop', 'on.score', 'off.score', 'min.coverage', 'which.key.pos') as integers. When a floating point number was encountered in one of these fields, it created a ValueError, terminating the execution of the script. This falls under the category of 'data type mismatch' problems, when the data provided to a function or operation doesn't match the expected type.

To fix this, a new function read_int has been introduced which tries to convert numeric inputs into integers but tolerates floating point numbers without automatic truncation or rounding errors. If a number cannot be converted exactly into an integer, a ValueError is raised. This modification improves the script's flexibility and resilience, now accommodating floating point numbers in these specified fields without error.

Data type mismatch issues, where the data provided to a function or operation doesn't match the expected type, can pose significant challenges in script execution. A common example of this error surfaces when a function expressly expects an integer input but receives a floating-point number. At its core, this problem arises from the inherent rigidity of type systems in programming, which while ensuring data consistency and integrity, can sometimes limit flexibility.

This particular revision serves as a practical example of addressing the data type mismatch problem, showcasing that with mindful updates, it's possible to maintain data integrity while allowing for greater operational flexibility in our codebases. It highlights that while strict typing can prevent certain types of errors, it's equally important to ensure our code is resilient to variations in data type, especially when interfacing with varying data sources or when scripts run in isolation outside their regular pipelines.

This commit addresses an issue in `update_qai.py` where the script
failed when encountering floating point numbers instead of exact
integers, which became apparent when running the script independently
outside of its typical pipeline.

The problem lies in the strict interpretation of certain numeric
fields (namely 'count', 'demultiplexed', 'v3loop', 'on.score',
'off.score', 'min.coverage', 'which.key.pos') as integers. When a
floating point number was encountered in one of these fields, it
created a ValueError, terminating the execution of the script. This
falls under the category of 'data type mismatch' problems, when the
data provided to a function or operation doesn't match the expected
type.

To fix this, a new function `read_int` has been introduced which tries
to convert numeric inputs into integers but tolerates floating point
numbers without automatic truncation or rounding errors. If a number
cannot be converted exactly into an integer, a ValueError is
raised. This modification improves the script's flexibility and
resilience, now accommodating floating point numbers in these
specified fields without error.

Data type mismatch issues, where the data provided to a function or
operation doesn't match the expected type, can pose significant
challenges in script execution. A common example of this error
surfaces when a function expressly expects an integer input but
receives a floating-point number. At its core, this problem arises
from the inherent rigidity of type systems in programming, which while
ensuring data consistency and integrity, can sometimes limit
flexibility.

This particular revision serves as a practical example of addressing
the data type mismatch problem, showcasing that with mindful updates,
it's possible to maintain data integrity while allowing for greater
operational flexibility in our codebases. It highlights that while
strict typing can prevent certain types of errors, it's equally
important to ensure our code is resilient to variations in data type,
especially when interfacing with varying data sources or when scripts
run in isolation outside their regular pipelines.
@Donaim Donaim merged commit 87441bc into master Apr 12, 2024
1 check passed
@Donaim Donaim deleted the tolerate-inexact-ints branch April 12, 2024 19:25
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.

1 participant