Skip to content

Commit 93b1fcd

Browse files
rollbach on str type
1 parent 101164c commit 93b1fcd

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

shapash/utils/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ def is_nested_list(object_param):
7373
return any(isinstance(elem, list) for elem in object_param)
7474

7575

76-
def add_line_break(text, nbchar, maxlen=150):
76+
def add_line_break(value, nbchar, maxlen=150):
7777
"""
7878
adding line break in string if necessary
7979
8080
Parameters
8181
----------
82-
text : string
83-
string to check in order to add line break
82+
value : string or oither type
83+
if string to check in order to add line break
8484
nbchar : int
8585
number of characters before line break
8686
maxlen : int
@@ -91,10 +91,10 @@ def add_line_break(text, nbchar, maxlen=150):
9191
string
9292
original text + line break
9393
"""
94-
if isinstance(text, str):
94+
if isinstance(value, str):
9595
length = 0
9696
tot_length = 0
97-
input_word = text.split()
97+
input_word = value.split()
9898
final_sep = []
9999
for w in input_word[:-1]:
100100
length = length + len(w)
@@ -113,7 +113,7 @@ def add_line_break(text, nbchar, maxlen=150):
113113
new_string = "".join(sum(zip(input_word, final_sep + [""]), ())[:-1]) + last_char
114114
return new_string
115115
else:
116-
return str(text)
116+
return value
117117

118118

119119
def truncate_str(text, maxlen=40):

tests/unit_tests/explainer/test_smart_plotter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,11 +1860,11 @@ def test_interactions_plot_3(self):
18601860

18611861
output = smart_explainer.plot.interactions_plot(col2, col1, violin_maxf=0)
18621862

1863-
assert np.array_equal(output.data[0].x, ["34.0"])
1863+
assert np.array_equal(output.data[0].x, [34.0])
18641864
assert np.array_equal(output.data[0].y, [-1.4])
18651865
assert output.data[0].name == "PhD"
18661866

1867-
assert np.array_equal(output.data[1].x, ["27.0"])
1867+
assert np.array_equal(output.data[1].x, [27.0])
18681868
assert np.array_equal(output.data[1].y, [-0.2])
18691869
assert output.data[1].name == "Master"
18701870

@@ -1893,7 +1893,7 @@ def test_interactions_plot_4(self):
18931893

18941894
output = smart_explainer.plot.interactions_plot(col1, col2, violin_maxf=0)
18951895

1896-
assert np.array_equal(output.data[0].x, ["520.0", "12800.0"])
1896+
assert np.array_equal(output.data[0].x, [520, 12800])
18971897
assert np.array_equal(output.data[0].y, [-1.4, -0.2])
18981898
assert np.array_equal(output.data[0].marker.color, [34.0, 27.0])
18991899

tests/unit_tests/utils/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_truncate_str_3(self):
8383

8484
def test_add_line_break_1(self):
8585
t = add_line_break(3453, 10)
86-
assert t == "3453"
86+
assert t == 3453
8787

8888
def test_add_line_break_2(self):
8989
t = add_line_break("this is a very long sentence in order to make a very great test", 10)

0 commit comments

Comments
 (0)