Skip to content

Commit

Permalink
Fix more pylint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Mar 15, 2024
1 parent 3219583 commit 3fb7ec0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
16 changes: 5 additions & 11 deletions src/application/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import math


_NUMBER_TO_WORD = {
0: "zero",
1: "one",
Expand Down Expand Up @@ -49,21 +48,16 @@ def round_to_n_decimal_places(cls, value: float, n: int):

@classmethod
def number_to_word(cls, number: int) -> str:
if number >= 0 and number <= 19:
if 0 <= number <= 19:
return _NUMBER_TO_WORD[number]
elif number >= 0 and number <= 99:
if 0 <= number <= 99:
tens = number // 10 * 10
ones = number % 10
if ones == 0:
return _NUMBER_TO_WORD[tens]
else:
return (
_NUMBER_TO_WORD[tens]
+ _NUMBER_TO_WORD[ones][0].upper()
+ _NUMBER_TO_WORD[ones][1:]
)
else:
raise RuntimeError("Runtime error.")
return _NUMBER_TO_WORD[tens] + cls.capitalize(_NUMBER_TO_WORD[ones])

raise ValueError(f"For variable names, only use numbers between 0 and 99. Got {number}.")

@classmethod
def capitalize(cls, s: str) -> str:
Expand Down
3 changes: 2 additions & 1 deletion src/application/rounder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class RoundingConfig:
decimal_places_fallback: int


# pylint: disable-next=too-few-public-methods
class _Rounder:

@classmethod
Expand Down Expand Up @@ -114,7 +115,7 @@ def _round_result(cls, result: _Result, config: RoundingConfig) -> None:
else:
u.uncertainty.set_sigfigs(2)

min_exponent = min([u.uncertainty.get_min_exponent() for u in uncertainties])
min_exponent = min(u.uncertainty.get_min_exponent() for u in uncertainties)
value.set_min_exponent(min_exponent)

# Rounding hierarchy 7:
Expand Down
4 changes: 1 addition & 3 deletions src/domain/uncertainty.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from domain.value import _Value


# pylint: disable-next=too-few-public-methods
class _Uncertainty:
"""
A named uncertainty value, e.g. a systematic uncertainty of ±0.1cm
Expand All @@ -16,6 +17,3 @@ class _Uncertainty:
def __init__(self, uncertainty: _Value, name: str = ""):
self.uncertainty = uncertainty
self.name = name

def value(self) -> _Value:
return self.uncertainty
2 changes: 1 addition & 1 deletion tests/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# wiz.res("", 42.0).print()
# -> Error: "name must not be empty"

wiz.res("a1", 1.0, r"\mm")
wiz.res("a99", 1.0, r"\mm")
# a: 1.0 \mm

wiz.res("1 b", 1.0, 0.01, r"\per\mm\cubed").print()
Expand Down

0 comments on commit 3fb7ec0

Please sign in to comment.