Skip to content

Commit 97c5416

Browse files
committed
add suggestions
1 parent 6ef7fb5 commit 97c5416

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/problem_bank_helpers/problem_bank_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def round_sig(x, sig):
9898
# avoid precision loss with floats
9999
decimal_x = round( Decimal(str(x)) , y )
100100

101-
return int(decimal_x) if isinstance(x, int) else float(decimal_x)
101+
return type(x)(decimal_x)
102102

103103

104104
# def round_sig(x, sig_figs = 3):

tests/test_problem_bank_helpers_rounding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ def test_sigfigs_float_input_fail():
141141
# Test round_sig function
142142
def test_roundsig_int_returns_int():
143143
"""Test rounding an int with specified sigfigs"""
144-
assert type(pbh.round_sig(123, 2)) is int
144+
assert isinstance(pbh.round_sig(123, 2), int)
145145

146146
def test_roundsig_with_float():
147147
"""Test rounding an float with specified sigfigs"""
148-
assert type(pbh.round_sig(123.0, 2)) is float
148+
assert isinstance(pbh.round_sig(123.0, 2), float)
149149

150150
def test_roundsig_with_string_fail():
151151
"""Test rounding a string with specified sigfigs"""

0 commit comments

Comments
 (0)