Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix last special printable characters #13

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading