Belle II Software  release-05-01-25
test.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 # Thomas Keck 2016
5 
6 import numpy as np
7 
8 
9 class State(object):
10  """
11  Test state
12  """
13  def __init__(self):
14  """ Constructor of the state object """
15  pass
16 
17  def __repr__(self):
18  """ Returns representation of this state"""
19  return 'State'
20 
21 
22 def feature_importance(state):
23  """
24  Return a list containing the feature importances
25  """
26  print("Called feature importance")
27  return []
28 
29 
30 def get_model(number_of_features, number_of_spectators, number_of_events, training_fraction, parameters):
31  """
32  Return default test model
33  """
34  print("Called get_model")
35  print(parameters)
36  return State()
37 
38 
39 def load(obj):
40  """
41  Test load function
42  """
43  print("Called load")
44  print(obj)
45  return State()
46 
47 
48 def apply(state, X):
49  """
50  Test apply function
51  """
52  print("Called apply")
53  print(state, X.shape)
54  p = np.zeros(len(X))
55  return np.require(p, dtype=np.float32, requirements=['A', 'W', 'C', 'O'])
56 
57 
58 def begin_fit(state, Xtest, Stest, ytest, wtest):
59  """
60  Test begin_fit function
61  """
62  print("Called begin_fit")
63  print(state, Xtest.shape, Stest.shape, ytest.shape, wtest.shape)
64  return state
65 
66 
67 def partial_fit(state, X, S, y, w, epoch):
68  """
69  Test partial_fit function
70  """
71  print("Called partial_fit")
72  print(state, X.shape, S.shape, y.shape, w.shape, epoch)
73  return True
74 
75 
76 def end_fit(state):
77  """
78  Test end_fit function
79  """
80  print("Called end_fit")
81  print(state)
82  return "SerializedState"
basf2_mva_python_interface.test.State
Definition: test.py:9
basf2_mva_python_interface.test.State.__repr__
def __repr__(self)
Definition: test.py:17
basf2_mva_python_interface.test.State.__init__
def __init__(self)
Definition: test.py:13