Repository navigation
Description
I met a problem when I am trying the first example in the tutorial (i.e., single-peak extraction). The PDF of Ag can be successfully plotted without extracting peak. However, when I execute
srmise data/Ag_nyquist_qmax30.gr --plot --range 2 3.5 --baseline "Polynomial(degree=1)"
on my PC, following warning appears:
The input PDF appears to be missing information: The sampling interval of the input PDF (0.10471976036) is larger than the Nyquist interval (0.10471975512) defined by qmax=30.0. This information is irretrievable.
Traceback (most recent call last):
File "c:\programdata\anaconda2\lib\runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "c:\programdata\anaconda2\lib\runpy.py", line 72, in run_code
exec code in run_globals
File "C:\ProgramData\Anaconda2\Scripts\srmise.exe_main.py", line 9, in
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\applications\extract.py", line 388, in main
cov = ext.extract()
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\pdfpeakextraction.py", line 386, in extract
ext.fit() # Clean up parameters after resampling.
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelcluster.py", line 878, in fit
orig_qual = self.quality()
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelcluster.py", line 1112, in quality
evaluator_inst.evaluate(self, **kwds)
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelevaluators\aic.py", line 71, in evaluate
self.chisq = self.chi_squared(fit.value(), fit.y_cluster, fit.error_cluster)
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelcluster.py", line 1067, in value
return self.valuebl(r)+(self.model.value(self.r_data, self.slice)[self.slice])
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelparts.py", line 272, in value
total += p.value(r, range)
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\modelparts.py", line 468, in value
return self._owner.value(self, r, range)
File "c:\programdata\anaconda2\lib\site-packages\diffpy\srmise\peaks\terminationripples.py", line 226, in value
output[rng] = value[ext_slice][::segments]
TypeError: slice indices must be integers or None or have an index method
Can anyone help with this problem?
Thanks!
Activity
JMSkelton commentedon Mar 16, 2019
This error appears to be due to a bug on line 216 in
terminationripples.py:segments = np.ceil(dr/dr_super)At least in newer versions of NumPy,
np.ceil()returns a floating-point value, which cannot be used as an array index.An easy solution is to edit
terminationripples.pyand change the line to e.g. the following:segments = int(np.ceil(dr/dr_super))stevenhua0320 commentedon Apr 7, 2026
@sbillinge Maybe we could move this issue later or close this one and open another one since the code might be refactored at some moment and I did a global search on the repo, which I didn't find the line that these users report that might be the culprit of the issue.
sbillinge commentedon Apr 7, 2026
I think we should maybe try and close this. Can you do a search for part of the code, like
dr/dr_superorsegments? I doubt we refactored names of variablesstevenhua0320 commentedon Apr 7, 2026
Yes, I tried all the possible way to pinpoint it, but there is no such code on the global search.
sbillinge commentedon Apr 7, 2026
Is that dataset in the repo as an example one? In that case can you run that command and see if it works? We may have renamed the file....
stevenhua0320 commentedon Apr 7, 2026
The issue might still exist... I run the command but still the issue persists. Let me dive into the issue tonight and see if I can find it out...
sbillinge commentedon Apr 7, 2026
thanks! It is an easy fix if you can find it, we just have to
inttheceilstevenhua0320 commentedon Apr 8, 2026
To tell the truth, it is not a quite easy thing to fix it. Because of the property of
python 2legacy issue (since this package is lack of test as we found out in 2024, there are still quite a lotpy2legacy in the code). So, it takes me some time to fix it 😂But I somewhat fixes the bug, the only issue is I'm not quite sure whether it is really behaving properly. So, I would now open a PR for this and I would also attach the plot that it produces.
sbillinge commentedon Apr 9, 2026
This was finally truly fixed by @stevenhua0320