Skip to content

Commit a310940

Browse files
Bug fix: Add None checks for the boundary values. (#832)
Its bugging me that CI workflow is failing because of a test for this function. This bug fix should bring green ticks back again. ;)
1 parent c12305c commit a310940

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

algorithms/arrays/limit.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@
1414

1515
# tl:dr -- array slicing by value
1616
def limit(arr, min_lim=None, max_lim=None):
17+
if len(arr) == 0:
18+
return arr
19+
20+
if min_lim is None:
21+
min_lim = min(arr)
22+
if max_lim is None:
23+
max_lim = max(arr)
24+
1725
return list(filter(lambda x: (min_lim <= x <= max_lim), arr))

0 commit comments

Comments
 (0)