Skip to content

Commit 5b0f30b

Browse files
committed
Revert "fix: use a custom error to stop leatsq"
This reverts commit 91fa347.
1 parent 91fa347 commit 5b0f30b

File tree

4 files changed

+7
-19
lines changed

4 files changed

+7
-19
lines changed

src/diffpy/morph/log.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,4 @@ def set_verbosity(vb):
5050
return
5151

5252

53-
class MorphOptimizationError(Exception):
54-
"Custom error for morph optimization process."
55-
56-
def __init__(self, value):
57-
super().__init__(value)
58-
59-
pass
60-
61-
6253
# End of file

src/diffpy/morph/morphapp.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import diffpy.morph.refine as refine
2828
import diffpy.morph.tools as tools
2929
from diffpy.morph import __save_morph_as__
30-
from diffpy.morph.log import MorphOptimizationError
3130
from diffpy.morph.version import __version__
3231

3332

@@ -681,7 +680,7 @@ def single_morph(
681680
refiner.refine(*rptemp)
682681
# Adjust all parameters
683682
refiner.refine(*refpars)
684-
except (ValueError, MorphOptimizationError) as e:
683+
except ValueError as e:
685684
parser.custom_error(str(e))
686685
# Smear is not being refined, but baselineslope needs to refined to apply
687686
# smear

src/diffpy/morph/refine.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
1212
# See LICENSE.txt for license information.
1313
#
1414
##############################################################################
15-
"""refine -- Refine a morph or morph chain"""
15+
"""refine -- Refine a morph or morph chain
16+
"""
1617

1718
from numpy import array, concatenate, dot, exp, ones_like
1819
from scipy.optimize import leastsq
1920
from scipy.stats import pearsonr
2021

21-
from diffpy.morph.log import MorphOptimizationError
22-
2322
# Map of scipy minimizer names to the method that uses them
2423

2524

@@ -85,7 +84,7 @@ def _residual(self, pvals):
8584
)
8685
rvec = _y_target - _y_morph
8786
if len(rvec) < len(pvals):
88-
raise MorphOptimizationError(
87+
raise ValueError(
8988
f"\nNumber of parameters (currently {len(pvals)}) cannot "
9089
"exceed the number of shared grid points "
9190
f"(currently {len(rvec)}). "

tests/test_refine.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import numpy
77
import pytest
88

9-
from diffpy.morph.log import MorphOptimizationError
109
from diffpy.morph.morph_helpers.transformpdftordf import TransformXtalPDFtoRDF
1110
from diffpy.morph.morph_helpers.transformrdftopdf import TransformXtalRDFtoPDF
1211
from diffpy.morph.morphs.morphchain import MorphChain
@@ -203,11 +202,11 @@ def test_refine_grid_bad(self, user_filesystem):
203202
"shared grid points."
204203
)
205204
with pytest.raises(
206-
MorphOptimizationError,
205+
ValueError,
207206
) as error:
208207
refiner.refine(*refpars)
209-
actual_error_message = str(error.value)
210-
assert actual_error_message == expected_error_message
208+
actual_error_message = str(error.value)
209+
assert actual_error_message == expected_error_message
211210

212211
# call from command line
213212
import subprocess

0 commit comments

Comments
 (0)