Skip to content

Commit

Permalink
to_integer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed Aug 9, 2024
1 parent e36943e commit aca9158
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dcicutils/misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ def to_number(value: str,
value = value[:value_dot_zero_suffix.start()]

if (allow_commas is True) and ("," in value):
# Make sure that any commas are properly placed/spaced.
# Make sure any commas are properly placed/spaced.
if not re.fullmatch(r"(-?\d{1,3}(,\d{3})*)", value):
return fallback
value = value.replace(",", "")
Expand All @@ -1108,7 +1108,7 @@ def to_number(value: str,

if value_multiplier != _TO_NUMBER_POWER_OF_TEN_FOR_NOTHING:
# We do string manipulation for the (power of ten) multiplier and NOT normal multiplicative
# arithmetic because this can easily yield unexpected floating point related inaccuracies.
# arithmetic because this can EASILY yield UNEXPECTED floating point related INACCURACIES.
# E.g. to_integer("1.5678K", allow_multiplier_suffix=True) would yield 1567.8000000000002
# rather than 1567.8 if (we simply did 1.5678 * 1000.0); also tried multiplying by 10 at
# a time, and using Decimal, which obviated some, but not all, of the idiosyncrasies.
Expand Down

0 comments on commit aca9158

Please sign in to comment.