Skip to content

Commit a108205

Browse files
merge from main and add tests for unknown materials
2 parents 1879f44 + b0b6676 commit a108205

20 files changed

+357
-212
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,10 @@ repos:
5858
- id: prettier
5959
additional_dependencies:
6060
- "prettier@^3.2.4"
61+
# docformatter - formats docstrings using PEP 257
62+
- repo: https://github.com/s-weigand/docformatter
63+
rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c
64+
hooks:
65+
- id: docformatter
66+
additional_dependencies: [tomli]
67+
args: [--in-place, --config, ./pyproject.toml]

doc/source/examples/tools_example.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ After receiving the inputs, the function will write the information to
114114
the `diffpyconfig.json` file in your home directory.
115115

116116

117+
``check_and_build_global_config()`` returns ``True`` if the config file exists (whether it created it or not)
118+
and ``False`` if the config file does not exist in the user's home allowing you to develop your own
119+
workflow for handling missing config files after running it with ``skip_config_creation=True``.
120+
117121
I entered the wrong information in my config file so it always loads incorrect information, how do I fix that?
118122
--------------------------------------------------------------------------------------------------------------
119123

news/configupdate.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: covered in the news from the get_user_info work
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>

news/docformatter.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* docforamtter in pre-commit for automatic formatting of docstrings to PEP 257
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>

news/uuid-rename.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+
* DiffractionObject's "id" property renamed to "uuid"
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>

src/diffpy/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# See LICENSE.rst for license information.
1717
#
1818
##############################################################################
19-
2019
"""diffpy - tools for structure analysis by diffraction.
2120
2221
Blank namespace package.

src/diffpy/utils/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
# See LICENSE.rst for license information.
1313
#
1414
##############################################################################
15-
16-
"""Shared utilities for diffpy packages"""
15+
"""Shared utilities for diffpy packages."""
1716

1817
# package version
1918
from diffpy.utils.version import __version__

src/diffpy/utils/diffraction_objects.py

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ class DiffractionObject:
4646
4747
Attributes
4848
----------
49-
all_arrays : ndarray
50-
The array containing the quantity of q, tth, d values.
51-
input_xtype : str
52-
The type of the independent variable in `xarray`. Must be one of {*XQUANTITIES}
53-
id : uuid
54-
The unique identifier for the diffraction object.
5549
scat_quantity : str
5650
The type of scattering experiment (e.g., "x-ray", "neutron"). Default is an empty string "".
5751
wavelength : float
@@ -127,7 +121,7 @@ def __init__(
127121
>>> print(do.metadata)
128122
"""
129123

130-
self._id = uuid.uuid4()
124+
self._uuid = uuid.uuid4()
131125
self._input_data(xarray, yarray, xtype, wavelength, scat_quantity, name, metadata)
132126

133127
def _input_data(self, xarray, yarray, xtype, wavelength, scat_quantity, name, metadata):
@@ -284,6 +278,23 @@ def __rtruediv__(self, other):
284278

285279
@property
286280
def all_arrays(self):
281+
"""The 2D array containing `xarray` and `yarray` values.
282+
283+
Returns
284+
-------
285+
ndarray
286+
The shape (len(data), 4) 2D array with columns containing the `yarray` (intensity)
287+
and the `xarray` values in q, tth, and d.
288+
289+
Examples
290+
--------
291+
To access specific arrays individually, use these slices:
292+
293+
>>> my_do.all_arrays[:, 0] # yarray
294+
>>> my_do.all_arrays[:, 1] # xarray in q
295+
>>> my_do.all_arrays[:, 2] # xarray in tth
296+
>>> my_do.all_arrays[:, 3] # xarray in d
297+
"""
287298
return self._all_arrays
288299

289300
@all_arrays.setter
@@ -292,19 +303,33 @@ def all_arrays(self, _):
292303

293304
@property
294305
def input_xtype(self):
306+
"""The type of the independent variable in `xarray`.
307+
308+
Returns
309+
-------
310+
str
311+
The type of `xarray`, which must be one of {*XQUANTITIES}.
312+
"""
295313
return self._input_xtype
296314

297315
@input_xtype.setter
298316
def input_xtype(self, _):
299317
raise AttributeError(_setter_wmsg("input_xtype"))
300318

301319
@property
302-
def id(self):
303-
return self._id
320+
def uuid(self):
321+
"""The unique identifier for the DiffractionObject instance.
322+
323+
Returns
324+
-------
325+
uuid
326+
The unique identifier of the DiffractionObject instance.
327+
"""
328+
return self._uuid
304329

305-
@id.setter
306-
def id(self, _):
307-
raise AttributeError(_setter_wmsg("id"))
330+
@uuid.setter
331+
def uuid(self, _):
332+
raise AttributeError(_setter_wmsg("uuid"))
308333

309334
def get_array_index(self, value, xtype=None):
310335
"""Return the index of the closest value in the array associated with
@@ -319,7 +344,8 @@ def get_array_index(self, value, xtype=None):
319344
320345
Returns
321346
-------
322-
the index of the value in the array
347+
list
348+
The list containing the index of the closest value in the array.
323349
"""
324350

325351
xtype = self._input_xtype

src/diffpy/utils/parsers/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
16-
"""Various utilities related to data parsing and manipulation.
17-
"""
15+
"""Various utilities related to data parsing and manipulation."""

src/diffpy/utils/parsers/serialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def serialize_data(
3333
show_path=True,
3434
serial_file=None,
3535
):
36-
"""Serialize file data into a dictionary. Can also save dictionary into a serial language file. Dictionary is
37-
formatted as {filename: data}.
36+
"""Serialize file data into a dictionary. Can also save dictionary into a
37+
serial language file. Dictionary is formatted as {filename: data}.
3838
3939
Requires hdata and data_table (can be generated by loadData).
4040

0 commit comments

Comments
 (0)