Skip to content

Commit 6d6a06d

Browse files
[pre-commit.ci] auto fixes from pre-commit hooks
1 parent f74d748 commit 6d6a06d

File tree

2 files changed

+51
-17
lines changed

2 files changed

+51
-17
lines changed

src/diffpy/morph/morphpy.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ def get_args(parser, params, kwargs):
2424
return opts, pargs
2525

2626

27-
def morph(morph_file, target_file, scale=None, stretch=None, smear=None, plot=False, **kwargs):
27+
def morph(
28+
morph_file,
29+
target_file,
30+
scale=None,
31+
stretch=None,
32+
smear=None,
33+
plot=False,
34+
**kwargs,
35+
):
2836
"""Run diffpy.morph at Python level.
2937
Parameters
3038
----------
@@ -52,7 +60,12 @@ def morph(morph_file, target_file, scale=None, stretch=None, smear=None, plot=Fa
5260
"""
5361

5462
parser = create_option_parser()
55-
params = {"scale": scale, "stretch": stretch, "smear": smear, "noplot": True if not plot else None}
63+
params = {
64+
"scale": scale,
65+
"stretch": stretch,
66+
"smear": smear,
67+
"noplot": True if not plot else None,
68+
}
5669
opts, pargs = get_args(parser, params, kwargs)
5770

5871
pargs = [morph_file, target_file]
@@ -62,7 +75,15 @@ def morph(morph_file, target_file, scale=None, stretch=None, smear=None, plot=Fa
6275
)
6376

6477

65-
def morphpy(morph_table, target_table, scale=None, stretch=None, smear=None, plot=False, **kwargs):
78+
def morphpy(
79+
morph_table,
80+
target_table,
81+
scale=None,
82+
stretch=None,
83+
smear=None,
84+
plot=False,
85+
**kwargs,
86+
):
6687
"""Run diffpy.morph at Python level.
6788
Parameters
6889
----------
@@ -90,7 +111,12 @@ def morphpy(morph_table, target_table, scale=None, stretch=None, smear=None, plo
90111
"""
91112

92113
parser = create_option_parser()
93-
params = {"scale": scale, "stretch": stretch, "smear": smear, "noplot": True if not plot else None}
114+
params = {
115+
"scale": scale,
116+
"stretch": stretch,
117+
"smear": smear,
118+
"noplot": True if not plot else None,
119+
}
94120
opts, pargs = get_args(parser, params, kwargs)
95121

96122
morph_table = np.array(morph_table)

tests/test_morphpy.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@
22

33
from pathlib import Path
44

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

8-
from diffpy.morph.morphapp import (
9-
create_option_parser,
10-
single_morph,
11-
)
8+
from diffpy.morph.morphapp import create_option_parser, single_morph
9+
from diffpy.morph.morphpy import morph, morphpy
1210
from diffpy.morph.tools import getRw
13-
from diffpy.morph.morphpy import (
14-
morph,
15-
morphpy,
16-
)
1711

1812
thisfile = locals().get("__file__", "file.py")
1913
tests_dir = Path(thisfile).parent.resolve()
@@ -78,15 +72,25 @@ def test_morph(self, setup_morph):
7872
morph_results = {}
7973
morph_file = self.testfiles[0]
8074
for target_file in self.testfiles[1:]:
81-
mr, grm = morph(morph_file, target_file, scale=1, stretch=0, sort_by="temperature")
75+
mr, grm = morph(
76+
morph_file,
77+
target_file,
78+
scale=1,
79+
stretch=0,
80+
sort_by="temperature",
81+
)
8282
_, grt = morph(target_file, target_file)
8383
morph_results.update({target_file.name: mr})
84+
8485
class Chain:
8586
xyallout = grm[:, 0], grm[:, 1], grt[:, 0], grt[:, 1]
87+
8688
chain = Chain()
8789
rw = getRw(chain)
8890
del chain
89-
assert numpy.allclose([rw], [self.morphapp_results[target_file.name]["Rw"]])
91+
assert numpy.allclose(
92+
[rw], [self.morphapp_results[target_file.name]["Rw"]]
93+
)
9094
assert morph_results == self.morphapp_results
9195

9296
def test_morphpy(self, setup_morph):
@@ -95,7 +99,9 @@ def test_morphpy(self, setup_morph):
9599
for target_file in self.testfiles[1:]:
96100
_, grm0 = morph(morph_file, morph_file)
97101
_, grt = morph(target_file, target_file)
98-
mr, grm = morphpy(grm0, grt, scale=1, stretch=0, sort_by="temperature")
102+
mr, grm = morphpy(
103+
grm0, grt, scale=1, stretch=0, sort_by="temperature"
104+
)
99105
morph_results.update({target_file.name: mr})
100106

101107
class Chain:
@@ -104,7 +110,9 @@ class Chain:
104110
chain = Chain()
105111
rw = getRw(chain)
106112
del chain
107-
assert numpy.allclose([rw], [self.morphapp_results[target_file.name]["Rw"]])
113+
assert numpy.allclose(
114+
[rw], [self.morphapp_results[target_file.name]["Rw"]]
115+
)
108116
assert morph_results == self.morphapp_results
109117

110118

0 commit comments

Comments
 (0)