Skip to content

Commit 7ce6a89

Browse files
authored
Fixing typos in documentation and tutorials (#229)
* Fix typo in stretch parameter * Indication to print * Formatting fixes * macos-14 tolerance * Add news * doc to docs * Typo fix
1 parent a02d3c4 commit 7ce6a89

File tree

8 files changed

+61
-33
lines changed

8 files changed

+61
-33
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ exclude =
66
__pycache__,
77
build,
88
dist,
9-
doc/source/conf.py
9+
docs/source/conf.py
1010
max-line-length = 79
1111
# Ignore some style 'errors' produced while formatting by 'black'
1212
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ python:
1010
- requirements: requirements/docs.txt
1111

1212
sphinx:
13-
configuration: doc/source/conf.py
13+
configuration: docs/source/conf.py

docs/source/api/diffpy.morph.morph_helpers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
:tocdepth: -1
22

3-
diffpy.morph.morp_helpers package
3+
diffpy.morph.morph_helpers package
44
==================================
55

66
.. automodule:: diffpy.morph.morph_helpers

docs/source/morphpy.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Python Morphing Functions
1717
morph on the files `darkSub_rh20_C_01.gr` and `darkSub_rh20_C_44.gr` using the command-line
1818
command ::
1919

20-
diffpy.morph --scale=0.8 --smear=-0.08 --stretch=0.5 --rmin=1.5 --rmax=30 darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
20+
diffpy.morph --scale=0.8 --smear=-0.08 --stretch=0.005 --rmin=1.5 --rmax=30 darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
2121

2222
2. To do the same on Python, we must first create a new Python script in the same directory as the
2323
data files `darkSub_rh20_C_01.gr` and `darkSub_rh20_C_44.gr`.
@@ -27,18 +27,19 @@ Python Morphing Functions
2727

2828
3. Finally, we run the ``morph`` function ::
2929

30-
morph_info, morph_table = morph("darkSub_rh20_C_01.gr", "darkSub_rh20_C_44.gr", scale=0.8, smear=-0.08, stretch=0.5, rmin=1.5, rmax=30)
30+
morph_info, morph_table = morph("darkSub_rh20_C_01.gr", "darkSub_rh20_C_44.gr", scale=0.8, smear=-0.08, stretch=0.005, rmin=1.5, rmax=30)
3131

32-
* The ``morph`` function takes in two file names (or paths). You can also provide various parameters
33-
for morphing (see the Full Parameter List below).
34-
* If, let's say, the file `darkSub_rh20_C_01.gr` is in a subdirectory `subdir/darkSub_rh20_C_01.gr`,
35-
you should replace ``"darkSub_rh20_C_01.gr"`` in the above example with ``"subdir/darkSub_rh20_C_01.gr"``.
32+
* The ``morph`` function takes in two file names (or paths). You can also provide various parameters
33+
for morphing (see the Full Parameter List below).
34+
* If, let's say, the file `darkSub_rh20_C_01.gr` is in a subdirectory `subdir/darkSub_rh20_C_01.gr`,
35+
you should replace ``"darkSub_rh20_C_01.gr"`` in the above example with ``"subdir/darkSub_rh20_C_01.gr"``.
3636

3737
4. The ``morph`` function returns a dictionary ``morph_info`` and a numpy array ``morph_table``.
3838

3939
* ``morph_info`` contains all morphs as keys (e.g. ``"scale"``, ``"stretch"``, ``"smear"``) with
4040
the optimized morphing parameters found by ``diffpy.morph`` as values. ``morph_info`` also contains
41-
the Rw and Pearson correlation coefficients found post-morphing.
41+
the Rw and Pearson correlation coefficients found post-morphing. Try printing ``print(morph_info)``
42+
and compare the values stored in this dictionary to those given by the CLI output!
4243
* ``morph_table`` is a two-column array of the morphed function interpolated onto the grid of the
4344
target function (e.g. in our example, it returns the contents of `darkSub_rh20_C_01.gr` after
4445
the morphs are applied interpolated onto the grid of `darkSub_rh20_C_44.gr`).
@@ -61,7 +62,7 @@ Python Morphing Functions
6162
9. Notice that the two-column format of the input to ``morph_arrays`` is the same as the
6263
output of ``morph`` and ``morph_arrays``. It is VERY IMPORTANT that the data is in two-column format
6364
rather than the traditional two-row format. This is to reflect the file formats conventionally
64-
used to store PDFs.
65+
used to store PDFs. Again, try printing ``print(morph_info)`` and compare!
6566
10. For a full list of parameters used by (both) ``morph`` and ``morph_arrays``, see the Full Parameter List
6667
section below.
6768

docs/source/quickstart.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ Basic diffpy.morph Workflow
181181
8. Finally, we will examine the stretch factor. Provide an initial
182182
guess by typing ::
183183

184-
diffpy.morph --scale=0.8 --smear=-0.08 --stretch=0.5 --rmin=1.5 --rmax=30 -a darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
184+
diffpy.morph --scale=0.8 --smear=-0.08 --stretch=0.005 --rmin=1.5 --rmax=30 -a darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
185185

186186
And noting that the difference has increased. Before continuing,
187187
see if you can see which direction (higher or lower) our initial

docs/source/tutorials.rst

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,15 @@ selected directory and plot resulting :math:`R_w` values from each morph.
2424
<https://global.oup.com/academic/product/
2525
atomic-pair-distribution-function-analysis-9780198885801>`_.
2626

27-
2. Let us start by getting the Rw of ``SrFe2As2_150K.gr`` compared to
27+
2. Let us start by getting the :math:`R_w` of ``SrFe2As2_150K.gr`` compared to
2828
all other files in the directory. Run ::
2929

3030
diffpy.morph SrFe2As2_150K.gr . --multiple-targets
3131

3232
The multiple tag indicates we are comparing PDF file (first input)
3333
against all PDFs in a directory (second input). Our choice of file
3434
was ``SeFe2As2_150K.gr`` and directory was the cwd, which should be
35-
``morphsequence``.::
36-
37-
diffpy.morph SrFe2As2_150K.gr . --multiple-targets --sort-by=temperature
35+
``morphsequence``.
3836

3937
.. figure:: images/ex_tutorial_bar.png
4038
:align: center
@@ -43,16 +41,16 @@ selected directory and plot resulting :math:`R_w` values from each morph.
4341
Bar chart of :math:`R_W` values for each target file. Target files are
4442
listed in ASCII sort order.
4543

46-
3. After running this, we get chart of Rw values for each target file.
44+
3. After running this, we get chart of :math:`R_w` values for each target file.
4745
However, this chart can be a bit confusing to interpret. To get a
4846
more understandable plot, run ::
4947

5048
diffpy.morph SrFe2As2_150K.gr . --multiple-targets --sort-by=temperature
5149

52-
This plots the Rw against the temperature parameter value provided
50+
This plots the :math:`R_w` against the temperature parameter value provided
5351
at the top of each file. Parameters are entries of the form
5452
``<parameter_name> = <parameter_value>`` and are located above
55-
the ``r`` versus ``gr`` table in each PDF file.::
53+
the ``r`` versus ``gr`` table in each PDF file. ::
5654

5755
# SrFe2As2_150K.gr
5856
[PDF Parameters]
@@ -77,7 +75,7 @@ selected directory and plot resulting :math:`R_w` values from each morph.
7775
Note that we are not applying a smear since it takes a long time to
7876
apply and does not significantly change the Rw values in this example.
7977

80-
5. We should now see a sharper increase in Rw between 192K and 198K.
78+
5. We should now see a sharper increase in :math:`R_w` between 192K and 198K.
8179

8280
6. Go back to the terminal to see optimized morphing parameters from each morph.
8381

@@ -219,27 +217,25 @@ Currently, the supported nanoparticle shapes include: spheres and spheroids.
219217

220218
diffpy.morph Ni_nano_sphere.cgr Ni_nano_sphere.cgr
221219

222-
3. Nanoparticles tend to have broader peaks at r-values larger
220+
Nanoparticles tend to have broader peaks at r-values larger
223221
than the particle size, corresponding to the much weaker
224222
correlations between molecules. On our plot, beyond r=22.5,
225223
peaks are too broad to be visible, indicating our particle
226224
size to be about 22.4. The approximate radius of a sphere
227-
would be half of that, or 11.2.::
228-
229-
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a
225+
would be half of that, or 11.2.
230226

231227

232-
4. Now, we are ready to perform a morph applying spherical
228+
3. Now, we are ready to perform a morph applying spherical
233229
effects. To do so, we use the ``--radius`` parameter ::
234230

235-
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a
231+
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a --rmax=30
236232

237-
5. We can see that the Rw value has significantly decreased
233+
4. We can see that the :math:`Rw` value has significantly decreased
238234
from before. Run without the ``-a`` tag to refine ::
239235

240-
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2
236+
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 --rmax=30
241237

242-
6. After refining, we see the actual radius of the
238+
5. After refining, we see the actual radius of the
243239
nanoparticle was closer to 12.
244240

245241
* Spheroidal Shape
@@ -255,7 +251,7 @@ Currently, the supported nanoparticle shapes include: spheres and spheroids.
255251
enough information to define our spheroid. To apply
256252
spheroid shape effects onto our bulk, run ::
257253

258-
diffpy.morph Ni_bulk.gr Ni_nano_spheroid.cgr --radius=12 --pradius=6 -a
254+
diffpy.morph Ni_bulk.gr Ni_nano_spheroid.cgr --radius=12 --pradius=6 -a --rmax=30
259255

260256
Note that the equatorial radius corresponds to the
261257
``--radius`` parameter and polar radius to ``--pradius``.

news/doc_review_2.0.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* Typo fixes in documentation.
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

tests/test_morphio.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ def quadratic(x, y, a0, a1, a2):
217217
with open(tmp_path.joinpath("funcy_target.cgr")) as gf:
218218
generated = filter(ignore_path, gf)
219219
target = filter(ignore_path, tf)
220-
for x, y in zip(generated, target):
221-
assert x == y
222-
assert all(x == y for x, y in zip(generated, target))
220+
for m, t in zip(generated, target):
221+
m_row = m.split()
222+
t_row = t.split()
223+
assert len(m_row) == len(t_row)
224+
for idx, _ in enumerate(m_row):
225+
if isfloat(m_row[idx]) and isfloat(t_row[idx]):
226+
assert np.isclose(
227+
float(m_row[idx]), float(t_row[idx])
228+
)
229+
else:
230+
assert m_row[idx] == t_row[idx]

0 commit comments

Comments
 (0)