def test_if_tof_is_not_two_values_then_histogram_not_created(self): config = deepcopy(self.config) config[0]["tof_range"] = (1,) histograms = HistogramFactory.generate(config) assert len(histograms) == 0
def test_if_no_id_specified_then_empty_string(self): config = deepcopy(self.config) del config[0]["id"] histograms = HistogramFactory.generate(config) assert histograms[0].identifier == ""
def test_if_tof_missing_then_histogram_not_created(self): config = deepcopy(self.config) del config[0]["tof_range"] histograms = HistogramFactory.generate(config) assert len(histograms) == 0
def test_if_height_not_numeric_then_histogram_not_created(self): config = deepcopy(self.config) config[0]["height"] = "hello" histograms = HistogramFactory.generate(config) assert len(histograms) == 0
def test_multiple_configs_produces_multiple_histograms(self): config = deepcopy(CONFIG_1D) config.extend(deepcopy(CONFIG_2D)) config.extend(deepcopy(CONFIG_2D_MAP)) histograms = HistogramFactory.generate(config) assert len(histograms) == 3
def test_creates_histogram_correctly(self): histograms = HistogramFactory.generate(self.config) assert isinstance(histograms[0], Histogram1d) assert histograms[0].tof_range == (20, 2000) assert histograms[0].det_range == (0, 500) assert histograms[0].num_bins == 50 assert histograms[0].topic == "topic0" assert histograms[0].source == "source1"
def test_creates_histogram_correctly(self): histograms = HistogramFactory.generate(self.config) assert isinstance(histograms[0], DetHistogram) assert histograms[0].tof_range == (20, 2000) assert histograms[0].det_range == (1, 6144) assert histograms[0].width == 32 assert histograms[0].height == 192 assert histograms[0].topic == "topic0" assert histograms[0].source == "source1"
def create_histogrammer(hist_sink, configuration): """ Creates a fully configured histogrammer. :param hist_sink: The sink to write histograms to. :param configuration: The configuration message. :return: The created histogrammer. """ start, stop, hist_configs = parse_config(configuration) histograms = HistogramFactory.generate(hist_configs) return Histogrammer(hist_sink, histograms, start, stop)
def create_histogrammer(configuration, start, stop): """ Create a histogrammer. :param configuration: The configuration. :param start: The start time. :param stop: The stop time. :return: The created histogrammer. """ producer = Producer(configuration["data_brokers"]) hist_sink = HistogramSink(producer) histograms = HistogramFactory.generate([configuration]) return Histogrammer(hist_sink, histograms, start, stop)
def test_when_no_histograms_defined_nothing_happens(self): histograms = HistogramFactory.generate(NO_HISTOGRAMS_CONFIG) assert len(histograms) == 0
def test_config_with_id_specified_sets_id(self): histograms = HistogramFactory.generate(self.config) assert histograms[0].identifier == "123456"