From 7dbc99fc8043cf81ad24354aeaff71df913a4ae9 Mon Sep 17 00:00:00 2001 From: Jack Greisman Date: Tue, 31 May 2022 17:45:12 -0400 Subject: [PATCH 1/6] Fixes #103: Add interface for setting project, crystal, and dataset names --- reciprocalspaceship/dataset.py | 42 +++++++++++++++++++++++--- reciprocalspaceship/io/mtz.py | 54 ++++++++++++++++++++++++++++------ tests/io/test_mtz.py | 43 ++++++++++++++++++++++++++- 3 files changed, 125 insertions(+), 14 deletions(-) diff --git a/reciprocalspaceship/dataset.py b/reciprocalspaceship/dataset.py index 1ca3279c..1bff6b02 100644 --- a/reciprocalspaceship/dataset.py +++ b/reciprocalspaceship/dataset.py @@ -316,7 +316,13 @@ def from_gemmi(cls, gemmiMtz): """ return cls(gemmiMtz) - def to_gemmi(self, skip_problem_mtztypes=False): + def to_gemmi( + self, + skip_problem_mtztypes=False, + project_name=None, + crystal_name=None, + dataset_name=None, + ): """ Creates gemmi.Mtz object from DataSet object. @@ -332,6 +338,12 @@ def to_gemmi(self, skip_problem_mtztypes=False): skip_problem_mtztypes : bool Whether to skip columns in DataSet that do not have specified MTZ datatypes + project_name : str + Project name to assign to MTZ file + crystal_name : str + Crystal name to assign to MTZ file + dataset_name : str + Dataset name to assign to MTZ file Returns ------- @@ -339,7 +351,9 @@ def to_gemmi(self, skip_problem_mtztypes=False): """ from reciprocalspaceship import io - return io.to_gemmi(self, skip_problem_mtztypes) + return io.to_gemmi( + self, skip_problem_mtztypes, project_name, crystal_name, dataset_name + ) def to_pickle(self, path, *args, **kwargs): """ @@ -471,7 +485,14 @@ def join(self, *args, check_isomorphous=True, **kwargs): result = super().join(*args, **kwargs) return result.__finalize__(self) - def write_mtz(self, mtzfile, skip_problem_mtztypes=False): + def write_mtz( + self, + mtzfile, + skip_problem_mtztypes=False, + project_name=None, + crystal_name=None, + dataset_name=None, + ): """ Write DataSet to MTZ file. @@ -489,10 +510,23 @@ def write_mtz(self, mtzfile, skip_problem_mtztypes=False): skip_problem_mtztypes : bool Whether to skip columns in DataSet that do not have specified MTZ datatypes + project_name : str + Project name to assign to MTZ file + crystal_name : str + Crystal name to assign to MTZ file + dataset_name : str + Dataset name to assign to MTZ file """ from reciprocalspaceship import io - return io.write_mtz(self, mtzfile, skip_problem_mtztypes) + return io.write_mtz( + self, + mtzfile, + skip_problem_mtztypes, + project_name, + crystal_name, + dataset_name, + ) def select_mtzdtype(self, dtype): """ diff --git a/reciprocalspaceship/io/mtz.py b/reciprocalspaceship/io/mtz.py index b9722e43..5eee05bc 100644 --- a/reciprocalspaceship/io/mtz.py +++ b/reciprocalspaceship/io/mtz.py @@ -58,7 +58,13 @@ def from_gemmi(gemmi_mtz): return dataset -def to_gemmi(dataset, skip_problem_mtztypes=False): +def to_gemmi( + dataset, + skip_problem_mtztypes=False, + project_name=None, + crystal_name=None, + dataset_name=None, +): """ Construct gemmi.Mtz object from DataSet @@ -76,6 +82,12 @@ def to_gemmi(dataset, skip_problem_mtztypes=False): skip_problem_mtztypes : bool Whether to skip columns in DataSet that do not have specified mtz datatypes + project_name : str + Project name to assign to MTZ file + crystal_name : str + Crystal name to assign to MTZ file + dataset_name : str + Dataset name to assign to MTZ file Returns ------- @@ -92,7 +104,7 @@ def to_gemmi(dataset, skip_problem_mtztypes=False): ) # Build up a gemmi.Mtz object - mtz = gemmi.Mtz() + mtz = gemmi.Mtz(with_base=True) # Adds HKL_base mtz.cell = dataset.cell mtz.spacegroup = dataset.spacegroup @@ -102,19 +114,28 @@ def to_gemmi(dataset, skip_problem_mtztypes=False): if not all_in_asu: dataset.hkl_to_asu(inplace=True) - # Construct data for Mtz object. + # Add Dataset with indicated names mtz.add_dataset("reciprocalspaceship") + if project_name: + mtz.datasets[1].project_name = project_name + if crystal_name: + mtz.datasets[1].crystal_name = crystal_name + if dataset_name: + mtz.datasets[1].dataset_name = dataset_name + + # Construct data for Mtz object temp = dataset.reset_index() - columns = [] + columns = ["H", "K", "L"] # already in HKL_base for c in temp.columns: cseries = temp[c] if isinstance(cseries.dtype, MTZDtype): - mtzcol = mtz.add_column(label=c, type=cseries.dtype.mtztype) - columns.append(c) + if c not in ["H", "K", "L"]: # HKL already in HKL_base + mtz.add_column(label=c, type=cseries.dtype.mtztype) + columns.append(c) # Special case for CENTRIC and PARTIAL flags elif cseries.dtype.name == "bool" and c in ["CENTRIC", "PARTIAL"]: temp[c] = temp[c].astype("MTZInt") - mtzcol = mtz.add_column(label=c, type="I") + mtz.add_column(label=c, type="I", dataset_id=1) columns.append(c) elif skip_problem_mtztypes: continue @@ -159,7 +180,14 @@ def read_mtz(mtzfile): return from_gemmi(gemmi_mtz) -def write_mtz(dataset, mtzfile, skip_problem_mtztypes=False): +def write_mtz( + dataset, + mtzfile, + skip_problem_mtztypes=False, + project_name=None, + crystal_name=None, + dataset_name=None, +): """ Write an MTZ reflection file from the reflection data in a DataSet. @@ -179,7 +207,15 @@ def write_mtz(dataset, mtzfile, skip_problem_mtztypes=False): skip_problem_mtztypes : bool Whether to skip columns in DataSet that do not have specified MTZ datatypes + project_name : str + Project name to assign to MTZ file + crystal_name : str + Crystal name to assign to MTZ file + dataset_name : str + Dataset name to assign to MTZ file """ - mtz = to_gemmi(dataset, skip_problem_mtztypes) + mtz = to_gemmi( + dataset, skip_problem_mtztypes, project_name, crystal_name, dataset_name + ) mtz.write_to_file(mtzfile) return diff --git a/tests/io/test_mtz.py b/tests/io/test_mtz.py index 9c1ec94e..a07ae26d 100644 --- a/tests/io/test_mtz.py +++ b/tests/io/test_mtz.py @@ -3,7 +3,6 @@ from os.path import exists import gemmi -import numpy as np import pytest from pandas.testing import assert_frame_equal @@ -145,3 +144,45 @@ def test_unmerged_after_write(data_unmerged, in_asu): expected = data_unmerged.copy() data_unmerged.write_mtz("/dev/null") assert_frame_equal(data_unmerged, expected) + + +@pytest.mark.parametrize("project_name", [None, "project", 1]) +@pytest.mark.parametrize("crystal_name", [None, "crystal", 1]) +@pytest.mark.parametrize("dataset_name", [None, "dataset", 1]) +def test_to_gemmi_names(IOtest_mtz, project_name, crystal_name, dataset_name): + """ + Test that DataSet.to_gemmi() sets project/crystal/dataset names when given. + + Values should default to "reciprocalspaceship" when not given + """ + ds = rs.read_mtz(IOtest_mtz) + + if project_name == 1 or crystal_name == 1 or dataset_name == 1: + with pytest.raises(TypeError): + ds.to_gemmi( + project_name=project_name, + crystal_name=crystal_name, + dataset_name=dataset_name, + ) + return + else: + gemmimtz = ds.to_gemmi( + project_name=project_name, + crystal_name=crystal_name, + dataset_name=dataset_name, + ) + + if project_name: + assert gemmimtz.dataset(1).project_name == project_name + else: + assert gemmimtz.dataset(1).project_name == "reciprocalspaceship" + + if crystal_name: + assert gemmimtz.dataset(1).crystal_name == crystal_name + else: + assert gemmimtz.dataset(1).crystal_name == "reciprocalspaceship" + + if dataset_name: + assert gemmimtz.dataset(1).dataset_name == dataset_name + else: + assert gemmimtz.dataset(1).dataset_name == "reciprocalspaceship" From e6dad2e63254ce0420afc16f089bb395dbbfe932 Mon Sep 17 00:00:00 2001 From: Jack Greisman Date: Tue, 31 May 2022 17:59:50 -0400 Subject: [PATCH 2/6] Add tests for DataSet.write_mtz() with mtz hierarchy names --- tests/io/test_mtz.py | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/io/test_mtz.py b/tests/io/test_mtz.py index a07ae26d..88201733 100644 --- a/tests/io/test_mtz.py +++ b/tests/io/test_mtz.py @@ -186,3 +186,53 @@ def test_to_gemmi_names(IOtest_mtz, project_name, crystal_name, dataset_name): assert gemmimtz.dataset(1).dataset_name == dataset_name else: assert gemmimtz.dataset(1).dataset_name == "reciprocalspaceship" + + +@pytest.mark.parametrize("project_name", [None, "project", 1]) +@pytest.mark.parametrize("crystal_name", [None, "crystal", 1]) +@pytest.mark.parametrize("dataset_name", [None, "dataset", 1]) +def test_write_mtz_names(IOtest_mtz, project_name, crystal_name, dataset_name): + """ + Test that DataSet.write_mtz() sets project/crystal/dataset names when given. + + Values should default to "reciprocalspaceship" when not given + """ + ds = rs.read_mtz(IOtest_mtz) + + temp = tempfile.NamedTemporaryFile(suffix=".mtz") + if project_name == 1 or crystal_name == 1 or dataset_name == 1: + with pytest.raises(TypeError): + ds.write_mtz( + temp.name, + project_name=project_name, + crystal_name=crystal_name, + dataset_name=dataset_name, + ) + temp.close() + return + else: + ds.write_mtz( + temp.name, + project_name=project_name, + crystal_name=crystal_name, + dataset_name=dataset_name, + ) + + gemmimtz = gemmi.read_mtz_file(temp.name) + + if project_name: + assert gemmimtz.dataset(1).project_name == project_name + else: + assert gemmimtz.dataset(1).project_name == "reciprocalspaceship" + + if crystal_name: + assert gemmimtz.dataset(1).crystal_name == crystal_name + else: + assert gemmimtz.dataset(1).crystal_name == "reciprocalspaceship" + + if dataset_name: + assert gemmimtz.dataset(1).dataset_name == dataset_name + else: + assert gemmimtz.dataset(1).dataset_name == "reciprocalspaceship" + + temp.close() From 1db927204610c800f2378a5efe697cd15536b100 Mon Sep 17 00:00:00 2001 From: Jack Greisman Date: Tue, 31 May 2022 18:12:19 -0400 Subject: [PATCH 3/6] Remove use of HKL_base when constructing gemmi.Mtz --- reciprocalspaceship/io/mtz.py | 19 ++++++++----------- tests/io/test_mtz.py | 24 ++++++++++++------------ 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/reciprocalspaceship/io/mtz.py b/reciprocalspaceship/io/mtz.py index 5eee05bc..9324af3d 100644 --- a/reciprocalspaceship/io/mtz.py +++ b/reciprocalspaceship/io/mtz.py @@ -1,6 +1,4 @@ import gemmi -import numpy as np -import pandas as pd from reciprocalspaceship import DataSet from reciprocalspaceship.dtypes.base import MTZDtype @@ -104,7 +102,7 @@ def to_gemmi( ) # Build up a gemmi.Mtz object - mtz = gemmi.Mtz(with_base=True) # Adds HKL_base + mtz = gemmi.Mtz() mtz.cell = dataset.cell mtz.spacegroup = dataset.spacegroup @@ -117,25 +115,24 @@ def to_gemmi( # Add Dataset with indicated names mtz.add_dataset("reciprocalspaceship") if project_name: - mtz.datasets[1].project_name = project_name + mtz.datasets[0].project_name = project_name if crystal_name: - mtz.datasets[1].crystal_name = crystal_name + mtz.datasets[0].crystal_name = crystal_name if dataset_name: - mtz.datasets[1].dataset_name = dataset_name + mtz.datasets[0].dataset_name = dataset_name # Construct data for Mtz object temp = dataset.reset_index() - columns = ["H", "K", "L"] # already in HKL_base + columns = [] for c in temp.columns: cseries = temp[c] if isinstance(cseries.dtype, MTZDtype): - if c not in ["H", "K", "L"]: # HKL already in HKL_base - mtz.add_column(label=c, type=cseries.dtype.mtztype) - columns.append(c) + mtz.add_column(label=c, type=cseries.dtype.mtztype) + columns.append(c) # Special case for CENTRIC and PARTIAL flags elif cseries.dtype.name == "bool" and c in ["CENTRIC", "PARTIAL"]: temp[c] = temp[c].astype("MTZInt") - mtz.add_column(label=c, type="I", dataset_id=1) + mtz.add_column(label=c, type="I") columns.append(c) elif skip_problem_mtztypes: continue diff --git a/tests/io/test_mtz.py b/tests/io/test_mtz.py index 88201733..aad1b6cd 100644 --- a/tests/io/test_mtz.py +++ b/tests/io/test_mtz.py @@ -173,19 +173,19 @@ def test_to_gemmi_names(IOtest_mtz, project_name, crystal_name, dataset_name): ) if project_name: - assert gemmimtz.dataset(1).project_name == project_name + assert gemmimtz.dataset(0).project_name == project_name else: - assert gemmimtz.dataset(1).project_name == "reciprocalspaceship" + assert gemmimtz.dataset(0).project_name == "reciprocalspaceship" if crystal_name: - assert gemmimtz.dataset(1).crystal_name == crystal_name + assert gemmimtz.dataset(0).crystal_name == crystal_name else: - assert gemmimtz.dataset(1).crystal_name == "reciprocalspaceship" + assert gemmimtz.dataset(0).crystal_name == "reciprocalspaceship" if dataset_name: - assert gemmimtz.dataset(1).dataset_name == dataset_name + assert gemmimtz.dataset(0).dataset_name == dataset_name else: - assert gemmimtz.dataset(1).dataset_name == "reciprocalspaceship" + assert gemmimtz.dataset(0).dataset_name == "reciprocalspaceship" @pytest.mark.parametrize("project_name", [None, "project", 1]) @@ -221,18 +221,18 @@ def test_write_mtz_names(IOtest_mtz, project_name, crystal_name, dataset_name): gemmimtz = gemmi.read_mtz_file(temp.name) if project_name: - assert gemmimtz.dataset(1).project_name == project_name + assert gemmimtz.dataset(0).project_name == project_name else: - assert gemmimtz.dataset(1).project_name == "reciprocalspaceship" + assert gemmimtz.dataset(0).project_name == "reciprocalspaceship" if crystal_name: - assert gemmimtz.dataset(1).crystal_name == crystal_name + assert gemmimtz.dataset(0).crystal_name == crystal_name else: - assert gemmimtz.dataset(1).crystal_name == "reciprocalspaceship" + assert gemmimtz.dataset(0).crystal_name == "reciprocalspaceship" if dataset_name: - assert gemmimtz.dataset(1).dataset_name == dataset_name + assert gemmimtz.dataset(0).dataset_name == dataset_name else: - assert gemmimtz.dataset(1).dataset_name == "reciprocalspaceship" + assert gemmimtz.dataset(0).dataset_name == "reciprocalspaceship" temp.close() From 27d7e56db9fde391c5753f5fe86f5125020654f3 Mon Sep 17 00:00:00 2001 From: Jack Greisman Date: Tue, 31 May 2022 20:54:47 -0400 Subject: [PATCH 4/6] Change default values from None to "reciprocalspaceship" --- reciprocalspaceship/dataset.py | 12 ++++++------ reciprocalspaceship/io/mtz.py | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/reciprocalspaceship/dataset.py b/reciprocalspaceship/dataset.py index 1bff6b02..578b7b57 100644 --- a/reciprocalspaceship/dataset.py +++ b/reciprocalspaceship/dataset.py @@ -319,9 +319,9 @@ def from_gemmi(cls, gemmiMtz): def to_gemmi( self, skip_problem_mtztypes=False, - project_name=None, - crystal_name=None, - dataset_name=None, + project_name="reciprocalspaceship", + crystal_name="reciprocalspaceship", + dataset_name="reciprocalspaceship", ): """ Creates gemmi.Mtz object from DataSet object. @@ -489,9 +489,9 @@ def write_mtz( self, mtzfile, skip_problem_mtztypes=False, - project_name=None, - crystal_name=None, - dataset_name=None, + project_name="reciprocalspaceship", + crystal_name="reciprocalspaceship", + dataset_name="reciprocalspaceship", ): """ Write DataSet to MTZ file. diff --git a/reciprocalspaceship/io/mtz.py b/reciprocalspaceship/io/mtz.py index 9324af3d..7ea77e56 100644 --- a/reciprocalspaceship/io/mtz.py +++ b/reciprocalspaceship/io/mtz.py @@ -59,9 +59,9 @@ def from_gemmi(gemmi_mtz): def to_gemmi( dataset, skip_problem_mtztypes=False, - project_name=None, - crystal_name=None, - dataset_name=None, + project_name="reciprocalspaceship", + crystal_name="reciprocalspaceship", + dataset_name="reciprocalspaceship", ): """ Construct gemmi.Mtz object from DataSet @@ -181,9 +181,9 @@ def write_mtz( dataset, mtzfile, skip_problem_mtztypes=False, - project_name=None, - crystal_name=None, - dataset_name=None, + project_name="reciprocalspaceship", + crystal_name="reciprocalspaceship", + dataset_name="reciprocalspaceship", ): """ Write an MTZ reflection file from the reflection data in a DataSet. From 4c41b68082b8f908e55b5bad8e61917905d776bb Mon Sep 17 00:00:00 2001 From: Jack Greisman Date: Wed, 1 Jun 2022 11:57:15 -0400 Subject: [PATCH 5/6] Raise ValueError in `to_gemmi()` if given non-string names --- reciprocalspaceship/io/mtz.py | 23 ++++++++--- tests/io/test_mtz.py | 77 +++++++++++++++-------------------- 2 files changed, 49 insertions(+), 51 deletions(-) diff --git a/reciprocalspaceship/io/mtz.py b/reciprocalspaceship/io/mtz.py index 7ea77e56..749fdc36 100644 --- a/reciprocalspaceship/io/mtz.py +++ b/reciprocalspaceship/io/mtz.py @@ -101,6 +101,20 @@ def to_gemmi( f"Instance of type {dataset.__class__.__name__} has no space group information" ) + # Check project_name, crystal_name, and dataset_name are str + if not isinstance(project_name, str): + raise ValueError( + f"project_name must be a string. Given type: {type(project_name)}" + ) + if not isinstance(crystal_name, str): + raise ValueError( + f"crystal_name must be a string. Given type: {type(crystal_name)}" + ) + if not isinstance(dataset_name, str): + raise ValueError( + f"dataset_name must be a string. Given type: {type(dataset_name)}" + ) + # Build up a gemmi.Mtz object mtz = gemmi.Mtz() mtz.cell = dataset.cell @@ -114,12 +128,9 @@ def to_gemmi( # Add Dataset with indicated names mtz.add_dataset("reciprocalspaceship") - if project_name: - mtz.datasets[0].project_name = project_name - if crystal_name: - mtz.datasets[0].crystal_name = crystal_name - if dataset_name: - mtz.datasets[0].dataset_name = dataset_name + mtz.datasets[0].project_name = project_name + mtz.datasets[0].crystal_name = crystal_name + mtz.datasets[0].dataset_name = dataset_name # Construct data for Mtz object temp = dataset.reset_index() diff --git a/tests/io/test_mtz.py b/tests/io/test_mtz.py index aad1b6cd..8cc871c3 100644 --- a/tests/io/test_mtz.py +++ b/tests/io/test_mtz.py @@ -146,62 +146,59 @@ def test_unmerged_after_write(data_unmerged, in_asu): assert_frame_equal(data_unmerged, expected) -@pytest.mark.parametrize("project_name", [None, "project", 1]) -@pytest.mark.parametrize("crystal_name", [None, "crystal", 1]) -@pytest.mark.parametrize("dataset_name", [None, "dataset", 1]) +@pytest.mark.parametrize("project_name", [None, "project", "reciprocalspaceship", 1]) +@pytest.mark.parametrize("crystal_name", [None, "crystal", "reciprocalspaceship", 1]) +@pytest.mark.parametrize("dataset_name", [None, "dataset", "reciprocalspaceship", 1]) def test_to_gemmi_names(IOtest_mtz, project_name, crystal_name, dataset_name): """ Test that DataSet.to_gemmi() sets project/crystal/dataset names when given. - Values should default to "reciprocalspaceship" when not given + ValueError should be raised for anything other than a string. """ ds = rs.read_mtz(IOtest_mtz) - if project_name == 1 or crystal_name == 1 or dataset_name == 1: - with pytest.raises(TypeError): + if ( + not isinstance(project_name, str) + or not isinstance(crystal_name, str) + or not isinstance(dataset_name, str) + ): + with pytest.raises(ValueError): ds.to_gemmi( project_name=project_name, crystal_name=crystal_name, dataset_name=dataset_name, ) return - else: - gemmimtz = ds.to_gemmi( - project_name=project_name, - crystal_name=crystal_name, - dataset_name=dataset_name, - ) - if project_name: - assert gemmimtz.dataset(0).project_name == project_name - else: - assert gemmimtz.dataset(0).project_name == "reciprocalspaceship" + gemmimtz = ds.to_gemmi( + project_name=project_name, + crystal_name=crystal_name, + dataset_name=dataset_name, + ) - if crystal_name: - assert gemmimtz.dataset(0).crystal_name == crystal_name - else: - assert gemmimtz.dataset(0).crystal_name == "reciprocalspaceship" + assert gemmimtz.dataset(0).project_name == project_name + assert gemmimtz.dataset(0).crystal_name == crystal_name + assert gemmimtz.dataset(0).dataset_name == dataset_name - if dataset_name: - assert gemmimtz.dataset(0).dataset_name == dataset_name - else: - assert gemmimtz.dataset(0).dataset_name == "reciprocalspaceship" - -@pytest.mark.parametrize("project_name", [None, "project", 1]) -@pytest.mark.parametrize("crystal_name", [None, "crystal", 1]) -@pytest.mark.parametrize("dataset_name", [None, "dataset", 1]) +@pytest.mark.parametrize("project_name", [None, "project", "reciprocalspaceship", 1]) +@pytest.mark.parametrize("crystal_name", [None, "crystal", "reciprocalspaceship", 1]) +@pytest.mark.parametrize("dataset_name", [None, "dataset", "reciprocalspaceship", 1]) def test_write_mtz_names(IOtest_mtz, project_name, crystal_name, dataset_name): """ Test that DataSet.write_mtz() sets project/crystal/dataset names when given. - Values should default to "reciprocalspaceship" when not given + ValueError should be raised for anything other than a string. """ ds = rs.read_mtz(IOtest_mtz) temp = tempfile.NamedTemporaryFile(suffix=".mtz") - if project_name == 1 or crystal_name == 1 or dataset_name == 1: - with pytest.raises(TypeError): + if ( + not isinstance(project_name, str) + or not isinstance(crystal_name, str) + or not isinstance(dataset_name, str) + ): + with pytest.raises(ValueError): ds.write_mtz( temp.name, project_name=project_name, @@ -220,19 +217,9 @@ def test_write_mtz_names(IOtest_mtz, project_name, crystal_name, dataset_name): gemmimtz = gemmi.read_mtz_file(temp.name) - if project_name: - assert gemmimtz.dataset(0).project_name == project_name - else: - assert gemmimtz.dataset(0).project_name == "reciprocalspaceship" - - if crystal_name: - assert gemmimtz.dataset(0).crystal_name == crystal_name - else: - assert gemmimtz.dataset(0).crystal_name == "reciprocalspaceship" - - if dataset_name: - assert gemmimtz.dataset(0).dataset_name == dataset_name - else: - assert gemmimtz.dataset(0).dataset_name == "reciprocalspaceship" + assert gemmimtz.dataset(0).project_name == project_name + assert gemmimtz.dataset(0).crystal_name == crystal_name + assert gemmimtz.dataset(0).dataset_name == dataset_name + # Clean up temp.close() From 97124c4725a92880372b0a3fd412e78de22c9f75 Mon Sep 17 00:00:00 2001 From: Jack Greisman Date: Wed, 1 Jun 2022 13:21:19 -0400 Subject: [PATCH 6/6] Remove default values from `io.write_mtz()` and `io.to_gemmi()` --- reciprocalspaceship/io/mtz.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/reciprocalspaceship/io/mtz.py b/reciprocalspaceship/io/mtz.py index 749fdc36..05957e0f 100644 --- a/reciprocalspaceship/io/mtz.py +++ b/reciprocalspaceship/io/mtz.py @@ -58,10 +58,10 @@ def from_gemmi(gemmi_mtz): def to_gemmi( dataset, - skip_problem_mtztypes=False, - project_name="reciprocalspaceship", - crystal_name="reciprocalspaceship", - dataset_name="reciprocalspaceship", + skip_problem_mtztypes, + project_name, + crystal_name, + dataset_name, ): """ Construct gemmi.Mtz object from DataSet @@ -191,10 +191,10 @@ def read_mtz(mtzfile): def write_mtz( dataset, mtzfile, - skip_problem_mtztypes=False, - project_name="reciprocalspaceship", - crystal_name="reciprocalspaceship", - dataset_name="reciprocalspaceship", + skip_problem_mtztypes, + project_name, + crystal_name, + dataset_name, ): """ Write an MTZ reflection file from the reflection data in a DataSet.