fix: fix load single peak in py3 support#178
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #178 +/- ##
=======================================
Coverage 76.47% 76.47%
=======================================
Files 3 3
Lines 51 51
=======================================
Hits 39 39
Misses 12 12 🚀 New features to boost your workflow:
|
|
@sbillinge I believe we have no tests to cover the issue here (since the tests only contain the easiest one written on 2024 summer by you and me), so it needs some human wisdom to decide if it is correct or not. |
|
yah, something seems rather wrong here. The fit is not working. It should end up looking like the fit in @bobleesj from the other issue. |
|
@stevenhua0320 let me know when you figure this out and want a review. |
|
@sbillinge ready to review. Finally, I figured out that it is because of the regularization of
|
| self.chisq = self.chi_squared(fit.value(), fit.y_cluster, fit.error_cluster) | ||
|
|
||
| self.stat = self.chisq + self.parpenalty(k, n) | ||
| self.stat = self.chisq + self.parpenalty(k) |
There was a problem hiding this comment.
This is needed, otherwise, it would have a unneeded positional argument, Moreover, since we are doing AIC, we don't need n here by the AIC formula.
| self.x[idx] - self.x[self.clusters[int(near_idx) - 1, 1]], | ||
| self.x[idx] - self.x[self.clusters[int(near_idx), 0]], | ||
| self.x[idx] - self.x[self.clusters[near_idx - 1, 1]], | ||
| self.x[idx] - self.x[self.clusters[near_idx, 0]], |
There was a problem hiding this comment.
This is to revert the incorrect fix done on summer 2024.
| # Enable "dg" as alias for "effective_dy" | ||
| if "dg" in args and "effective_dy" not in args: | ||
| nargs.add("effective_dy") | ||
| nargs.append("effective_dy") |
There was a problem hiding this comment.
Now, we have nargs as a list, so we need append method here
| new_dr = (new_r[-1] - r[0]) / (len(new_r) - 1) | ||
|
|
||
| yfft = np.imag(np.fft.fft(new_y))[: len(new_y) / 2] | ||
| yfft = np.imag(np.fft.fft(new_y))[: len(new_y) // 2] |
There was a problem hiding this comment.
In py2 it doesn't matter but in py3, since the slicing number must be an integer, so it must be // to get an integer value.
sbillinge
left a comment
There was a problem hiding this comment.
Oh wow. Super! Great job!

@sbillinge ready to review. Note that there are a lot of
py2legacy in this package. (My bad, I did not clean it up comprehensively on 2024). Now it would give a plot when I run the commandsrmise docs/examples/data/Ag-nyquist-qmax30.gr --plot --range 2 3.5 --baseline "Polynomial(degree=1)"it would give me the plot below.Also there are some messages for the fitting process: