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