def test_create_outputDir(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) Ssp.create_outputDir() existing = False if os.path.isdir(output_dir): existing = True assert existing == True
def test_create_axis(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) fig, ax = Ssp.create_axis() existing = False if not (fig == None or ax == None): existing = True assert existing == True
def test_check_inputValidity_wrong_outputDir(): try: Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, 3) Ssp.check_inputValidity() error = False except ValueError: error = True assert error == True
def test_check_inputValidity_wrong_simTruth(): try: Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, "/foo/bar", output_dir) Ssp.check_inputValidity() error = False except ValueError: error = True assert error == True
def test_compare_thrown_muon_opening_angle_with_detected(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) Ssp.compare_thrown_muon_opening_angle_with_detected() plotPath = os.path.join(output_dir, "opening_angle.png") existing = False if os.path.exists(plotPath): existing = True assert existing == True
def test_confusionMatrix_opening_angle(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) Ssp.confusionMatrix_opening_angle() plotPath = os.path.join(output_dir, "confusionMatrix_oa.png") existing = False if os.path.exists(plotPath): existing = True assert existing == True
def test_plot_cxcy_sq(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) Ssp.plot_cxcy_sq() path = os.path.join(output_dir, "cxcy_squared.png") existing = False if os.path.exists(path): existing = True assert existing == True
def test_plot_plot_gaussDistribution_for_R_width(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) Ssp.plot_gaussDistribution_for_R_width() path = os.path.join(output_dir, "r_difference_gauss.png") existing = False if os.path.exists(path): existing = True assert existing == True
def test_create_all_singleSimulation_plots(): mainOut = os.path.join(output_dir, "main") Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, mainOut) Ssp.create_all_singleSimulation_plots() wild_card_path = os.path.join(mainOut, "*") i = 0 for path in glob.glob(wild_card_path): i += 1 assert i == 7
def do_plotting(self): methods = ["ringM", "medianR", "knownC", "hough"] for method in methods: fileName = method + "_extracted" + ".csv" reconstructed_muons_path = os.path.join(self.output_dir, "extractionFiles", fileName) plot_out = os.path.join(self.output_dir, "Plots", method) Plotting = pss.SingleSimulatonPlotting(reconstructed_muons_path, self.simulationTruth_path, plot_out) Plotting.create_all_singleSimulation_plots()
def test_choose_muon_events(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) muEvents = Ssp.choose_muon_events() assert (muEvents == [3, 8, 14, 16, 28, 36, 43, 61, 74, 97]).all()
def test_read_dataFrames_extractedMuons(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) simulation_truth, extracted_muons = Ssp.read_dataframes() assert (len(extracted_muons.keys()) == 7 or len(extracted_muons.keys()) == 4)
def test_create_bins(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) input_data = [1, 2, 3, 4] bin_edges = Ssp.create_bins(input_data) assert (bin_edges == [1, 2.5, 4])
def test_extract_cx_cy_returnsReconstructed(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) returns = Ssp.extract_cx_cy() assert len(returns[4]) == 10 and len(returns[5]) == 10
def test_calculate_r_sq(): Ssp = pss.SingleSimulatonPlotting(reconstructed_muons_path, simulationTruth, output_dir) r_d_sq, r_t_sq = Ssp.calculate_r_sq() assert (len(r_d_sq) == 10 and len(r_t_sq) == 100)
def do_plotting(self): Plotting = pss.SingleSimulatonPlotting(self.extracted_muons, self.simulationTruth, self.plotting_dir) Plotting.create_all_singleSimulation_plots()