Skip to content

Commit b2c46cb

Browse files
committed
test/func: improving readability
1 parent e3639a3 commit b2c46cb

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/diffpy/morph/morphs/morphfuncy.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,22 @@ def morph(self, x_morph, y_morph, x_target, y_target):
3737
-------
3838
Import the funcy morph function:
3939
>>> from diffpy.morph.morphs.morphfuncy import MorphFuncy
40+
4041
Define or import the user-supplied transformation function:
4142
>>> def sine_function(x, y, amplitude, frequency):
4243
>>> return amplitude * np.sin(frequency * x) * y
44+
4345
Provide initial guess for parameters:
4446
>>> parameters = {'amplitude': 2, 'frequency': 2}
47+
4548
Run the funcy morph given input morph array (x_morph, y_morph)
4649
and target array (x_target, y_target):
4750
>>> morph = MorphFuncy()
4851
>>> morph.function = sine_function
4952
>>> morph.parameters = parameters
50-
>>> x_morph_out, y_morph_out, x_target_out, y_target_out = morph(
53+
>>> x_morph_out, y_morph_out, x_target_out, y_target_out = morph.morph(
5154
... x_morph, y_morph, x_target, y_target)
55+
5256
To access parameters from the morph instance:
5357
>>> x_morph_in = morph.x_morph_in
5458
>>> y_morph_in = morph.y_morph_in
@@ -61,5 +65,4 @@ def morph(self, x_morph, y_morph, x_target, y_target):
6165
self.y_morph_out = self.function(
6266
self.x_morph_in, self.y_morph_in, **self.parameters
6367
)
64-
6568
return self.xyallout

tests/test_morphfuncy.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def test_funcy(function, parameters, expected_function):
6767
x_morph_actual, y_morph_actual, x_target_actual, y_target_actual = (
6868
morph.morph(x_morph, y_morph, x_target, y_target)
6969
)
70+
7071
assert np.allclose(y_morph_actual, y_morph_expected)
7172
assert np.allclose(x_morph_actual, x_morph_expected)
7273
assert np.allclose(x_target_actual, x_target)

0 commit comments

Comments
 (0)