SND@LHC Software
Loading...
Searching...
No Matches
conditionsDatabase.tests.dummydata_generator Namespace Reference

Functions

 create_big_daniel (detector_number=1000)
 
 create_big_detectors (detector_number=10, parent_id=None, detector_root_name="Detector", start_index_for_detector_root_name=0)
 
 create_multilevel_detectors (level=5, number_subdetectors_of_each_detector=4, detector_root_name="detector", parent_path=None, group_detector_parent=[])
 

Detailed Description

 This module implements a dummy data generator. 

Function Documentation

◆ create_big_daniel()

conditionsDatabase.tests.dummydata_generator.create_big_daniel (   detector_number = 1000)
function generate big daniel data

:param detector_number: number of entries that will be generated - default number is 1000
:return data: dict as {'T756_MA_756': [655, 97, 564], 'T772_MA_772': [436, 744, 614],
 'T254_MA_254': [608, 74, 8]...}

Definition at line 5 of file dummydata_generator.py.

5def create_big_daniel(detector_number=1000):
6 """
7 function generate big daniel data
8
9 :param detector_number: number of entries that will be generated - default number is 1000
10 :return data: dict as {'T756_MA_756': [655, 97, 564], 'T772_MA_772': [436, 744, 614],
11 'T254_MA_254': [608, 74, 8]...}
12 """
13 daniel = {}
14 for i in range(detector_number):
15 arr = np.random.randint(1000, size=3)
16 daniel['T' + str(i) + '_MA_' + str(i)] = arr.tolist()
17
18 return daniel
19
20

◆ create_big_detectors()

conditionsDatabase.tests.dummydata_generator.create_big_detectors (   detector_number = 10,
  parent_id = None,
  detector_root_name = "Detector",
  start_index_for_detector_root_name = 0 
)
function create big data i.e. detector_name, detector_parent_id relating to
the detector name, and parent as API add_detector(self, name, parent_id) required

:param detector_number: number of detectors that well be generated - default number is 10
:param parent_id: parent path of detector - default None
:param detector_root_name: base name for a detector - default value is "Detector"
:param start_index_for_detector_root_name:
       start index of increase progressively with detector root name - default is 0
:return list with tuples that can be input for pytests.
:return example [('Detector0', None), ('Detector1', None)...]

Definition at line 21 of file dummydata_generator.py.

23 start_index_for_detector_root_name=0):
24 """
25 function create big data i.e. detector_name, detector_parent_id relating to
26 the detector name, and parent as API add_detector(self, name, parent_id) required
27
28 :param detector_number: number of detectors that well be generated - default number is 10
29 :param parent_id: parent path of detector - default None
30 :param detector_root_name: base name for a detector - default value is "Detector"
31 :param start_index_for_detector_root_name:
32 start index of increase progressively with detector root name - default is 0
33 :return list with tuples that can be input for pytests.
34 :return example [('Detector0', None), ('Detector1', None)...]
35 """
36 group_detectors = []
37 root = detector_root_name
38 area = range(start_index_for_detector_root_name,
39 start_index_for_detector_root_name + detector_number)
40
41 for start in area:
42 detector_name_root_with_number = root + str(start)
43 item = (detector_name_root_with_number, parent_id)
44 group_detectors.append(item)
45
46 return group_detectors
47
48

◆ create_multilevel_detectors()

conditionsDatabase.tests.dummydata_generator.create_multilevel_detectors (   level = 5,
  number_subdetectors_of_each_detector = 4,
  detector_root_name = "detector",
  parent_path = None,
  group_detector_parent = [] 
)
function create multilevel of detectors , which is like n-tree
(each detector has many layers of subdetectors)

:param level: define layers of detectors tree, default is 5
:param number_subdetectors_of_each_detector: define number of
       subdetectors for each parent detector, default is 4
:param detector_root_name: define the base name of detector,
       default value is "detector"
:param parent_path: specify parent_path of subdetector,
       if there is no basic detector can be used,
       it should be None as create first level detectors, default is None
:param[inout] group_detector_parent: a list stores
       the data structure of multilevel detector, default is []
return null. The result will be stored in the group_detector_parent param.

usage example: create_multilevel_detectors(5, 4, "detector", None, group_detector_parent)
example explanation: it create a five levels detectors tree each detector has 4 subdetector,

Definition at line 49 of file dummydata_generator.py.

53 group_detector_parent=[]):
54 """
55 function create multilevel of detectors , which is like n-tree
56 (each detector has many layers of subdetectors)
57
58 :param level: define layers of detectors tree, default is 5
59 :param number_subdetectors_of_each_detector: define number of
60 subdetectors for each parent detector, default is 4
61 :param detector_root_name: define the base name of detector,
62 default value is "detector"
63 :param parent_path: specify parent_path of subdetector,
64 if there is no basic detector can be used,
65 it should be None as create first level detectors, default is None
66 :param[inout] group_detector_parent: a list stores
67 the data structure of multilevel detector, default is []
68 return null. The result will be stored in the group_detector_parent param.
69
70 usage example: create_multilevel_detectors(5, 4, "detector", None, group_detector_parent)
71 example explanation: it create a five levels detectors tree each detector has 4 subdetector,
72 """
73
74 # level is also used to as a count to achieve recursion;
75 # assume [detect, None] is counted as a layer as well
76 if level == 0:
77 return
78
79 first_level_detector = create_big_detectors(
80 number_subdetectors_of_each_detector, parent_path, detector_root_name)
81
82 for first_level_item in first_level_detector:
83 group_detector_parent.append(first_level_item)
84 detector_name = first_level_item[0]
85
86 if parent_path is None:
87 path = detector_name
88 else:
89 path = parent_path + "/" + detector_name
90
91 create_multilevel_detectors(level - 1, number_subdetectors_of_each_detector,
92 "sub" + detector_root_name, path,
93 group_detector_parent)