Skip to content

Commit

Permalink
refactor: adds SLICE_INTERVAL_REGEX constant
Browse files Browse the repository at this point in the history
  • Loading branch information
johentsch committed Jan 21, 2024
1 parent 70fd82e commit c9f575e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/ms3/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@

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

MS3_HTML = {
"#005500": "ms3_darkgreen",
Expand Down
3 changes: 2 additions & 1 deletion src/ms3/utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
MS3_HTML,
MS3_RGB,
SCORE_EXTENSIONS,
SLICE_INTERVAL_REGEX,
STANDARD_COLUMN_ORDER,
STANDARD_NAMES,
STANDARD_NAMES_OR_GIT,
Expand Down Expand Up @@ -2451,7 +2452,7 @@ def parse_interval_index_column(df, column=None, closed="left"):
-------
:obj:`pandas.IntervalIndex`
"""
iv_regex = r"[\[\(]([0-9]*\.[0-9]+), ([0-9]*\.[0-9]+)[\)\]]"
iv_regex = SLICE_INTERVAL_REGEX
if column is None:
iv_strings = df.index
else:
Expand Down

0 comments on commit c9f575e

Please sign in to comment.