You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
docs: some parts in documentation are incorrect. #352
from diffpy.utils.transforms import d_to_tth
wavelength = 0.71
d = np.array([1.0, 0.8, 0.6, 0.4, 0.2])
tth = d_to_tth(d, wavelength)
will raise
ValueError: The supplied input array and wavelength will result in an impossible two-theta. Please check these values and re-instantiate the DiffractionObject with correct values.
def get_array_index(self, xtype, xvalue):
"""Return the index of the closest value in the array associated with
the specified xtype and the value provided.
...
xtype = self._input_xtype
xarray = self.on_xtype(xtype)[0]
if len(xarray) == 0:
raise ValueError(
f"The '{xtype}' array is empty. "
"Please ensure it is initialized."
)
index = (np.abs(xarray - xvalue)).argmin()
return index
"""
So the input parameterxtype doesn't have an effect at all. Thus, the following code
yes, this looks like a bug. The intent is that the user wants the index of, for example, Q=23.4 a-1, or tth=45 deg. so inside we want to use the relevant xarray, be it Q or tth or whatever.
Let's write some tests for this then fix the code.
Please check everywhere in the code where this is used, and also the docs so everything agrees. Maybe do all that work on separate PR clsing a separate issue.
Please also fix all the other documentation issues that you found.
Activity
ycexiao commentedon Jul 24, 2025
The function
DiffractionObject.get_array_indexSo the input parameter
xtypedoesn't have an effect at all. Thus, the following codereturns
TrueandFalse.@sbillinge, is it a bug we want to fix?
[-]docs: example of using `get_array_index` failed[/-][+]docs: Some parts in documentation are incorrect.[/+][-]docs: Some parts in documentation are incorrect.[/-][+]docs: some parts in documentation are incorrect.[/+]sbillinge commentedon Jul 25, 2025
yes, this looks like a bug. The intent is that the user wants the index of, for example, Q=23.4 a-1, or tth=45 deg. so inside we want to use the relevant xarray, be it Q or tth or whatever.
Let's write some tests for this then fix the code.
Please check everywhere in the code where this is used, and also the docs so everything agrees. Maybe do all that work on separate PR clsing a separate issue.
Please also fix all the other documentation issues that you found.