Skip to content

Commit

Permalink
Add error message when user gives exact value AND specifies sigfigs/d…
Browse files Browse the repository at this point in the history
…ecimal places
  • Loading branch information
paul019 committed Mar 16, 2024
1 parent 7fb8e1a commit c201917
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/api/res.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ def res(
"Please choose one or the other."
)

if sigfigs is not None and isinstance(value, str):
raise ValueError(
"You can't set sigfigs and supply an exact value. Please do one or the other."
)

if decimal_places is not None and isinstance(value, str):
raise ValueError(
"You can't set decimal places and supply an exact value. Please do one or the other."
)

# Parse user input
name_res = parsers.parse_name(name)
value_res = parsers.parse_value(value)
Expand Down
2 changes: 0 additions & 2 deletions src/application/rounder.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ def round_result(cls, result: Result, config: RoundingConfig) -> None:
8. Is fallback for decimal places given (not -1) (see config)?
Round value according to number of decimal places.
TODO: Warning message if user specifies exact value and sigfigs etc.
"""
cls._round_result(result, config)

Expand Down

0 comments on commit c201917

Please sign in to comment.