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

topdown: improve scientific notation parsing in extractNumAndUnit #7147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Oct 31, 2024

  1. topdown: improve scientific notation parsing in extractNumAndUnit

    - Updated extractNumAndUnit to recognize and correctly parse scientific notation, including cases with 'e' or 'E' followed by an exponent (e.g., "1e10", "3.2E4").
    - Ensures that 'e' or 'E' is treated as part of the number if followed by digits, enhancing compatibility with scientific notation inputs.
    - Scientific notation with units now also parses correctly (e.g., "1e10GB" extracts "1e10" as the number and "GB" as the unit).
    - Maintains behavior for cases without units, allowing either the number or unit portion to be empty, while improving overall string parsing logic.
    - Added tests for scientific notation parsing in `units.parse_bytes`, including both SI and binary units (e.g., KB, MiB, GiB, KiB).
    - Included cases for uppercase, lowercase, and mixed case formats with scientific notation.
    - Added validation for numbers without units defaulting to bytes.
    
    Fixes open-policy-agent#7142
    Signed-off-by: bakar <[email protected]>
    bakar committed Oct 31, 2024
    Configuration menu
    Copy the full SHA
    09e820d View commit details
    Browse the repository at this point in the history