Skip to content

Commit

Permalink
Prevent bids values with leading 0s in tests
Browse files Browse the repository at this point in the history
When used with `run`, the leading 0 gets stripped because run is
converted into an int. This breaks tests that instantiate a datset on
the filesystem and re-parse it using generate_inputs. Easiest solution
is to just to prevent these values entirely
  • Loading branch information
pvandyken committed May 9, 2024
1 parent 156f58f commit 5df0b56
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions snakebids/tests/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def bids_value(pattern: str = r"[^\n\r]*") -> st.SearchStrategy[str]:
# remove values leading with multiple dots ".." because pybids doesn't handle
# them correctly when applied to the "extension" entity
.filter(lambda s: s[:2] != "..")
# numbers with leading 0s get messed up with _run-, which converts to int
# and strips the leading 0s. This messes up some of the dataset creation tests
.filter(lambda s: s.isdigit() and int(s) > 0 and not s.startswith("0"))
)


Expand Down

0 comments on commit 5df0b56

Please sign in to comment.