Skip to content

Commit

Permalink
formating
Browse files Browse the repository at this point in the history
Signed-off-by: adam444555 <a473489548@gmail.com>
  • Loading branch information
adam444555 committed Nov 15, 2021
1 parent 46eccd9 commit 13edd88
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_sklearn_tfidf_vectorizer_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,33 @@ def test_model_tfidf_vectorizer_nan(self):
assert res.shape == (4, 9)
assert numpy.isnan(res[0, 0])

@unittest.skipIf(
StrictVersion(onnx.__version__) <= StrictVersion("1.4.1"),
reason="Requires opset 9.")
def test_model_tfidf_vectorizer11_custom_vocabulary(self):
corpus = numpy.array([
"This is the first document.",
"This document is the second document.",
"And this is the third one.",
"Is this the first document?",
]).reshape((4, 1))
vc = ["first", "second", "third", "document", "this"]
vect = TfidfVectorizer(ngram_range=(1, 1), norm=None, vocabulary=vc)
vect.fit(corpus.ravel())
model_onnx = convert_sklearn(vect, "TfidfVectorizer",
[("input", StringTensorType())],
options=self.get_options(),
target_opset=TARGET_OPSET)
self.assertTrue(model_onnx is not None)
dump_data_and_model(
corpus,
vect,
model_onnx,
basename="SklearnTfidfVectorizer11CustomVocab-OneOff-SklCol",
allow_failure="StrictVersion(onnxruntime.__version__)"
" <= StrictVersion('0.4.0')",
)


if __name__ == "__main__":
unittest.main()

0 comments on commit 13edd88

Please sign in to comment.