Skip to content

Fixing typos in documentation and tutorials #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exclude =
__pycache__,
build,
dist,
doc/source/conf.py
docs/source/conf.py
max-line-length = 79
# Ignore some style 'errors' produced while formatting by 'black'
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ python:
- requirements: requirements/docs.txt

sphinx:
configuration: doc/source/conf.py
configuration: docs/source/conf.py
2 changes: 1 addition & 1 deletion docs/source/api/diffpy.morph.morph_helpers.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:tocdepth: -1

diffpy.morph.morp_helpers package
diffpy.morph.morph_helpers package
==================================

.. automodule:: diffpy.morph.morph_helpers
Expand Down
17 changes: 9 additions & 8 deletions docs/source/morphpy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Python Morphing Functions
morph on the files `darkSub_rh20_C_01.gr` and `darkSub_rh20_C_44.gr` using the command-line
command ::

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
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

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

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

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)
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)

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Basic diffpy.morph Workflow
8. Finally, we will examine the stretch factor. Provide an initial
guess by typing ::

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
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

And noting that the difference has increased. Before continuing,
see if you can see which direction (higher or lower) our initial
Expand Down
32 changes: 14 additions & 18 deletions docs/source/tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ selected directory and plot resulting :math:`R_w` values from each morph.
<https://global.oup.com/academic/product/
atomic-pair-distribution-function-analysis-9780198885801>`_.

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

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

The multiple tag indicates we are comparing PDF file (first input)
against all PDFs in a directory (second input). Our choice of file
was ``SeFe2As2_150K.gr`` and directory was the cwd, which should be
``morphsequence``.::

diffpy.morph SrFe2As2_150K.gr . --multiple-targets --sort-by=temperature
``morphsequence``.

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

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

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

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

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

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

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

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

diffpy.morph Ni_nano_sphere.cgr Ni_nano_sphere.cgr

3. Nanoparticles tend to have broader peaks at r-values larger
Nanoparticles tend to have broader peaks at r-values larger
than the particle size, corresponding to the much weaker
correlations between molecules. On our plot, beyond r=22.5,
peaks are too broad to be visible, indicating our particle
size to be about 22.4. The approximate radius of a sphere
would be half of that, or 11.2.::

diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a
would be half of that, or 11.2.


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

diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 -a --rmax=30

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

diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2
diffpy.morph Ni_bulk.gr Ni_nano_sphere.cgr --radius=11.2 --rmax=30

6. After refining, we see the actual radius of the
5. After refining, we see the actual radius of the
nanoparticle was closer to 12.

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

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

Note that the equatorial radius corresponds to the
``--radius`` parameter and polar radius to ``--pradius``.
Expand Down
23 changes: 23 additions & 0 deletions news/doc_review_2.0.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* Typo fixes in documentation.

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
14 changes: 11 additions & 3 deletions tests/test_morphio.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ def quadratic(x, y, a0, a1, a2):
with open(tmp_path.joinpath("funcy_target.cgr")) as gf:
generated = filter(ignore_path, gf)
target = filter(ignore_path, tf)
for x, y in zip(generated, target):
assert x == y
assert all(x == y for x, y in zip(generated, target))
for m, t in zip(generated, target):
m_row = m.split()
t_row = t.split()
assert len(m_row) == len(t_row)
for idx, _ in enumerate(m_row):
if isfloat(m_row[idx]) and isfloat(t_row[idx]):
assert np.isclose(
float(m_row[idx]), float(t_row[idx])
)
else:
assert m_row[idx] == t_row[idx]
Loading