def test_waveform_copy(): """ Test that the waveforms are not altered by any WaveformReducer """ reader = ReaderR1(get_file("chec_r1.tio")) kwargs = dict( n_pixels=reader.n_pixels, n_samples=reader.n_samples, mapping=reader.mapping, reference_pulse_path=reader.reference_pulse_path, ) waveforms = reader[0] test_waveforms = np.copy(waveforms) all_reducers = child_subclasses(WaveformReducer) for r in all_reducers: try: reducer = r(**kwargs) reducer.process(waveforms) if not (waveforms == test_waveforms).all(): raise ValueError("WaveformReducer {} alters the waveforms!" .format(r.__name__)) except ImportError: continue
def test_readerr1(): reader = ReaderR1(get_file("chec_r1.tio")) n_events = reader.n_events count = 0 for _ in reader: count += 1 assert count > 0 assert count == n_events
def test_readerr0(): reader = ReaderR0(get_file("targetmodule_r0.tio")) n_events = reader.n_events count = 0 for _ in reader: count += 1 assert count > 0 assert count == n_events
def main(): description = ('Create a yaml config file for use with extract_dl1.py ' 'to configure the WaveformReducers') parser = argparse.ArgumentParser(description=description, formatter_class=Formatter) parser.add_argument('-o', '--output', dest='output_path', action='store', help='path to store the output HDF5 dl1 file') parser.add_argument('--bare', dest='bare', action='store_true', help='create the file without docstrings') args = parser.parse_args() output_path = args.output_path or get_file("extractor_config.yml") bare = args.bare all_reducers = child_subclasses(WaveformReducer) default = WaveformReducerChain.default_columns with open(output_path, 'w') as f: for r in all_reducers: f.writelines("# {}\n".format(r.__name__)) doc = r.__doc__ if doc and not bare: doc = re.sub(r'(\n\s*)', '\n# ', doc).strip()[:-1] f.writelines(doc) for c in r.columns: f.writelines("{}: {}\n".format(c, default.get(c, True))) doc = column.registry[c].__doc__ if doc and not bare: doc = re.sub(r'(\n\s*)', '\n# ', doc).strip()[:-1] f.writelines(doc) f.writelines("\n") print("Config file created: {}".format(output_path))
def test_readerr1_with_r0(): with pytest.raises(IOError): reader = ReaderR1(get_file("targetmodule_r0.tio"))
def test_readerr0_with_r1(): with pytest.raises(IOError): reader = ReaderR0(get_file("targetmodule_r1.tio"))
def test_readerr1_single_module(): reader = ReaderR1(get_file("targetmodule_r1.tio")) assert reader.n_pixels == 64 assert reader[0].shape[0] == 64
def test_readerr1_getitem(): reader = ReaderR1(get_file("chec_r1.tio")) event = reader[1] assert event.shape == (reader.n_pixels, reader.n_samples) assert reader.index == 1