Skip to content

Commit c9f575e

Browse files
author
Johannes Hentschel
committed
refactor: adds SLICE_INTERVAL_REGEX constant
1 parent 70fd82e commit c9f575e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/ms3/utils/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@
318318

319319
KEYSIG_DICT_ENTRY_REGEX = r"(\d+): (-?\d+)(?:, )?"
320320
TIMESIG_DICT_ENTRY_REGEX = r"(\d+): (\d+\/\d+)(?:, )?"
321+
SLICE_INTERVAL_REGEX = (
322+
r"[\[\)]((?:\d+\.?\d*)|(?:\.\d+)), ((?:\d+\.?\d*)|(?:\.\d+))[\)\]]"
323+
)
324+
"""Regular expression for slice interval in open/closed notation and any flavour of floating point numbers,
325+
e.g. [0, 1.5) or (.5, 2.]"""
321326

322327
MS3_HTML = {
323328
"#005500": "ms3_darkgreen",

src/ms3/utils/functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
MS3_HTML,
6868
MS3_RGB,
6969
SCORE_EXTENSIONS,
70+
SLICE_INTERVAL_REGEX,
7071
STANDARD_COLUMN_ORDER,
7172
STANDARD_NAMES,
7273
STANDARD_NAMES_OR_GIT,
@@ -2451,7 +2452,7 @@ def parse_interval_index_column(df, column=None, closed="left"):
24512452
-------
24522453
:obj:`pandas.IntervalIndex`
24532454
"""
2454-
iv_regex = r"[\[\(]([0-9]*\.[0-9]+), ([0-9]*\.[0-9]+)[\)\]]"
2455+
iv_regex = SLICE_INTERVAL_REGEX
24552456
if column is None:
24562457
iv_strings = df.index
24572458
else:

0 commit comments

Comments
 (0)