Skip to content

Commit d6b320d

Browse files
committed
raise ValueError if x_squeezed is not strictly increasing
1 parent 6fdc0af commit d6b320d

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* Raise ``ValueError`` if ``x_squeezed`` is not strictly increasing.
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

src/diffpy/morph/morphs/morphsqueeze.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ def morph(self, x_morph, y_morph, x_target, y_target):
7878
coeffs = [self.squeeze[f"a{i}"] for i in range(len(self.squeeze))]
7979
squeeze_polynomial = Polynomial(coeffs)
8080
x_squeezed = self.x_morph_in + squeeze_polynomial(self.x_morph_in)
81+
strictly_increasing_x = (np.diff(x_squeezed) > 0).all()
82+
if not strictly_increasing_x:
83+
raise ValueError(
84+
"Computed squeezed x is not strictly increasing. "
85+
"Please change the input x_morph or the squeeze "
86+
"coefficients."
87+
)
8188
self.y_morph_out = CubicSpline(x_squeezed, self.y_morph_in)(
8289
self.x_morph_in
8390
)

0 commit comments

Comments
 (0)