diff --git a/newsfragments/862.misc b/newsfragments/862.misc new file mode 100644 index 000000000..24f32bfb7 --- /dev/null +++ b/newsfragments/862.misc @@ -0,0 +1 @@ +Update dials-data uses for the new always-pathlib dials-data. diff --git a/tests/command_line/test_average.py b/tests/command_line/test_average.py index c18c8985c..2f03ccc01 100644 --- a/tests/command_line/test_average.py +++ b/tests/command_line/test_average.py @@ -14,9 +14,7 @@ def test_average(dials_data, tmp_path, use_mpi): if use_mpi: pytest.importorskip("mpi4py") - data = ( - dials_data("image_examples", pathlib=True) / "SACLA-MPCCD-run266702-0-subset.h5" - ) + data = dials_data("image_examples") / "SACLA-MPCCD-run266702-0-subset.h5" if use_mpi: command = "mpirun" mpargs = "-n 2 dxtbx.image_average --mpi=True".split() diff --git a/tests/command_line/test_dlsnxs2cbf.py b/tests/command_line/test_dlsnxs2cbf.py index 954b3947c..b7a9d3c72 100644 --- a/tests/command_line/test_dlsnxs2cbf.py +++ b/tests/command_line/test_dlsnxs2cbf.py @@ -16,7 +16,7 @@ @pytest.mark.xfail(reason="Broken for old data while collecting new data") def test_dlsnxs2cbf(dials_data, tmp_path, capsys): - screen = dials_data("thaumatin_eiger_screen", pathlib=True) + screen = dials_data("thaumatin_eiger_screen") master = screen / "Therm_6_1_master.h5" run([str(master), "junk_%04d.cbf"]) @@ -48,7 +48,7 @@ def test_dlsnxs2cbf(dials_data, tmp_path, capsys): @pytest.mark.parametrize("remove_axis", ["phi", "chi"], ids=["no phi", "no chi"]) def test_dlsnxs2cbf_deleted_axis(dials_data, tmp_path, remove_axis): """Check that a master file without φ or χ axes processes OK.""" - screen = dials_data("thaumatin_eiger_screen", pathlib=True) + screen = dials_data("thaumatin_eiger_screen") master = "Therm_6_1_master.h5" links = (path.name for path in screen.glob("*") if path.name != master) try: diff --git a/tests/command_line/test_plot_detector_models.py b/tests/command_line/test_plot_detector_models.py index 160e37bb3..cc4657d9f 100644 --- a/tests/command_line/test_plot_detector_models.py +++ b/tests/command_line/test_plot_detector_models.py @@ -6,7 +6,7 @@ def test_plot_models_noninteractive_to_pdf(dials_data, tmp_path): - ssx = dials_data("cunir_serial_processed", pathlib=True) + ssx = dials_data("cunir_serial_processed") expts = str(ssx / "imported_no_ref_5.expt") subprocess.run( [shutil.which("dxtbx.plot_detector_models"), expts, "pdf_file=plot_test.pdf"], diff --git a/tests/command_line/test_print_header.py b/tests/command_line/test_print_header.py index e4f1a7f95..006bf653d 100644 --- a/tests/command_line/test_print_header.py +++ b/tests/command_line/test_print_header.py @@ -4,7 +4,7 @@ def test_print_header(dials_data, capsys): - screen = dials_data("thaumatin_eiger_screen", pathlib=True) + screen = dials_data("thaumatin_eiger_screen") master = screen / "Therm_6_1_master.h5" print_header.run([str(master)]) diff --git a/tests/command_line/test_show_mask_info.py b/tests/command_line/test_show_mask_info.py index 0df50d7c7..0cc3b7204 100644 --- a/tests/command_line/test_show_mask_info.py +++ b/tests/command_line/test_show_mask_info.py @@ -4,7 +4,7 @@ def test_show_mask_info(dials_data, capsys): - data = dials_data("image_examples", pathlib=True) / "dectris_eiger_master.h5" + data = dials_data("image_examples") / "dectris_eiger_master.h5" show_mask_info.run([str(data)]) captured = capsys.readouterr() diff --git a/tests/format/test_FormatCBFFullPilatusDLS6MSN126.py b/tests/format/test_FormatCBFFullPilatusDLS6MSN126.py index cc16b34f4..056006762 100644 --- a/tests/format/test_FormatCBFFullPilatusDLS6MSN126.py +++ b/tests/format/test_FormatCBFFullPilatusDLS6MSN126.py @@ -8,9 +8,7 @@ def test_DLS_I03_smargon(dials_data): - filename = ( - dials_data("image_examples", pathlib=True) / "DLS_I03_smargon_0001.cbf.gz" - ) + filename = dials_data("image_examples") / "DLS_I03_smargon_0001.cbf.gz" assert FormatCBFFullPilatusDLS6MSN126.understand(filename) expts = ExperimentListFactory.from_filenames( [filename], format_kwargs={"dynamic_shadowing": True} diff --git a/tests/format/test_FormatCBFMiniEigerDLS16MSN160.py b/tests/format/test_FormatCBFMiniEigerDLS16MSN160.py index 60093dca5..787e4fd54 100644 --- a/tests/format/test_FormatCBFMiniEigerDLS16MSN160.py +++ b/tests/format/test_FormatCBFMiniEigerDLS16MSN160.py @@ -8,9 +8,7 @@ def test_dlsnxs2cbf_therm(dials_data): - filename = ( - dials_data("image_examples", pathlib=True) / "dlsnxs2cbf_therm_0001.cbf.gz" - ) + filename = dials_data("image_examples") / "dlsnxs2cbf_therm_0001.cbf.gz" assert FormatCBFMiniEigerDLS16MSN160.understand(filename) expts = ExperimentListFactory.from_filenames( diff --git a/tests/format/test_FormatCBFMiniPilatus.py b/tests/format/test_FormatCBFMiniPilatus.py index 408bc457a..379f02566 100644 --- a/tests/format/test_FormatCBFMiniPilatus.py +++ b/tests/format/test_FormatCBFMiniPilatus.py @@ -7,7 +7,7 @@ def test_single_panel(dials_data, tmpdir): - filename = dials_data("x4wide", pathlib=True) / "X4_wide_M1S4_2_0001.cbf" + filename = dials_data("x4wide") / "X4_wide_M1S4_2_0001.cbf" assert FormatCBFMiniPilatus.understand(filename) expts = ExperimentListFactory.from_filenames([filename]) @@ -17,7 +17,7 @@ def test_single_panel(dials_data, tmpdir): def test_multi_panel(dials_data, tmpdir): - filename = dials_data("x4wide", pathlib=True) / "X4_wide_M1S4_2_0001.cbf" + filename = dials_data("x4wide") / "X4_wide_M1S4_2_0001.cbf" assert FormatCBFMiniPilatus.understand(filename) expts = ExperimentListFactory.from_filenames( diff --git a/tests/format/test_FormatCBFMiniPilatusDLS12M.py b/tests/format/test_FormatCBFMiniPilatusDLS12M.py index 6ead704fa..cc1082d0c 100644 --- a/tests/format/test_FormatCBFMiniPilatusDLS12M.py +++ b/tests/format/test_FormatCBFMiniPilatusDLS12M.py @@ -56,9 +56,7 @@ def test_bad_pixel_mask(timestamp, multi_panel, masked_pixel_count, dials_data, ) mocked_timestamp.return_value = timestamp - image_path = str( - dials_data("image_examples", pathlib=True) / "DLS_I23-germ_13KeV_0001.cbf.bz2" - ) + image_path = str(dials_data("image_examples") / "DLS_I23-germ_13KeV_0001.cbf.bz2") experiments = ExperimentListFactory.from_filenames( [image_path], format_kwargs={"multi_panel": multi_panel} ) diff --git a/tests/format/test_FormatHDF5EigerNearlyNexus.py b/tests/format/test_FormatHDF5EigerNearlyNexus.py index 828a12348..73a6a43cb 100644 --- a/tests/format/test_FormatHDF5EigerNearlyNexus.py +++ b/tests/format/test_FormatHDF5EigerNearlyNexus.py @@ -33,7 +33,7 @@ def test_biomax_vertical_goniometer_at_diamond(tmpdir): def test_semi_synthetic_dectris_eiger_nearly_nexus(dials_data, tmpdir): - master_h5 = dials_data("image_examples", pathlib=True) / "dectris_eiger_master.h5" + master_h5 = dials_data("image_examples") / "dectris_eiger_master.h5" if not os.access(master_h5, os.R_OK): pytest.skip("Test images not available") diff --git a/tests/format/test_FormatHDF5EigerNearlyNexusSPring8.py b/tests/format/test_FormatHDF5EigerNearlyNexusSPring8.py index 458046a96..b2bb84318 100644 --- a/tests/format/test_FormatHDF5EigerNearlyNexusSPring8.py +++ b/tests/format/test_FormatHDF5EigerNearlyNexusSPring8.py @@ -11,7 +11,7 @@ def test_spring8_ccp4_2018_zenodo_1443110_data03(dials_data): master_h5 = ( - dials_data("spring8_ccp4_2018", pathlib=True) + dials_data("spring8_ccp4_2018") / "ccp4school2018_bl41xu" / "05" / "data03" diff --git a/tests/format/test_FormatHDF5SaclaMPCCD.py b/tests/format/test_FormatHDF5SaclaMPCCD.py index 1be1f97c7..692ef8018 100644 --- a/tests/format/test_FormatHDF5SaclaMPCCD.py +++ b/tests/format/test_FormatHDF5SaclaMPCCD.py @@ -15,10 +15,7 @@ def test_static_mask(dials_data): - master_h5 = ( - dials_data("image_examples", pathlib=True) - / "SACLA-MPCCD-Phase3-21528-5images.h5" - ) + master_h5 = dials_data("image_examples") / "SACLA-MPCCD-Phase3-21528-5images.h5" assert FormatHDF5SaclaMPCCD.understand(master_h5) expts_from_filename = ExperimentListFactory.from_filenames([master_h5]) @@ -35,10 +32,7 @@ def test_static_mask(dials_data): def test_MPCCD_Phase3_21528(dials_data): - master_h5 = ( - dials_data("image_examples", pathlib=True) - / "SACLA-MPCCD-Phase3-21528-5images.h5" - ) + master_h5 = dials_data("image_examples") / "SACLA-MPCCD-Phase3-21528-5images.h5" assert FormatHDF5SaclaMPCCD.understand(master_h5) expts = ExperimentListFactory.from_filenames([master_h5]) imageset = expts[0].imageset @@ -81,10 +75,7 @@ def test_MPCCD_RECONST_MODE(dials_data, monkeypatch): else: monkeypatch.delenv("MPCCD_RECONST_MODE", raising=False) - master_h5 = ( - dials_data("image_examples", pathlib=True) - / "SACLA-MPCCD-Phase3-21528-5images.h5" - ) + master_h5 = dials_data("image_examples") / "SACLA-MPCCD-Phase3-21528-5images.h5" expts = ExperimentListFactory.from_filenames([master_h5]) imageset = expts[0].imageset # Horrible hack to work around format_instance caching @@ -107,10 +98,7 @@ def test_MPCCD_RECONST_MODE(dials_data, monkeypatch): def test_combine_with_user_static_mask(dials_data, tmpdir): - master_h5 = ( - dials_data("image_examples", pathlib=True) - / "SACLA-MPCCD-Phase3-21528-5images.h5" - ) + master_h5 = dials_data("image_examples") / "SACLA-MPCCD-Phase3-21528-5images.h5" assert FormatHDF5SaclaMPCCD.understand(master_h5) expts_from_filename = ExperimentListFactory.from_filenames([master_h5]) @@ -154,7 +142,7 @@ def test_HDF5_format_caching(dials_data, clear_cache): xfail: see https://github.com/cctbx/dxtbx/issues/245 """ img_file = "SACLA-MPCCD-Phase3-21528-5images.h5" - master_h5 = dials_data("image_examples", pathlib=True) / img_file + master_h5 = dials_data("image_examples") / img_file expts1 = ExperimentListFactory.from_filenames([master_h5]) expts1[0].imageset.get_mask(0) diff --git a/tests/format/test_FormatISISSXD.py b/tests/format/test_FormatISISSXD.py index cf01e6e81..f4d87597c 100644 --- a/tests/format/test_FormatISISSXD.py +++ b/tests/format/test_FormatISISSXD.py @@ -9,7 +9,7 @@ @pytest.fixture(scope="session") def nacl(dials_data): - location = dials_data("isis_sxd_example_data", pathlib=True) + location = dials_data("isis_sxd_example_data") nacl_filename = join(location, "sxd_nacl_run.nxs") return nacl_filename diff --git a/tests/format/test_FormatNXmxDLS16M.py b/tests/format/test_FormatNXmxDLS16M.py index a9ba1d2a1..6fabbca49 100644 --- a/tests/format/test_FormatNXmxDLS16M.py +++ b/tests/format/test_FormatNXmxDLS16M.py @@ -182,9 +182,7 @@ def test_grid_scan_i04(): raises=AssertionError, reason="https://github.com/cctbx/dxtbx/issues/13" ) def test_screening(dials_data): - master_h5 = ( - dials_data("thaumatin_eiger_screen", pathlib=True) / "Therm_6_1_master.h5" - ) + master_h5 = dials_data("thaumatin_eiger_screen") / "Therm_6_1_master.h5" assert FormatNXmxDLS16M.understand(master_h5) expts = ExperimentListFactory.from_filenames([master_h5]) diff --git a/tests/format/test_FormatPYunspecified.py b/tests/format/test_FormatPYunspecified.py index 282a99ecb..1a2418c58 100644 --- a/tests/format/test_FormatPYunspecified.py +++ b/tests/format/test_FormatPYunspecified.py @@ -5,7 +5,7 @@ def test_static_mask(dials_data): - data_dir = dials_data("image_examples", pathlib=True) + data_dir = dials_data("image_examples") filename = str( data_dir / "LCLS_CXI-shot-s00-2011-12-02T21_07Z29.723_00569.pickle", ) diff --git a/tests/format/test_FormatSMVADSC.py b/tests/format/test_FormatSMVADSC.py index e23a0fe07..21ad9f2d7 100644 --- a/tests/format/test_FormatSMVADSC.py +++ b/tests/format/test_FormatSMVADSC.py @@ -6,7 +6,7 @@ def test_noninteger_pedestal(dials_data, tmpdir): - data_dir = dials_data("image_examples", pathlib=True) + data_dir = dials_data("image_examples") filename = str(data_dir / "APS_14BMC-q315_1_001.img.bz2") # Read this file in as data with bz2.open(filename, "rb") as f: diff --git a/tests/format/test_cbf_mini_as_file.py b/tests/format/test_cbf_mini_as_file.py index d8f8b5cdd..d0d24d34f 100644 --- a/tests/format/test_cbf_mini_as_file.py +++ b/tests/format/test_cbf_mini_as_file.py @@ -20,7 +20,7 @@ ], ) def test_cbf_writer(image_file, dials_data, tmp_path): - data_dir = dials_data("image_examples", pathlib=True) + data_dir = dials_data("image_examples") filename = str(data_dir / image_file) imageset = ExperimentListFactory.from_filenames([filename])[0].imageset output_file = tmp_path / "image_0001.cbf" diff --git a/tests/format/test_format.py b/tests/format/test_format.py index 806af7d86..1287a44f5 100644 --- a/tests/format/test_format.py +++ b/tests/format/test_format.py @@ -4,7 +4,7 @@ def test_reading_refl_failure(dials_data): - test_data = dials_data("centroid_test_data", pathlib=True) + test_data = dials_data("centroid_test_data") assert Registry.get_format_class_for_file(test_data / "indexed.refl") is None # Check .expt while here diff --git a/tests/format/test_nexus.py b/tests/format/test_nexus.py index cc405b381..eb3d41c83 100644 --- a/tests/format/test_nexus.py +++ b/tests/format/test_nexus.py @@ -67,7 +67,7 @@ def nexus_file(tmp_path_factory) -> Path: def test_data_factory_nxs(dials_data): - nxs_file = dials_data("vmxi_thaumatin", pathlib=True) / "image_15799.nxs" + nxs_file = dials_data("vmxi_thaumatin") / "image_15799.nxs" with h5py.File(nxs_file) as fh: data = fh["/entry/data"] data_factory = nexus.DataFactory(nexus.NXdata(data)) diff --git a/tests/imagelist.py b/tests/imagelist.py index 20e097726..be03cfb39 100644 --- a/tests/imagelist.py +++ b/tests/imagelist.py @@ -5,7 +5,7 @@ import dials_data.download df = dials_data.download.DataFetcher() -data_dir = df("image_examples", pathlib=True) +data_dir = df("image_examples") image_examples = [] for f in data_dir.iterdir(): ext = os.path.splitext(f)[1] diff --git a/tests/masking/test_masking.py b/tests/masking/test_masking.py index 1ee31d245..17d138e51 100644 --- a/tests/masking/test_masking.py +++ b/tests/masking/test_masking.py @@ -121,8 +121,7 @@ def _construct_shadow_masker(goniometer): @pytest.fixture def dls_i23_experiment(dials_data): experiments_file = str( - dials_data("shadow_test_data", pathlib=True) - / "DLS_I23_Kappa-data_1_0400.cbf.gz" + dials_data("shadow_test_data") / "DLS_I23_Kappa-data_1_0400.cbf.gz" ) experiments = ExperimentListFactory.from_filenames([experiments_file]) return experiments[0] diff --git a/tests/model/test_detector.py b/tests/model/test_detector.py index ed6cc49db..5934d6d74 100644 --- a/tests/model/test_detector.py +++ b/tests/model/test_detector.py @@ -333,7 +333,7 @@ def test_get_detector_projection_2d_axes(): def test_get_panel_projection_2d_from_axes(dials_data): # Get test data pytest.importorskip("h5py") - filename = dials_data("image_examples", pathlib=True) / "dectris_eiger_master.h5" + filename = dials_data("image_examples") / "dectris_eiger_master.h5" experiment = ExperimentListFactory.from_filenames([filename])[0] detector = experiment.detector diff --git a/tests/model/test_experiment_list.py b/tests/model/test_experiment_list.py index 6909ccf6f..3334adcf7 100644 --- a/tests/model/test_experiment_list.py +++ b/tests/model/test_experiment_list.py @@ -41,7 +41,7 @@ @pytest.fixture(scope="session") def centroid_test_data(dials_data): - return str(dials_data("centroid_test_data", pathlib=True)) + return str(dials_data("centroid_test_data")) @pytest.fixture @@ -88,7 +88,7 @@ def all_image_examples(dials_data): ("SSRL_bl111-mar325_1_001.mccd.bz2"), ("xia2-merge2cbf_averaged_0001.cbf.bz2"), ) - return [str(dials_data("image_examples", pathlib=True) / f) for f in filenames] + return [str(dials_data("image_examples") / f) for f in filenames] @pytest.fixture @@ -173,10 +173,8 @@ def test_experiment_equality(): def test_experiment_consistent(dials_data): # Create a sequence - sequence_filenames = dials_data("centroid_test_data", pathlib=False).listdir( - "centroid*.cbf" - ) - sequence = ImageSetFactory.new(sorted(f.strpath for f in sequence_filenames))[0] + sequence_filenames = dials_data("centroid_test_data").glob("centroid*.cbf") + sequence = ImageSetFactory.new(sorted(str(f) for f in sequence_filenames))[0] # Create experiment with sequence and good scan e = Experiment(imageset=sequence, scan=sequence.get_scan()) @@ -405,7 +403,7 @@ def experiment_list(): def test_experimentlist_factory_from_json(monkeypatch, dials_data): - data_dir = dials_data("experiment_test_data", pathlib=True) + data_dir = dials_data("experiment_test_data") dials_data_root = data_dir / ".." # Get all the filenames filename1 = str(data_dir / "experiment_1.json") @@ -442,7 +440,7 @@ def test_experimentlist_factory_from_json(monkeypatch, dials_data): def test_experimentlist_factory_from_pickle(monkeypatch, dials_data): - data_dir = dials_data("experiment_test_data", pathlib=True) + data_dir = dials_data("experiment_test_data") dials_data_root = data_dir / ".." # Get all the filenames filename1 = str(data_dir / "experiment_1.json") @@ -472,7 +470,7 @@ def test_experimentlist_factory_from_pickle(monkeypatch, dials_data): def test_experimentlist_factory_from_args(monkeypatch, dials_data): pytest.importorskip("dials") - data_dir = dials_data("experiment_test_data", pathlib=True) + data_dir = dials_data("experiment_test_data") dials_data_root = data_dir / ".." # Get all the filenames @@ -538,7 +536,7 @@ def test_experimentlist_factory_from_sequence(): def test_experimentlist_dumper_dump_formats(monkeypatch, dials_data, tmp_path): - data_dir = dials_data("experiment_test_data", pathlib=True) + data_dir = dials_data("experiment_test_data") dials_data_root = data_dir / ".." # Get all the filenames @@ -563,7 +561,7 @@ def test_experimentlist_dumper_dump_formats(monkeypatch, dials_data, tmp_path): def test_experimentlist_dumper_dump_scan_varying(monkeypatch, dials_data, tmp_path): - data_dir = dials_data("experiment_test_data", pathlib=True) + data_dir = dials_data("experiment_test_data") dials_data_root = data_dir / ".." # Get all the filenames filename1 = str(data_dir / "experiment_1.json") @@ -622,7 +620,7 @@ def test_experimentlist_dumper_dump_empty_sequence(tmp_path): def test_experimentlist_dumper_dump_with_lookup(dials_data, tmp_path): - data_dir = dials_data("centroid_test_data", pathlib=True) + data_dir = dials_data("centroid_test_data") # Copy to the tmp directory, because we need to unpack some files filename = shutil.copy(data_dir / "experiments_with_lookup.json", tmp_path) @@ -668,10 +666,7 @@ def test_experimentlist_dumper_dump_with_lookup(dials_data, tmp_path): def test_experimentlist_dumper_dump_with_bad_lookup(dials_data, tmpdir): - filename = ( - dials_data("centroid_test_data", pathlib=True) - / "experiments_with_bad_lookup.json" - ) + filename = dials_data("centroid_test_data") / "experiments_with_bad_lookup.json" experiments = ExperimentListFactory.from_json_file(filename, check_format=False) imageset = experiments[0].imageset @@ -734,9 +729,7 @@ def test_experimentlist_with_identifiers(): def test_load_models(dials_data): pytest.importorskip("h5py") - filename = ( - dials_data("image_examples", pathlib=True) / "SACLA-MPCCD-run266702-0-subset.h5" - ) + filename = dials_data("image_examples") / "SACLA-MPCCD-run266702-0-subset.h5" # Test different ways of loading the data waves1, waves2, waves3, waves4, waves5 = [], [], [], [], [] @@ -849,7 +842,7 @@ def compare_experiment(exp1, exp2): def test_experimentlist_from_file(dials_data, monkeypatch, tmpdir): # With the default check_format=True this file should fail to load with an # appropriate error as we can't find the images on disk - data_dir = dials_data("experiment_test_data", pathlib=True) + data_dir = dials_data("experiment_test_data") dials_data_root = data_dir / ".." with monkeypatch.context() as m: @@ -880,10 +873,7 @@ def test_experimentlist_from_file(dials_data, monkeypatch, tmpdir): def test_experimentlist_imagesequence_stills(dials_data): filenames = [ - str( - dials_data("thaumatin_grid_scan", pathlib=True) - / f"thau_3_2_{i:04d}.cbf.bz2" - ) + str(dials_data("thaumatin_grid_scan") / f"thau_3_2_{i:04d}.cbf.bz2") for i in range(1, 4) ] experiments = ExperimentListFactory.from_filenames(filenames) @@ -967,8 +957,7 @@ def test_experimentlist_change_basis(dials_data): for i in range(4): experiments.extend( ExperimentList.from_file( - dials_data("vmxi_proteinase_k_sweeps", pathlib=True) - / ("experiments_%i.expt" % i), + dials_data("vmxi_proteinase_k_sweeps") / ("experiments_%i.expt" % i), check_format=False, ) ) @@ -1204,7 +1193,7 @@ def test_from_null_sequence(): def test_from_templates(dials_data): - template = dials_data("insulin", pathlib=True) / "insulin_1_###.img" + template = dials_data("insulin") / "insulin_1_###.img" expts = ExperimentList.from_templates([template]) assert len(expts) == 1 assert expts[0].imageset.get_template() == str(template) diff --git a/tests/model/test_parallax_correction.py b/tests/model/test_parallax_correction.py index 1c233cd11..fad744489 100644 --- a/tests/model/test_parallax_correction.py +++ b/tests/model/test_parallax_correction.py @@ -21,7 +21,7 @@ def correct_gold(detector, attlen, xy): def test_run(dials_data): - filename = str(dials_data("misc_regression", pathlib=True) / "sim_mx-GXPARM.XDS") + filename = str(dials_data("misc_regression") / "sim_mx-GXPARM.XDS") models = dxtbx.load(filename) detector = models.get_detector() diff --git a/tests/model/test_pixel_to_millimeter.py b/tests/model/test_pixel_to_millimeter.py index 2e131f131..8409c3ed1 100644 --- a/tests/model/test_pixel_to_millimeter.py +++ b/tests/model/test_pixel_to_millimeter.py @@ -25,7 +25,7 @@ @pytest.fixture def model(dials_data): - filename = str(dials_data("misc_regression", pathlib=True) / "sim_mx-GXPARM.XDS") + filename = str(dials_data("misc_regression") / "sim_mx-GXPARM.XDS") models = dxtbx.load(filename) detector = models.get_detector() diff --git a/tests/nexus/test_jf16M.py b/tests/nexus/test_jf16M.py index 195b54150..b3c974715 100644 --- a/tests/nexus/test_jf16M.py +++ b/tests/nexus/test_jf16M.py @@ -7,7 +7,7 @@ def test_jf16M_matches_expected_hierarchy(dials_data): try: h5path = ( - dials_data("lysozyme_JF16M_4img", pathlib=True) + dials_data("lysozyme_JF16M_4img") / "lyso009a_0087.JF07T32V01_master_4img.h5" ) except Exception as e: @@ -18,7 +18,7 @@ def test_jf16M_matches_expected_hierarchy(dials_data): d1 = img.get_detector() expts_path = ( - dials_data("lysozyme_JF16M_4img", pathlib=True) + dials_data("lysozyme_JF16M_4img") / "lyso009a_0087.JF07T32V01_master_4img_imported.expt" ) expts = ExperimentList.from_file(expts_path, check_format=False) diff --git a/tests/nexus/test_mpccd_nexus.py b/tests/nexus/test_mpccd_nexus.py index 433924b4b..5856ac4b3 100644 --- a/tests/nexus/test_mpccd_nexus.py +++ b/tests/nexus/test_mpccd_nexus.py @@ -10,10 +10,7 @@ def test_mpccd_nexus_gain(dials_data): """ try: - h5path = ( - dials_data("image_examples", pathlib=True) - / "SACLA-MPCCD-run197287-0-nexus.h5" - ) + h5path = dials_data("image_examples") / "SACLA-MPCCD-run197287-0-nexus.h5" except Exception as e: print(type(e), str(e)) raise diff --git a/tests/nexus/test_nxmx_writer.py b/tests/nexus/test_nxmx_writer.py index c70adf223..2477377fe 100644 --- a/tests/nexus/test_nxmx_writer.py +++ b/tests/nexus/test_nxmx_writer.py @@ -18,8 +18,7 @@ def test_writer_jf16M(dials_data, tmpdir): h5path = ( - dials_data("lysozyme_JF16M_4img", pathlib=True) - / "lyso009a_0087.JF07T32V01_master_4img.h5" + dials_data("lysozyme_JF16M_4img") / "lyso009a_0087.JF07T32V01_master_4img.h5" ) with h5py.File(h5path) as handle: output_file = tmpdir / "4img.h5" @@ -66,7 +65,7 @@ def recursive_test(pg1, pg2): def test_writer_x4wide(dials_data, tmpdir): - cbfspath = dials_data("x4wide", pathlib=True) / "X4_wide_M1S4_2_000*.cbf" + cbfspath = dials_data("x4wide") / "X4_wide_M1S4_2_000*.cbf" output_file = tmpdir / "x4wide_10img.h5" params = phil_scope.fetch( diff --git a/tests/serialize/test_xds.py b/tests/serialize/test_xds.py index f3f182012..07d201122 100644 --- a/tests/serialize/test_xds.py +++ b/tests/serialize/test_xds.py @@ -9,7 +9,7 @@ def test_to_xds(dials_data, tmpdir): - file_names = dials_data("centroid_test_data", pathlib=True).glob("centroid_00*.cbf") + file_names = dials_data("centroid_test_data").glob("centroid_00*.cbf") sequence = ImageSetFactory.new(list(file_names))[0] to_xds = xds.to_xds(sequence) s1 = to_xds.XDS_INP() @@ -49,7 +49,7 @@ def test_to_xds(dials_data, tmpdir): UNTRUSTED_RECTANGLE= 0 2464 2315 2333 DATA_RANGE= 1 9 JOB=XYCORR INIT COLSPOT IDXREF DEFPIX INTEGRATE CORRECT\ -""" % (dials_data("centroid_test_data", pathlib=True) / "centroid_????.cbf") +""" % (dials_data("centroid_test_data") / "centroid_????.cbf") # universe changed once, so be flexible expected = [expected_f % a for a in ["3.960382", "3.960386"]] @@ -80,7 +80,7 @@ def test_to_xds(dials_data, tmpdir): def test_to_xds_multi_panel_i23(dials_data, tmpdir, mocker): - data_dir = dials_data("image_examples", pathlib=True) + data_dir = dials_data("image_examples") file_name = str(data_dir / "DLS_I23-germ_13KeV_0001.cbf.bz2") sequence = ImageSetFactory.new([file_name])[0] to_xds = xds.to_xds(sequence) @@ -121,7 +121,7 @@ def test_to_xds_multi_panel_i23(dials_data, tmpdir, mocker): def test_vmxi_thaumatin(dials_data): - master_h5 = dials_data("vmxi_thaumatin", pathlib=True) / "image_15799_master.h5" + master_h5 = dials_data("vmxi_thaumatin") / "image_15799_master.h5" expts = ExperimentListFactory.from_filenames([master_h5]) to_xds = xds.to_xds(expts[0].imageset) s = to_xds.XDS_INP() @@ -163,6 +163,6 @@ def test_xds_to_imageset(tmp_path, dials_data): f.write(input_file) ## Note that the XDS.INP is for thaumatin, and centroid test data is not, but ## this is sufficient for testing the creation of an imageset of the correct size. - xds_other = dials_data("centroid_test_data", pathlib=True) / "INTEGRATE.HKL" + xds_other = dials_data("centroid_test_data") / "INTEGRATE.HKL" iset = xds.to_imageset(xds_inp, xds_other) assert len(iset) == 100 diff --git a/tests/test_FormatCBFFull.py b/tests/test_FormatCBFFull.py index a345cef5b..7b208c431 100644 --- a/tests/test_FormatCBFFull.py +++ b/tests/test_FormatCBFFull.py @@ -6,7 +6,7 @@ def test_multi_axis_goniometer(dials_data): - data_dir = dials_data("misc_regression", pathlib=True) + data_dir = dials_data("misc_regression") imgset = ImageSetFactory.new(str(data_dir / "dials-190_01_00001.cbf"))[0] gonio = imgset.get_goniometer(0) @@ -33,7 +33,7 @@ def test_multi_axis_goniometer(dials_data): def test_still(dials_data): - data_dir = dials_data("image_examples", pathlib=True) + data_dir = dials_data("image_examples") imgset = ImageSetFactory.new(str(data_dir / "DLS_I04-grid_full_cbf_0005.cbf.bz2"))[ 0 diff --git a/tests/test_filecache.py b/tests/test_filecache.py index f9f962fc4..e5d66bcb5 100644 --- a/tests/test_filecache.py +++ b/tests/test_filecache.py @@ -82,7 +82,7 @@ def test_filecache(): def test_filecache_more(dials_data): - data_dir = dials_data("image_examples", pathlib=True) + data_dir = dials_data("image_examples") filename = str(data_dir / "MacScience-reallysurprise_001.ipf") cache = dxtbx.filecache.lazy_file_cache(open(filename, "rb")) with dxtbx.filecache.pseudo_file(cache) as fh: diff --git a/tests/test_image_readers.py b/tests/test_image_readers.py index 508506e68..6242f2d60 100644 --- a/tests/test_image_readers.py +++ b/tests/test_image_readers.py @@ -15,7 +15,7 @@ def cbf_read_buffer(handle, contents, flags): def test_cbf_buffer(dials_data): - data_dir = dials_data("misc_regression", pathlib=True) + data_dir = dials_data("misc_regression") filename = str(data_dir / "dials-190_01_00001.cbf") with open(filename, "rb") as f: contents = f.read() diff --git a/tests/test_imageset.py b/tests/test_imageset.py index adda72624..b67704b93 100644 --- a/tests/test_imageset.py +++ b/tests/test_imageset.py @@ -34,10 +34,7 @@ def dummy_beam(): "_beam", side_effect=dummy_beam, ) as obj: - filename = ( - dials_data("image_examples", pathlib=True) - / "SACLA-MPCCD-run266702-0-subset.h5" - ) + filename = dials_data("image_examples") / "SACLA-MPCCD-run266702-0-subset.h5" format_class = dxtbx.format.Registry.get_format_class_for_file(filename) iset = format_class.get_imageset( [filename], single_file_indices=indices, format_kwargs={"lazy": lazy} @@ -194,7 +191,7 @@ def test_imagesetdata(centroid_files): @pytest.fixture(scope="session") def centroid_files(dials_data): return [ - str(dials_data("centroid_test_data", pathlib=True) / f"centroid_{i:04d}.cbf") + str(dials_data("centroid_test_data") / f"centroid_{i:04d}.cbf") for i in range(1, 10) ] @@ -462,9 +459,7 @@ def tst_set_models(sequence): @pytest.mark.parametrize("lazy", (True, False)) def test_SACLA_MPCCD_Cheetah_File(dials_data, lazy): pytest.importorskip("h5py") - filename = ( - dials_data("image_examples", pathlib=True) / "SACLA-MPCCD-run266702-0-subset.h5" - ) + filename = dials_data("image_examples") / "SACLA-MPCCD-run266702-0-subset.h5" format_class = dxtbx.format.Registry.get_format_class_for_file(filename) @@ -499,7 +494,7 @@ def test_imagesetfactory(centroid_files, dials_data): assert isinstance(sequence[0], ImageSequence) - template = str(dials_data("centroid_test_data", pathlib=True) / "centroid_####.cbf") + template = str(dials_data("centroid_test_data") / "centroid_####.cbf") image_range = (3, 6) sequence = ImageSetFactory.from_template(template, image_range) @@ -524,8 +519,7 @@ def test_imagesetfactory(centroid_files, dials_data): def test_make_sequence_with_percent_character(dials_data, tmp_path): images = [ - dials_data("centroid_test_data", pathlib=True) / f"centroid_{i:04}.cbf" - for i in range(1, 10) + dials_data("centroid_test_data") / f"centroid_{i:04}.cbf" for i in range(1, 10) ] directory = tmp_path / "test%" directory.mkdir() @@ -620,9 +614,7 @@ def test_get_corrected_data(centroid_files): def test_multi_panel_gain_map(dials_data): pytest.importorskip("h5py") - filename = ( - dials_data("image_examples", pathlib=True) / "SACLA-MPCCD-run266702-0-subset.h5" - ) + filename = dials_data("image_examples") / "SACLA-MPCCD-run266702-0-subset.h5" format_class = dxtbx.format.Registry.get_format_class_for_file(filename) iset = format_class.get_imageset([filename]) @@ -644,9 +636,7 @@ def test_multi_panel_gain_map(dials_data): ), ) def test_multi_panel(multi_panel, expected_panel_count, dials_data): - image_path = str( - dials_data("image_examples", pathlib=True) / "DLS_I23-germ_13KeV_0001.cbf.bz2" - ) + image_path = str(dials_data("image_examples") / "DLS_I23-germ_13KeV_0001.cbf.bz2") experiments = ExperimentListFactory.from_filenames( [image_path], format_kwargs={"multi_panel": multi_panel} ) @@ -659,10 +649,8 @@ def test_multi_panel(multi_panel, expected_panel_count, dials_data): def test_scan_imageset_slice_consistency(dials_data): - files = dials_data("centroid_test_data", pathlib=False).listdir("*.cbf", sort=True)[ - 1: - ] - expt = ExperimentListFactory.from_filenames(f.strpath for f in files)[0] + files = sorted(dials_data("centroid_test_data").glob("*.cbf"))[1:] + expt = ExperimentListFactory.from_filenames(str(f) for f in files)[0] assert expt.scan[0:8] == expt.scan # The following doesn't work, and expects expt.imageset[1:9] assert expt.imageset[0:8] == expt.imageset diff --git a/tests/test_sequence_filenames.py b/tests/test_sequence_filenames.py index 52be526b2..df9a40411 100644 --- a/tests/test_sequence_filenames.py +++ b/tests/test_sequence_filenames.py @@ -25,12 +25,12 @@ def test_template_regex(filename, template, digits): def test_template_image_range(dials_data): - template = str(dials_data("insulin", pathlib=True) / "insulin_1_###.img") + template = str(dials_data("insulin") / "insulin_1_###.img") assert template_image_range(template) == (1, 45) def test_template_image_range_non_zero_padded(dials_data, tmp_path): - images = sorted(dials_data("insulin", pathlib=True).glob("insulin_1_0[0-1]*")) + images = sorted(dials_data("insulin").glob("insulin_1_0[0-1]*")) # symlink if possible, copy if necessary for i, image in enumerate(images): try: diff --git a/tests/test_split_singleimage_imageset.py b/tests/test_split_singleimage_imageset.py index efdada48b..a37d7f3a4 100644 --- a/tests/test_split_singleimage_imageset.py +++ b/tests/test_split_singleimage_imageset.py @@ -11,9 +11,7 @@ def test_split_single_image_imageset(dials_data, tmpdir): pytest.importorskip("h5py") - sacla_file = ( - dials_data("image_examples", pathlib=True) / "SACLA-MPCCD-run266702-0-subset.h5" - ) + sacla_file = dials_data("image_examples") / "SACLA-MPCCD-run266702-0-subset.h5" expts = ExperimentListFactory.from_filenames([sacla_file]) assert len(expts) == 4 subset = expts[2:3]