@@ -105,41 +105,16 @@ def test_generate_tcm_cols(lgnd_test_data):
105
105
hash_func = None ,
106
106
buffer_len = 1 ,
107
107
)
108
+ # fmt: off
108
109
assert np .array_equal (
109
110
tcm_cols .table_key .flattened_data .nda ,
110
111
[
111
- 1 ,
112
- 0 ,
113
- 2 ,
114
- 1 ,
115
- 2 ,
116
- 1 ,
117
- 2 ,
118
- 1 ,
119
- 1 ,
120
- 1 ,
121
- 0 ,
122
- 1 ,
123
- 1 ,
124
- 2 ,
125
- 2 ,
126
- 1 ,
127
- 2 ,
128
- 1 ,
129
- 2 ,
130
- 0 ,
131
- 0 ,
132
- 2 ,
133
- 2 ,
134
- 2 ,
135
- 0 ,
136
- 0 ,
137
- 0 ,
138
- 0 ,
139
- 0 ,
140
- 0 ,
112
+ 1 , 0 , 2 , 1 , 2 , 1 , 2 , 1 , 1 , 1 , 0 ,
113
+ 1 , 1 , 2 , 2 , 1 , 2 , 1 , 2 , 0 , 0 , 2 ,
114
+ 2 , 2 , 0 , 0 , 0 , 0 , 0 , 0 ,
141
115
],
142
116
)
117
+ # fmt: on
143
118
# test invalid hash func
144
119
with pytest .raises (NotImplementedError ):
145
120
evt .build_tcm (
@@ -175,41 +150,61 @@ def test_generate_tcm_cols(lgnd_test_data):
175
150
tcm_cols .table_key .cumulative_length .nda ,
176
151
[30 ],
177
152
)
153
+ # fmt: off
178
154
assert np .array_equal (
179
155
tcm_cols .table_key .flattened_data .nda ,
180
156
[
181
- 1084804 ,
182
- 1084803 ,
183
- 1121600 ,
184
- 1084804 ,
185
- 1121600 ,
186
- 1084804 ,
187
- 1121600 ,
188
- 1084804 ,
189
- 1084804 ,
190
- 1084804 ,
191
- 1084803 ,
192
- 1084804 ,
193
- 1084804 ,
194
- 1121600 ,
195
- 1121600 ,
196
- 1084804 ,
197
- 1121600 ,
198
- 1084804 ,
199
- 1121600 ,
200
- 1084803 ,
201
- 1084803 ,
202
- 1121600 ,
203
- 1121600 ,
204
- 1121600 ,
205
- 1084803 ,
206
- 1084803 ,
207
- 1084803 ,
208
- 1084803 ,
209
- 1084803 ,
210
- 1084803 ,
157
+ 1084804 , 1084803 , 1121600 , 1084804 , 1121600 , 1084804 ,
158
+ 1121600 , 1084804 , 1084804 , 1084804 , 1084803 , 1084804 ,
159
+ 1084804 , 1121600 , 1121600 , 1084804 , 1121600 , 1084804 ,
160
+ 1121600 , 1084803 , 1084803 , 1121600 , 1121600 , 1121600 ,
161
+ 1084803 , 1084803 , 1084803 , 1084803 , 1084803 , 1084803 ,
211
162
],
212
163
)
164
+ # fmt: on
165
+
166
+
167
+ def test_build_tcm_multiple_cols (lgnd_test_data ):
168
+ f_raw = lgnd_test_data .get_path (
169
+ "lh5/prod-ref-l200/generated/tier/raw/cal/p03/r001/l200-p03-r001-cal-20230318T012144Z-tier_raw.lh5"
170
+ )
171
+
172
+ with pytest .raises (ValueError ):
173
+ evt .build_tcm (
174
+ [(f_raw , ["ch1084803/raw" , "ch1084804/raw" , "ch1121600/raw" ])],
175
+ coin_cols = "timestamp" ,
176
+ window_refs = ["last" , "last" ],
177
+ )
178
+ with pytest .raises (ValueError ):
179
+ evt .build_tcm (
180
+ [(f_raw , ["ch1084803/raw" , "ch1084804/raw" , "ch1121600/raw" ])],
181
+ coin_cols = ["timestamp" ],
182
+ coin_windows = [1 , 2 ],
183
+ )
184
+ tcm = evt .build_tcm (
185
+ [(f_raw , ["ch1084803/raw" , "ch1084804/raw" , "ch1121600/raw" ])],
186
+ coin_cols = ["timestamp" , "table_key" ],
187
+ )
188
+ assert isinstance (tcm , Table )
189
+ assert isinstance (tcm .table_key , VectorOfVectors )
190
+ assert isinstance (tcm .row_in_table , VectorOfVectors )
191
+ # fmt: off
192
+ assert np .array_equal (
193
+ tcm .table_key .flattened_data .nda ,
194
+ [
195
+ 1084804 , 1084803 , 1121600 , 1084804 , 1121600 , 1084804 , 1121600 ,
196
+ 1084804 , 1084804 , 1084804 , 1084803 , 1084804 , 1084804 , 1121600 ,
197
+ 1121600 , 1084804 , 1121600 , 1084804 , 1121600 , 1084803 , 1084803 ,
198
+ 1121600 , 1121600 , 1121600 , 1084803 , 1084803 , 1084803 , 1084803 ,
199
+ 1084803 , 1084803 ,
200
+ ],
201
+ )
202
+ # fmt: on
203
+
204
+ assert np .array_equal (
205
+ tcm .table_key .cumulative_length .nda ,
206
+ np .arange (1 , 31 ),
207
+ )
213
208
214
209
215
210
def test_build_tcm_write (lgnd_test_data , tmp_dir ):
@@ -224,6 +219,7 @@ def test_build_tcm_write(lgnd_test_data, tmp_dir):
224
219
out_name = "hardware_tcm" ,
225
220
wo_mode = "of" ,
226
221
)
222
+
227
223
assert os .path .exists (out_file )
228
224
tcm_cols = lh5 .read ("hardware_tcm" , out_file )
229
225
assert isinstance (tcm_cols , lgdo .Struct )
0 commit comments