From 5d9b311df4c5631be8694ad901465596b06da995 Mon Sep 17 00:00:00 2001 From: Patrick Avery Date: Thu, 26 Mar 2026 15:56:14 -0500 Subject: [PATCH] Correctly save a `tThWidth` of `None` Before, if the `tThWidth` was set to `None`, which is a valid setting, saving the material and reloading it would reset it to the default value, rather than restoring the value of `None`. This PR fixes the bug so that `None` is properly saved and restored, as it should be. Signed-off-by: Patrick Avery --- hexrd/core/material/material.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hexrd/core/material/material.py b/hexrd/core/material/material.py index 65606847..8dda950c 100644 --- a/hexrd/core/material/material.py +++ b/hexrd/core/material/material.py @@ -961,7 +961,7 @@ def _readHDFxtal(self, fhdf=DFLT_NAME, xtal=DFLT_NAME): tThWidth = np.array(gid.get('tThWidth'), dtype=np.float64).item() tThWidth = np.radians(tThWidth) else: - tThWidth = Material.DFLT_TTH + tThWidth = None self._tThWidth = tThWidth @@ -991,9 +991,7 @@ def dump_material(self, file, path=None): AtomInfo['hkls'] = self.planeData.getHKLs() AtomInfo['dmin'] = self.unitcell.dmin AtomInfo['kev'] = self.beamEnergy.getVal("keV") - if self.planeData.tThWidth is None: - AtomInfo['tThWidth'] = np.degrees(Material.DFLT_TTH) - else: + if self.planeData.tThWidth is not None: AtomInfo['tThWidth'] = np.degrees(self.planeData.tThWidth) AtomInfo['pressure'] = self.pressure