def test_onnxt_json(self):
     idi = numpy.identity(2)
     idi2 = numpy.identity(2) * 2
     onx = OnnxAdd(OnnxAdd('X', idi), idi2, output_names=['Y'])
     model_def = onx.to_onnx({'X': idi.astype(numpy.float32)})
     oinf = OnnxInference(model_def)
     js = oinf.to_json()
     self.assertIn('"initializers": {', js)
 def test_onnxt_json(self):
     idi = numpy.identity(2).astype(numpy.float32)
     idi2 = (numpy.identity(2) * 2).astype(numpy.float32)
     onx = OnnxAdd(OnnxAdd('X', idi, op_version=TARGET_OPSET),
                   idi2,
                   output_names=['Y'],
                   op_version=TARGET_OPSET)
     model_def = onx.to_onnx({'X': idi.astype(numpy.float32)},
                             target_opset=TARGET_OPSET)
     oinf = OnnxInference(model_def)
     js = oinf.to_json()
     self.assertIn('"initializers": {', js)
    def test_onnxt_lrc_iris_json(self):
        iris = load_iris()
        X, y = iris.data, iris.target
        X_train, _, y_train, __ = train_test_split(X, y, random_state=11)
        clr = LogisticRegression(solver="liblinear")
        clr.fit(X_train, y_train)

        model_def = to_onnx(clr, X_train.astype(numpy.float32))
        oinf = OnnxInference(model_def)
        js = oinf.to_json()
        self.assertIn('"producer_name": "skl2onnx",', js)
        self.assertIn('"name": "output_label",', js)
        self.assertIn('"name": "output_probability",', js)
        self.assertIn('"name": "LinearClassifier",', js)
        self.assertIn('"coefficients": {', js)
        self.assertIn('"name": "Normalizer",', js)
        self.assertIn('"name": "Cast",', js)
        self.assertIn('"name": "ZipMap",', js)