Skip to content

Commit 93bc105

Browse files
authored
Merge pull request #354 from ycexiao/fix-docs-example
docs: fix the example of using `DiffractionObject.get_array_index` in the documentation
2 parents 7eb9f5c + 829d62a commit 93bc105

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

docs/source/examples/diffraction_objects_example.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ For example, attempting to add a diffraction object and a string will raise an e
180180

181181
.. code-block:: python
182182
183-
tth_ninety_index = diff_object1.get_array_index(90, xtype="tth")
183+
tth_ninety_index = diff_object1.get_array_index(xvalue=90, xtype="tth")
184184
intensity_at_ninety = diff_object1.on_tth()[1][tth_ninety_index]
185185
186186
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:
190190
.. code-block:: python
191191
192192
print(do._input_xtype) # remind ourselves which array was input. prints "q" in this case.
193-
index = do.get_array_index(0.25) # no xtype passed, defaults to do._input_xtype, or in this example, q
194-
index = do.get_array_index(0.25, xtype="q") # explicitly choose an xtype to specify a value
193+
index = do.get_array_index(xvalue=0.25) # no xtype passed, defaults to do._input_xtype, or in this example, q
194+
index = do.get_array_index(xvalue=0.25, xtype="q") # explicitly choose an xtype to specify a value
195195
196196
5. The ``dump`` function saves the diffraction data and relevant information to an xy format file with headers
197197
(widely used chi format used, for example, by Fit2D and diffpy. These files can be read by ``LoadData()``

docs/source/examples/parsers_example.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ Now we can extract specific data table columns from the dictionary.
104104
105105
parsed_file_data = serialize_data('<PATH to data.txt>', hdata, data_table, serial_file='<PATH to serialfile.json>')
106106
107-
The returned value, ``parsed_file_data``, is the dictionary we just added to ``serialfile.json``.
108-
To extract the data from the serial file, we use ``deserialize_data``.
107+
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``.
109108

110109
.. code-block:: python
111110

docs/source/examples/resample_example.rst

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@ given enough datapoints.
2323
Each data table has two columns: first is the grid and second is the function value.
2424
To extract the columns, we can utilize the serialize function ...
2525

26-
.. code-block:: python
27-
28-
from diffpy.utils.parsers.serialization import serialize_data
29-
nickel_data = serialize_data('Nickel.gr', {}, nickel_datatable, dt_colnames=['grid', 'func'])
30-
nickel_grid = nickel_data['Nickel.gr']['grid']
31-
nickel_func = nickel_data['Nickel.gr']['func']
32-
target_data = serialize_data('NiTarget.gr', {}, nitarget_datatable, dt_colnames=['grid', 'function'])
33-
target_grid = nickel_data['Nickel.gr']['grid']
34-
target_func = nickel_data['Nickel.gr']['func']
35-
36-
To extract the columns, we can utilize the serialize function ...
37-
3826
.. code-block:: python
3927
4028
from diffpy.utils.parsers.serialization import serialize_data

news/fix-docs-example.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* No news added: Fix some examples in the documentation.
4+
5+
**Changed:**
6+
7+
* <news item>
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>

0 commit comments

Comments
 (0)