Skip to content

Commit 8aefb07

Browse files
feat: increase muD_max to 7 for fast cal, report muD value when raising the error
1 parent 1a263b4 commit 8aefb07

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
-6.543824057313183,2.517676049711881e-10,-430.98705781061807,-1390.1242894055792,-2233.6043531698424,-2624.226082870084,-2590.22123249732
2-
5.020666247920394,-4.676545705328227e-10,875.3743680589598,2744.521375373735,4366.230491983095,5113.620084734874,5051.51673764446
3-
1.8615172482459748,3.25649449911046e-10,-663.8228448830648,-2027.2101338882571,-3194.0427904869357,-3728.3876362721985,-3684.6430045258744
4-
-1.9688714316525813,0.9999999998992586,224.64320300800793,666.0546805817288,1038.3830530062712,1207.4338980088214,1193.1790131535502
5-
0.9819818977427489,1.1680695590205036e-11,-28.533774174029173,-82.17596308875525,-126.6770208129477,-146.65755463691826,-144.8506009433783
1+
-20619.128648244743,2.4364997877410417e-06,26505.585137008606,-337279.3213902739,-1056051.2792994028,-1815539.1160187968,-2372171.980894541,-2642993.4538858426
2+
56203.20048346139,-6.774323967911372e-06,-51225.01460831775,1005023.6254387972,3051609.2101441943,5201294.212075991,6773264.754466731,7538833.212217793
3+
-63802.106117440504,7.845612740225726e-06,33089.880661840034,-1242527.9972772636,-3668761.3028854067,-6202335.40819644,-8050708.344579743,-8951452.327576341
4+
38603.18842240787,-4.844608638276231e-06,-4028.752491140328,816333.2796219026,2349291.871863084,3940828.5623758254,5099123.959731602,5663734.051678175
5+
-13126.533425725584,1.6822282153058894e-06,-4395.4012467221355,-300757.7094990732,-845218.597424347,-1407243.8630987857,-1815244.4369415767,-2014105.8565458413
6+
2378.155272695758,0.9999996885549859,1912.0755691304305,58944.34388638723,162014.93660541167,267802.2088119374,344395.5526651557,381710.2334140182
7+
-178.70587585316136,2.4018054840276848e-08,-234.76082555771987,-4803.1698085743365,-12928.521798999534,-21220.235622246797,-27207.092578054173,-30121.285267280207

src/diffpy/labpdfproc/functions.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
CVE_METHODS = ["brute_force", "polynomial_interpolation"]
1717

1818
# Pre-computed datasets for polynomial interpolation (fast calculation)
19-
MUD_LIST = [0.5, 1, 2, 3, 4, 5, 6]
19+
MUD_LIST = [0.5, 1, 2, 3, 4, 5, 6, 7]
2020
CWD = Path(__file__).parent.resolve()
2121
MULS = np.loadtxt(CWD / "data" / "inverse_cve.xy")
2222
COEFFICIENT_LIST = np.array(
@@ -206,25 +206,28 @@ def _cve_brute_force(input_pattern, mud):
206206

207207
def _cve_polynomial_interpolation(input_pattern, mud):
208208
"""Compute cve using polynomial interpolation method,
209-
raise an error if the mu*D value is out of the range (0.5 to 6).
209+
raise an error if the mu*D value is out of the range (0.5 to 7).
210210
"""
211-
if mud > 6 or mud < 0.5:
211+
if mud > 7 or mud < 0.5:
212212
raise ValueError(
213-
f"mu*D is out of the acceptable range (0.5 to 6) "
213+
f"Input mu*D = {mud} is out of the acceptable range "
214+
f"({min(MUD_LIST)} to {max(MUD_LIST)}) "
214215
f"for polynomial interpolation. "
215216
f"Please rerun with a value within this range "
216217
f"or specifying another method from {*CVE_METHODS, }."
217218
)
218-
coeff_a, coeff_b, coeff_c, coeff_d, coeff_e = [
219+
coef1, coef2, coef3, coef4, coef5, coef6, coef7 = [
219220
interpolation_function(mud)
220221
for interpolation_function in INTERPOLATION_FUNCTIONS
221222
]
222223
muls = np.array(
223-
coeff_a * MULS**4
224-
+ coeff_b * MULS**3
225-
+ coeff_c * MULS**2
226-
+ coeff_d * MULS
227-
+ coeff_e
224+
coef1 * MULS**6
225+
+ coef2 * MULS**5
226+
+ coef3 * MULS**4
227+
+ coef4 * MULS**3
228+
+ coef5 * MULS**2
229+
+ coef6 * MULS
230+
+ coef7
228231
)
229232
cve = 1 / muls
230233

tests/test_functions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def test_compute_cve(input_xtype, expected, mocker):
160160
"inputs, msg",
161161
[
162162
(
163-
{"mud": 7, "method": "polynomial_interpolation"},
164-
f"mu*D is out of the acceptable range (0.5 to 6) "
163+
{"mud": 10, "method": "polynomial_interpolation"},
164+
f"mu*D = 10 is out of the acceptable range (0.5 to 7) "
165165
f"for polynomial interpolation. "
166166
f"Please rerun with a value within this range "
167167
f"or specifying another method from {*CVE_METHODS, }.",

0 commit comments

Comments
 (0)