Skip to content

Commit

Permalink
Fix last special printable characters (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
qubixes authored Sep 17, 2024
1 parent 90eb8a8 commit bdb4277
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
include:
- os: macos-latest
python-version: "3.11"
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: MIT License",
]
Expand Down
4 changes: 2 additions & 2 deletions regexmodel/regexclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ def draw_once(self):

@classmethod
def from_string(cls, regex_str) -> Optional[tuple[BaseRegex, str]]:
_special_chars = [".", "+", "*", "?", "^", "$", "(", ")", "[", "]",
"{", "}", "|", "\\", "-", "~", "\r"]
_special_chars = [".", "+", "*", "?", "^", "$", "(", ")", "[", "]", "#", "&",
"{", "}", "|", "\\", "-", "~", "\r", "\t", "\x0b", "\x0c", "\n"]
if len(regex_str) > 1 and regex_str[0] == "\\" and regex_str[1] in _special_chars:
return cls([_unescape(regex_str[1])]), regex_str[2:]
if len(regex_str) >= 1 and regex_str[0] != "\\" and regex_str[0] not in _special_chars:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_regex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pytest import mark
import string

from regexmodel import RegexModel

Expand Down Expand Up @@ -33,6 +34,10 @@ def test_full_pipeline(series, regex, counts):
assert model.regex == new_model.regex
assert new_model.serialize()["counts"] == model.serialize()["counts"]

def test_all_chars():
model = RegexModel.fit(list(string.printable), count_thres=1)
new_model = RegexModel(model.serialize())
assert isinstance(new_model, RegexModel)


# @mark.parametrize(
Expand Down

0 comments on commit bdb4277

Please sign in to comment.