Skip to content

Commit 1baaaee

Browse files
committed
Fix scale + stretch + apply with extrap warning
1 parent 177d073 commit 1baaaee

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

src/diffpy/morph/morph_io.py

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -501,38 +501,39 @@ def tabulate_results(multiple_morph_results):
501501
def handle_extrapolation_warnings(morph):
502502
if morph is not None:
503503
extrapolation_info = morph.extrapolation_info
504-
is_extrap_low = extrapolation_info["is_extrap_low"]
505-
is_extrap_high = extrapolation_info["is_extrap_high"]
506-
cutoff_low = extrapolation_info["cutoff_low"]
507-
cutoff_high = extrapolation_info["cutoff_high"]
508-
509-
if is_extrap_low and is_extrap_high:
510-
wmsg = (
511-
"Warning: points with grid value below "
512-
f"{cutoff_low} and above "
513-
f"{cutoff_high} "
514-
f"are extrapolated."
515-
)
516-
elif is_extrap_low:
517-
wmsg = (
518-
"Warning: points with grid value below "
519-
f"{cutoff_low} "
520-
f"are extrapolated."
521-
)
522-
elif is_extrap_high:
523-
wmsg = (
524-
"Warning: points with grid value above "
525-
f"{cutoff_high} "
526-
f"are extrapolated."
527-
)
528-
else:
529-
wmsg = None
504+
if extrapolation_info is not None:
505+
is_extrap_low = extrapolation_info["is_extrap_low"]
506+
is_extrap_high = extrapolation_info["is_extrap_high"]
507+
cutoff_low = extrapolation_info["cutoff_low"]
508+
cutoff_high = extrapolation_info["cutoff_high"]
509+
510+
if is_extrap_low and is_extrap_high:
511+
wmsg = (
512+
"Warning: points with grid value below "
513+
f"{cutoff_low} and above "
514+
f"{cutoff_high} "
515+
f"are extrapolated."
516+
)
517+
elif is_extrap_low:
518+
wmsg = (
519+
"Warning: points with grid value below "
520+
f"{cutoff_low} "
521+
f"are extrapolated."
522+
)
523+
elif is_extrap_high:
524+
wmsg = (
525+
"Warning: points with grid value above "
526+
f"{cutoff_high} "
527+
f"are extrapolated."
528+
)
529+
else:
530+
wmsg = None
530531

531-
if wmsg:
532-
warnings.warn(
533-
wmsg,
534-
UserWarning,
535-
)
532+
if wmsg:
533+
warnings.warn(
534+
wmsg,
535+
UserWarning,
536+
)
536537

537538

538539
def handle_check_increase_warning(squeeze_morph):

src/diffpy/morph/morphs/morph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def __init__(self, config=None):
124124
All configuration variables.
125125
"""
126126
# declare empty attributes
127+
self.extrapolation_info = None
127128
if config is None:
128129
config = {}
129130
self.x_morph_in = None

0 commit comments

Comments
 (0)