From 0cb0a0489d5201a5d2f7df9f1fc3c4037d1ce74a Mon Sep 17 00:00:00 2001 From: Yuchen Ethan Xiao Date: Thu, 24 Jul 2025 13:48:21 -0400 Subject: [PATCH 1/4] docs: fix the example of using `DiffractionObject.get_array_index` in the documentation --- .../examples/diffraction_objects_example.rst | 6 ++--- news/fix-docs-example.rst | 23 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 news/fix-docs-example.rst diff --git a/docs/source/examples/diffraction_objects_example.rst b/docs/source/examples/diffraction_objects_example.rst index 1122bf21..8794c719 100644 --- a/docs/source/examples/diffraction_objects_example.rst +++ b/docs/source/examples/diffraction_objects_example.rst @@ -180,7 +180,7 @@ For example, attempting to add a diffraction object and a string will raise an e .. code-block:: python - tth_ninety_index = diff_object1.get_array_index(90, xtype="tth") + tth_ninety_index = diff_object1.get_array_index(xvalue=90, xtype="tth") intensity_at_ninety = diff_object1.on_tth()[1][tth_ninety_index] If you do not specify an ``xtype``, it will default to the ``xtype`` used when creating the ``DiffractionObject``. @@ -190,8 +190,8 @@ you can find its closest index for ``q=0.25`` by typing either of the following: .. code-block:: python print(do._input_xtype) # remind ourselves which array was input. prints "q" in this case. - index = do.get_array_index(0.25) # no xtype passed, defaults to do._input_xtype, or in this example, q - index = do.get_array_index(0.25, xtype="q") # explicitly choose an xtype to specify a value + index = do.get_array_index(xvalue=0.25) # no xtype passed, defaults to do._input_xtype, or in this example, q + index = do.get_array_index(xvalue=0.25, xtype="q") # explicitly choose an xtype to specify a value 5. The ``dump`` function saves the diffraction data and relevant information to an xy format file with headers (widely used chi format used, for example, by Fit2D and diffpy. These files can be read by ``LoadData()`` diff --git a/news/fix-docs-example.rst b/news/fix-docs-example.rst new file mode 100644 index 00000000..ef351fae --- /dev/null +++ b/news/fix-docs-example.rst @@ -0,0 +1,23 @@ +**Added:** + +* No news added: Fix the example of using ``DiffractionObject.get_array_index`` in the documentation. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 14ec0bc17f123fd125b3b0eb877a75e35bb17dd4 Mon Sep 17 00:00:00 2001 From: Yuchen Ethan Xiao Date: Thu, 24 Jul 2025 15:05:41 -0400 Subject: [PATCH 2/4] docs: remove a duplicate code block --- docs/source/examples/resample_example.rst | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/docs/source/examples/resample_example.rst b/docs/source/examples/resample_example.rst index 4884f5c9..ba28390b 100644 --- a/docs/source/examples/resample_example.rst +++ b/docs/source/examples/resample_example.rst @@ -23,18 +23,6 @@ given enough datapoints. Each data table has two columns: first is the grid and second is the function value. To extract the columns, we can utilize the serialize function ... -.. code-block:: python - - from diffpy.utils.parsers.serialization import serialize_data - nickel_data = serialize_data('Nickel.gr', {}, nickel_datatable, dt_colnames=['grid', 'func']) - nickel_grid = nickel_data['Nickel.gr']['grid'] - nickel_func = nickel_data['Nickel.gr']['func'] - target_data = serialize_data('NiTarget.gr', {}, nitarget_datatable, dt_colnames=['grid', 'function']) - target_grid = nickel_data['Nickel.gr']['grid'] - target_func = nickel_data['Nickel.gr']['func'] - -To extract the columns, we can utilize the serialize function ... - .. code-block:: python from diffpy.utils.parsers.serialization import serialize_data From 174f2be1ebc27129f061d34e9fcf787896adc2c3 Mon Sep 17 00:00:00 2001 From: Yuchen Ethan Xiao Date: Thu, 24 Jul 2025 15:07:41 -0400 Subject: [PATCH 3/4] docs: fix the `.rst` markup --- docs/source/examples/parsers_example.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/source/examples/parsers_example.rst b/docs/source/examples/parsers_example.rst index 92135f3b..09220a3a 100644 --- a/docs/source/examples/parsers_example.rst +++ b/docs/source/examples/parsers_example.rst @@ -104,8 +104,7 @@ Now we can extract specific data table columns from the dictionary. parsed_file_data = serialize_data('', hdata, data_table, serial_file='') - The returned value, ``parsed_file_data``, is the dictionary we just added to ``serialfile.json``. - To extract the data from the serial file, we use ``deserialize_data``. +The returned value, ``parsed_file_data``, is the dictionary we just added to ``serialfile.json``. To extract the data from the serial file, we use ``deserialize_data``. .. code-block:: python From 829d62a609fc1ce6432eb14e61ee03030722f8f0 Mon Sep 17 00:00:00 2001 From: Yuchen Ethan Xiao Date: Thu, 24 Jul 2025 15:08:08 -0400 Subject: [PATCH 4/4] chore: update news --- news/fix-docs-example.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/fix-docs-example.rst b/news/fix-docs-example.rst index ef351fae..0048f8a3 100644 --- a/news/fix-docs-example.rst +++ b/news/fix-docs-example.rst @@ -1,6 +1,6 @@ **Added:** -* No news added: Fix the example of using ``DiffractionObject.get_array_index`` in the documentation. +* No news added: Fix some examples in the documentation. **Changed:**