diff --git a/.flake8 b/.flake8 index 7b2865c..88077af 100644 --- a/.flake8 +++ b/.flake8 @@ -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 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 47f7a01..aaa8889 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,4 +10,4 @@ python: - requirements: requirements/docs.txt sphinx: - configuration: doc/source/conf.py + configuration: docs/source/conf.py diff --git a/docs/source/api/diffpy.morph.morph_helpers.rst b/docs/source/api/diffpy.morph.morph_helpers.rst index 4651f50..73e864d 100644 --- a/docs/source/api/diffpy.morph.morph_helpers.rst +++ b/docs/source/api/diffpy.morph.morph_helpers.rst @@ -1,6 +1,6 @@ :tocdepth: -1 -diffpy.morph.morp_helpers package +diffpy.morph.morph_helpers package ================================== .. automodule:: diffpy.morph.morph_helpers diff --git a/docs/source/morphpy.rst b/docs/source/morphpy.rst index 30bd5c9..d3d3af5 100644 --- a/docs/source/morphpy.rst +++ b/docs/source/morphpy.rst @@ -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`. @@ -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`). @@ -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. diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst index 8093dc5..d448746 100644 --- a/docs/source/quickstart.rst +++ b/docs/source/quickstart.rst @@ -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 diff --git a/docs/source/tutorials.rst b/docs/source/tutorials.rst index dd7ad63..01ba345 100644 --- a/docs/source/tutorials.rst +++ b/docs/source/tutorials.rst @@ -24,7 +24,7 @@ selected directory and plot resulting :math:`R_w` values from each morph. `_. -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 @@ -32,9 +32,7 @@ selected directory and plot resulting :math:`R_w` values from each morph. 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 @@ -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 `` = `` 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] @@ -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. @@ -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 @@ -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``. diff --git a/news/doc_review_2.0.rst b/news/doc_review_2.0.rst new file mode 100644 index 0000000..1231720 --- /dev/null +++ b/news/doc_review_2.0.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Typo fixes in documentation. + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/tests/test_morphio.py b/tests/test_morphio.py index 7311113..b16d414 100644 --- a/tests/test_morphio.py +++ b/tests/test_morphio.py @@ -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]