@@ -69,8 +69,7 @@ def test_onnx_text_plot_tree_cls_2(self):
6969 model_def = load (f )
7070 res = onnx_text_plot_tree (model_def .graph .node [0 ])
7171 self .assertIn ("n_classes=3" , res )
72- expected = textwrap .dedent (
73- """
72+ expected = textwrap .dedent ("""
7473 n_classes=3
7574 n_trees=1
7675 ----
@@ -92,8 +91,7 @@ def test_onnx_text_plot_tree_cls_2(self):
9291 -f 0:0 1:0 2:1
9392 +f 0:0 1:1 2:0
9493 +f 0:1 1:0 2:0
95- """
96- ).strip (" \n \r " )
94+ """ ).strip (" \n \r " )
9795 res = res .replace ("np.float32(" , "" ).replace (")" , "" )
9896 self .assertEqual (expected , res .strip (" \n \r " ))
9997
@@ -104,39 +102,33 @@ def test_onnx_simple_text_plot_kmeans(self):
104102 model .fit (x )
105103 onx = to_onnx (model , x .astype (numpy .float32 ), target_opset = 15 )
106104 text = onnx_simple_text_plot (onx )
107- expected1 = textwrap .dedent (
108- """
105+ expected1 = textwrap .dedent ("""
109106 ReduceSumSquare(X, axes=[1], keepdims=1) -> Re_reduced0
110107 Mul(Re_reduced0, Mu_Mulcst) -> Mu_C0
111108 Gemm(X, Ge_Gemmcst, Mu_C0, alpha=-2.00, transB=1) -> Ge_Y0
112109 Add(Re_reduced0, Ge_Y0) -> Ad_C01
113110 Add(Ad_Addcst, Ad_C01) -> Ad_C0
114111 Sqrt(Ad_C0) -> scores
115112 ArgMin(Ad_C0, axis=1, keepdims=0) -> label
116- """
117- ).strip (" \n " )
118- expected2 = textwrap .dedent (
119- """
113+ """ ).strip (" \n " )
114+ expected2 = textwrap .dedent ("""
120115 ReduceSumSquare(X, axes=[1], keepdims=1) -> Re_reduced0
121116 Mul(Re_reduced0, Mu_Mulcst) -> Mu_C0
122117 Gemm(X, Ge_Gemmcst, Mu_C0, alpha=-2.00, transB=1) -> Ge_Y0
123118 Add(Re_reduced0, Ge_Y0) -> Ad_C01
124119 Add(Ad_Addcst, Ad_C01) -> Ad_C0
125120 Sqrt(Ad_C0) -> scores
126121 ArgMin(Ad_C0, axis=1, keepdims=0) -> label
127- """
128- ).strip (" \n " )
129- expected3 = textwrap .dedent (
130- """
122+ """ ).strip (" \n " )
123+ expected3 = textwrap .dedent ("""
131124 ReduceSumSquare(X, axes=[1], keepdims=1) -> Re_reduced0
132125 Mul(Re_reduced0, Mu_Mulcst) -> Mu_C0
133126 Gemm(X, Ge_Gemmcst, Mu_C0, alpha=-2.00, transB=1) -> Ge_Y0
134127 Add(Re_reduced0, Ge_Y0) -> Ad_C01
135128 Add(Ad_Addcst, Ad_C01) -> Ad_C0
136129 ArgMin(Ad_C0, axis=1, keepdims=0) -> label
137130 Sqrt(Ad_C0) -> scores
138- """
139- ).strip (" \n " )
131+ """ ).strip (" \n " )
140132 if expected1 not in text and expected2 not in text and expected3 not in text :
141133 raise AssertionError (f"Unexpected value:\n { text } " )
142134
@@ -165,17 +157,15 @@ def test_onnx_simple_text_plot_toy(self):
165157 {"X" : x .astype (numpy .float32 )}, outputs = {"Y" : x }, target_opset = 15
166158 )
167159 text = onnx_simple_text_plot (onx , verbose = False )
168- expected = textwrap .dedent (
169- """
160+ expected = textwrap .dedent ("""
170161 Add(X, Ad_Addcst) -> Ad_C0
171162 Abs(Ad_C0) -> Ab_Y0
172163 Identity(Ad_Addcst) -> Su_Subcst
173164 Sub(X, Su_Subcst) -> Su_C0
174165 Abs(Su_C0) -> Ab_Y02
175166 Div(Ab_Y0, Ab_Y02) -> Di_C0
176167 Abs(Di_C0) -> Y
177- """
178- ).strip (" \n " )
168+ """ ).strip (" \n " )
179169 self .assertIn (expected , text )
180170 text2 , out , err = self .capture (lambda : onnx_simple_text_plot (onx , verbose = True ))
181171 self .assertEqual (text , text2 )
@@ -188,11 +178,9 @@ def test_onnx_simple_text_plot_leaky(self):
188178 {"X" : FloatTensorType ()}, outputs = {"Y" : FloatTensorType ()}, target_opset = 15
189179 )
190180 text = onnx_simple_text_plot (onx )
191- expected = textwrap .dedent (
192- """
181+ expected = textwrap .dedent ("""
193182 LeakyRelu(X, alpha=0.50) -> Y
194- """
195- ).strip (" \n " )
183+ """ ).strip (" \n " )
196184 self .assertIn (expected , text )
197185
198186 def test_onnx_text_plot_io (self ):
@@ -201,11 +189,9 @@ def test_onnx_text_plot_io(self):
201189 {"X" : FloatTensorType ()}, outputs = {"Y" : FloatTensorType ()}, target_opset = 15
202190 )
203191 text = onnx_text_plot_io (onx )
204- expected = textwrap .dedent (
205- """
192+ expected = textwrap .dedent ("""
206193 input:
207- """
208- ).strip (" \n " )
194+ """ ).strip (" \n " )
209195 self .assertIn (expected , text )
210196
211197 def test_onnx_simple_text_plot_if (self ):
@@ -244,11 +230,9 @@ def test_onnx_simple_text_plot_if(self):
244230 {"x1" : x1 , "x2" : x2 }, target_opset = opv , outputs = [("y" , FloatTensorType ())]
245231 )
246232 text = onnx_simple_text_plot (model_def )
247- expected = textwrap .dedent (
248- """
233+ expected = textwrap .dedent ("""
249234 input:
250- """
251- ).strip (" \n " )
235+ """ ).strip (" \n " )
252236 self .assertIn (expected , text )
253237 self .assertIn ("If(Gr_C0, else_branch=G1, then_branch=G2)" , text )
254238
0 commit comments