Skip to content

Commit ecb4e98

Browse files
[pre-commit.ci] auto fixes from pre-commit hooks
1 parent 9bfc39b commit ecb4e98

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

src/diffpy/morph/morph_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ def single_morph_output(
7070
# Handle special inputs
7171
if "squeeze" in morph_results:
7272
sq_dict = morph_results.pop("squeeze")
73-
rw_pos = list(morph_results.keys()).index('Rw')
73+
rw_pos = list(morph_results.keys()).index("Rw")
7474
morph_results_list = list(morph_results.items())
7575
for idx, _ in enumerate(sq_dict):
7676
morph_results_list.insert(
77-
rw_pos+idx, (f"squeeze a{idx}", sq_dict[f"a{idx}"])
77+
rw_pos + idx, (f"squeeze a{idx}", sq_dict[f"a{idx}"])
7878
)
7979
morph_results = dict(morph_results_list)
8080
# Normal inputs

src/diffpy/morph/morphapp.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,9 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
455455
config["rmax"] = opts.rmax
456456
config["rstep"] = None
457457
if (
458-
opts.rmin is not None
459-
and opts.rmax is not None
460-
and opts.rmax <= opts.rmin
458+
opts.rmin is not None
459+
and opts.rmax is not None
460+
and opts.rmax <= opts.rmin
461461
):
462462
e = "rmin must be less than rmax"
463463
parser.custom_error(e)
@@ -471,7 +471,7 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
471471
# Squeeze
472472
squeeze_poly_deg = -1
473473
if opts.squeeze is not None:
474-
squeeze_coeffs = opts.squeeze.strip().split(',')
474+
squeeze_coeffs = opts.squeeze.strip().split(",")
475475
squeeze_dict_in = {}
476476
for idx, coeff in enumerate(squeeze_coeffs):
477477
squeeze_dict_in.update({f"a{idx}": float(coeff)})
@@ -494,8 +494,9 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
494494
refpars.append("stretch")
495495
# Shift
496496
# Only enable hshift is squeeze is not enabled
497-
if ((opts.hshift is not None and squeeze_poly_deg < 0)
498-
or opts.vshift is not None):
497+
if (
498+
opts.hshift is not None and squeeze_poly_deg < 0
499+
) or opts.vshift is not None:
499500
chain.append(morphs.MorphShift())
500501
if opts.hshift is not None and squeeze_poly_deg < 0:
501502
hshift_in = opts.hshift
@@ -603,19 +604,15 @@ def single_morph(parser, opts, pargs, stdout_flag=True):
603604
"stretch": stretch_in,
604605
"smear": smear_in,
605606
}
606-
morph_inputs.update(
607-
{"hshift": hshift_in, "vshift": vshift_in}
608-
)
607+
morph_inputs.update({"hshift": hshift_in, "vshift": vshift_in})
609608
# More complex input morph parameters are only displayed conditionally
610609
if opts.squeeze is not None:
611-
squeeze_coeffs = opts.squeeze.strip().split(',')
610+
squeeze_coeffs = opts.squeeze.strip().split(",")
612611
squeeze_dict = {}
613612
for idx, coeff in enumerate(squeeze_coeffs):
614613
squeeze_dict.update({f"a{idx}": float(coeff)})
615614
for idx, _ in enumerate(squeeze_dict):
616-
morph_inputs.update(
617-
{f"squeeze a{idx}": squeeze_dict[f"a{idx}"]}
618-
)
615+
morph_inputs.update({f"squeeze a{idx}": squeeze_dict[f"a{idx}"]})
619616

620617
# Output morph parameters
621618
morph_results = dict(config.items())

tests/test_morphio.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
from pathlib import Path
44

5-
import pytest
65
import numpy as np
6+
import pytest
77

88
from diffpy.morph.morphapp import (
99
create_option_parser,
@@ -158,9 +158,20 @@ def test_morph_squeeze_outputs(self, setup, tmp_path):
158158
sqr_name = sqr.resolve().as_posix()
159159
# Note that stretch and hshift should not be considered
160160
(opts, _) = self.parser.parse_args(
161-
["--scale", "2", "--squeeze", "0,-0.001,-0.0001,0.0001",
162-
"--stretch", "1", "--hshift", "1",
163-
"-s", sqr_name, "-n", "--verbose"]
161+
[
162+
"--scale",
163+
"2",
164+
"--squeeze",
165+
"0,-0.001,-0.0001,0.0001",
166+
"--stretch",
167+
"1",
168+
"--hshift",
169+
"1",
170+
"-s",
171+
sqr_name,
172+
"-n",
173+
"--verbose",
174+
]
164175
)
165176
pargs = [morph_file, target_file]
166177
single_morph(self.parser, opts, pargs, stdout_flag=False)
@@ -176,6 +187,8 @@ def test_morph_squeeze_outputs(self, setup, tmp_path):
176187
assert len(m_row) == len(t_row)
177188
for idx, _ in enumerate(m_row):
178189
if isfloat(m_row[idx]) and isfloat(t_row[idx]):
179-
assert np.isclose(float(m_row[idx]), float(t_row[idx]))
190+
assert np.isclose(
191+
float(m_row[idx]), float(t_row[idx])
192+
)
180193
else:
181194
assert m_row[idx] == t_row[idx]

0 commit comments

Comments
 (0)