Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 19, 2024
1 parent 6c248e4 commit 1d0b88d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions reciprocalspaceship/io/dials.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def _read_dials_stills_ray(fnames, unitcell, spacegroup, numjobs=10, extra_cols=

def dials_to_mtz_dtypes(ds, inplace=True):
"""
Coerce the dtypes in ds into ones that can be written to an mtz file.
Coerce the dtypes in ds into ones that can be written to an mtz file.
This will downcast doubles to single precision. If "variance" columns
are present, they will be converted to "sigma" and assigned
are present, they will be converted to "sigma" and assigned
StandardDeviationDtype.
Parameters
Expand Down Expand Up @@ -226,7 +226,7 @@ def read_dials_stills(
"""
Read reflections from still images processed by DIALS from fnames and return
them as a DataSet. By default, this function will not convert the data from
dials into an MTZ compatible format.
dials into an MTZ compatible format.
Parameters
----------
Expand Down
20 changes: 17 additions & 3 deletions tests/io/test_dials.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def make_refls(unit_cell, sg, seed=8675309, file_prefix=""):
ds0.set_index(["H", "K", "L"], inplace=True, drop=True)
return ds0, pack_names


def test_dials_mtz_conversion():
unit_cell = 78, 78, 235, 90, 90, 120
sg = "P 65 2 2"
Expand All @@ -109,16 +110,23 @@ def test_dials_mtz_conversion():
prefix = tdir + "/"
ds0, pack_names = make_refls(unit_cell, sg, file_prefix=prefix)
ds = read_dials_stills(
pack_names, unit_cell, sg, parallel_backend=None, numjobs=1, verbose=False, mtz_dtypes=True
pack_names,
unit_cell,
sg,
parallel_backend=None,
numjobs=1,
verbose=False,
mtz_dtypes=True,
)

mtzout = tdir + '/ds.mtz'
mtzout = tdir + "/ds.mtz"
ds.write_mtz(mtzout)
assert os.path.exists(mtzout)
test_ds = rs.read_mtz(mtzout).reset_index()
for k in ds:
assert np.allclose(ds[k], test_ds[k])


@pytest.mark.parametrize("parallel_backend", ["mpi", "ray"])
@pytest.mark.parametrize("mtz_dtypes", [True, False])
def test_dials_reader(parallel_backend, mtz_dtypes, verbose=False):
Expand All @@ -134,7 +142,13 @@ def test_dials_reader(parallel_backend, mtz_dtypes, verbose=False):
ds0, pack_names = make_refls(unit_cell, sg, file_prefix=prefix)
# read without parallelization
ds1 = read_dials_stills(
pack_names, unit_cell, sg, parallel_backend=None, numjobs=1, verbose=verbose, mtz_dtypes=mtz_dtypes
pack_names,
unit_cell,
sg,
parallel_backend=None,
numjobs=1,
verbose=verbose,
mtz_dtypes=mtz_dtypes,
)
gemmi_unit_cell = gemmi.UnitCell(*unit_cell)
gemmi_sg = gemmi.SpaceGroup(sg)
Expand Down

0 comments on commit 1d0b88d

Please sign in to comment.