Skip to content

Commit

Permalink
Fixed evaluation environments
Browse files Browse the repository at this point in the history
  • Loading branch information
vruusmann committed Oct 28, 2024
1 parent 0d5c489 commit 8ca1d9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions sklearn2pmml/preprocessing/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,13 @@ def test_func_transform(self):
X = numpy.array([[1.5], [0.0], [-3.0]])
self.assertEqual([[1], [0], [-1]], transformer.fit_transform(X).tolist())

def test_regex_transform(self):
transformer = ExpressionTransformer("pcre2.substitute(r'B+', r'c', X[0])")
X = numpy.array([["ABBA"]])
self.assertEqual([["AcA"]], transformer.fit_transform(X).tolist())
transformer = ExpressionTransformer("re.sub(r'B+', r'c', X[0])")
self.assertEqual([["AcA"]], transformer.fit_transform(X).tolist())

def test_sequence_transform(self):
X = DataFrame([[None], [1], [None]], columns = ["a"])
mapper = DataFrameMapper([
Expand Down
2 changes: 1 addition & 1 deletion sklearn2pmml/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def to_expr(expr):
else:
raise TypeError()

def to_expr_func(expr, modules = ["math", "re", "pcre", "numpy", "pandas", "scipy"]):
def to_expr_func(expr, modules = ["math", "re", "pcre", "pcre2", "numpy", "pandas", "scipy"]):
env = dict()

if isinstance(expr, str):
Expand Down

0 comments on commit 8ca1d9f

Please sign in to comment.