Skip to content

Commit

Permalink
Allow negative integers in ID hashes (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
KCGallagher committed Aug 6, 2024
1 parent 222cbfb commit ffb8478
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyEpiabm/pyEpiabm/core/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def set_id(self, id: str, cells: typing.List):
raise TypeError("Provided id must be a string")

# This regex will match on any string which has 1 or more digits
if not re.match("^\\d+$", id):
if not re.match("^-?\\d+$", id):
raise ValueError(f"Invalid id: {id}. id must be of the form 'i' "
f"where i is an integer")

Expand Down
2 changes: 1 addition & 1 deletion pyEpiabm/pyEpiabm/core/household.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def set_id(self, id: str):

# This regex will match on any string which takes the form "i.j.k"
# where i, j and k are integers
if not re.match("^\\d+\\.\\d+\\.\\d+$", id):
if not re.match("^-?\\d+\\.-?\\d+\\.-?\\d+$", id):
raise ValueError(f"Invalid id: {id}. id must be of the form "
f"'i.j.k' where i, j, k are integers")

Expand Down
2 changes: 1 addition & 1 deletion pyEpiabm/pyEpiabm/core/microcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def set_id(self, id):

# This regex will match on any string which takes the form "i.j" where
# i and j are integers
if not re.match("^\\d+\\.\\d+$", id):
if not re.match("^-?\\d+\\.-?\\d+$", id):
raise ValueError(f"Invalid id: {id}. id must be of the form 'i.j' "
f"where i, j are integers")

Expand Down
2 changes: 1 addition & 1 deletion pyEpiabm/pyEpiabm/core/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def set_id(self, id: str):

# This regex will match on any string which takes the form "i.j.k.l"
# where i, j, k and l are integers (k can be empty)
if not re.match("^\\d+\\.\\d+\\.\\d*\\.\\d+$", id):
if not re.match("^-?\\d+\\.-?\\d+\\.-?\\d*\\.-?\\d+$", id):
raise ValueError(f"Invalid id: {id}. id must be of the form "
f"'i.j.k.l' where i, j, k, l are integers (k"
f"can be empty)")
Expand Down

0 comments on commit ffb8478

Please sign in to comment.