Coverage for mlprodict/onnxrt/ops_cpu/op_feature_vectorizer.py: 88%

16 statements  

« prev     ^ index     » next       coverage.py v7.1.0, created at 2023-02-04 02:28 +0100

1# -*- encoding: utf-8 -*- 

2# pylint: disable=E0203,E1101,C0111 

3""" 

4@file 

5@brief Runtime operator. 

6""" 

7import numpy 

8from ._op import OpRun 

9 

10 

11class FeatureVectorizer(OpRun): 

12 """ 

13 Very similar to @see cl Concat. 

14 """ 

15 

16 def __init__(self, onnx_node, desc=None, **options): 

17 OpRun.__init__(self, onnx_node, desc=desc, 

18 **options) 

19 self.axis = 1 

20 

21 def _preprocess(self, a): 

22 if self.axis >= len(a.shape): 

23 new_shape = a.shape + (1, ) * (self.axis + 1 - len(a.shape)) 

24 return a.reshape(new_shape) 

25 return a 

26 

27 def _run(self, *args, attributes=None, verbose=0, fLOG=None): # pylint: disable=W0221 

28 args = [self._preprocess(a) for a in args] 

29 res = numpy.concatenate(args, self.axis) 

30 return (res, )