(tmp_path)
| 629 | |
| 630 | |
| 631 | def test_ParamQuantEstimation_3(tmp_path): |
| 632 | standard_data = _standard_data_sample |
| 633 | |
| 634 | # 'home_dir' is typically '~', but for testing it is set to 'tmp_dir' |
| 635 | home_dir = tmp_path |
| 636 | config_dir = ".pyxrf" |
| 637 | standards_fln = "quantitative_standards.yaml" |
| 638 | |
| 639 | # Create the file with user-defined reference definitions |
| 640 | file_path = os.path.join(home_dir, config_dir, standards_fln) |
| 641 | save_xrf_standard_yaml_file(file_path, standard_data) |
| 642 | |
| 643 | # Create the object and load references |
| 644 | pqe = ParamQuantEstimation(home_dir=home_dir) |
| 645 | pqe.load_standards() |
| 646 | |
| 647 | # Select first 'user-defined' sample (from '_standard_data_sample' list) |
| 648 | incident_energy = 12.0 |
| 649 | img = gen_xrf_map_dict() |
| 650 | |
| 651 | # Generate and fill fluorescence data dictionary |
| 652 | pqe.set_selected_standard() |
| 653 | pqe.gen_fluorescence_data_dict(incident_energy=incident_energy) |
| 654 | scaler_name = "sclr" |
| 655 | pqe.fill_fluorescence_data_dict(xrf_map_dict=img, scaler_name=scaler_name) |
| 656 | |
| 657 | # Equivalent transformations using functions that are already tested. The sequence |
| 658 | # must give the same result (same functions are called). |
| 659 | qfdd = get_quant_fluor_data_dict(standard_data[0], incident_energy) |
| 660 | fill_quant_fluor_data_dict(qfdd, xrf_map_dict=img, scaler_name=scaler_name) |
| 661 | |
| 662 | assert ( |
| 663 | pqe.fluorescence_data_dict == qfdd |
| 664 | ), "The filled fluorescence data dictionary does not match the expected" |
| 665 | |
| 666 | # Test generation of preview (superficial) |
| 667 | pview, msg_warnings = pqe.get_fluorescence_data_dict_text_preview() |
| 668 | # It is expected that the preview will contain 'WARNING:' |
| 669 | assert len(msg_warnings), "Warning is not found in preview" |
| 670 | # Disable warnings |
| 671 | pview, msg_warnings = pqe.get_fluorescence_data_dict_text_preview(enable_warnings=False) |
| 672 | assert not len(msg_warnings), "Warnings are disabled, but still generated" |
| 673 | |
| 674 | # Test function for setting detector channel name |
| 675 | pqe.set_detector_channel_in_data_dict(detector_channel="sum") |
| 676 | assert pqe.fluorescence_data_dict["detector_channel"] == "sum", "Detector channel was not set correctly" |
| 677 | |
| 678 | # Test function for setting distance to sample |
| 679 | distance_to_sample = 2.5 |
| 680 | pqe.set_distance_to_sample_in_data_dict(distance_to_sample=distance_to_sample) |
| 681 | assert ( |
| 682 | pqe.fluorescence_data_dict["distance_to_sample"] == distance_to_sample |
| 683 | ), "Distance-to-sample was not set correctly" |
| 684 | |
| 685 | # Function for setting Scan ID and Scan UID |
| 686 | scan_id = 65476 |
| 687 | scan_uid = "abcdef-12345678" # Some string |
| 688 |
nothing calls this directly
no test coverage detected