diffpy.utils 3.6.1rc1__tar.gz → 3.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/PKG-INFO +5 -5
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/README.rst +2 -2
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/pyproject.toml +10 -2
- diffpy_utils-3.7.0/src/diffpy/utils/_deprecator.py +178 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/diffraction_objects.py +39 -34
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/parsers/__init__.py +9 -1
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/parsers/loaddata.py +197 -172
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/parsers/serialization.py +4 -3
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/resampler.py +11 -11
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/tools.py +63 -73
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/transforms.py +22 -18
- diffpy_utils-3.7.0/src/diffpy/utils/utils_app.py +33 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/version.py +5 -4
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/wx/gridutils.py +3 -3
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy.utils.egg-info/PKG-INFO +5 -5
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy.utils.egg-info/SOURCES.txt +4 -0
- diffpy_utils-3.7.0/src/diffpy.utils.egg-info/entry_points.txt +2 -0
- diffpy_utils-3.7.0/tests/test_deprecator.py +38 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/test_loaddata.py +75 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/test_serialization.py +13 -11
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/test_tools.py +0 -35
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/AUTHORS.rst +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/LICENSE.rst +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/LICENSE_DANSE.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/MANIFEST.in +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/requirements/build.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/requirements/conda.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/requirements/docs.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/requirements/pip.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/requirements/tests.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/setup.cfg +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/__init__.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/__init__.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/parsers/custom_exceptions.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/validators.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy/utils/wx/__init__.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy.utils.egg-info/dependency_links.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy.utils.egg-info/requires.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/src/diffpy.utils.egg-info/top_level.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/conftest.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/test_diffraction_objects.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/test_resample.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/test_transforms.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/test_validators.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/test_version.py +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/dbload/e1.gr +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/dbload/e2.gr +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/dbload/e3.gr +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/generated_db.json +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/generatewarnings.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/loaddata01.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/loaddatawithheaders.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/loadfile.txt +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/strumining.json +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/targetjson.json +0 -0
- {diffpy_utils-3.6.1rc1 → diffpy_utils-3.7.0}/tests/testdata/wrong.type +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: diffpy.utils
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.7.0
|
|
4
4
|
Summary: General utilities for analyzing diffraction data
|
|
5
5
|
Author-email: Simon Billinge <sb2896@columbia.edu>
|
|
6
6
|
Maintainer-email: Simon Billinge <sb2896@columbia.edu>
|
|
@@ -16,12 +16,12 @@ Classifier: Operating System :: MacOS :: MacOS X
|
|
|
16
16
|
Classifier: Operating System :: Microsoft :: Windows
|
|
17
17
|
Classifier: Operating System :: POSIX
|
|
18
18
|
Classifier: Operating System :: Unix
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
22
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
23
23
|
Classifier: Topic :: Scientific/Engineering :: Chemistry
|
|
24
|
-
Requires-Python: <3.
|
|
24
|
+
Requires-Python: <3.15,>=3.12
|
|
25
25
|
Description-Content-Type: text/x-rst
|
|
26
26
|
License-File: LICENSE.rst
|
|
27
27
|
License-File: LICENSE_DANSE.txt
|
|
@@ -58,6 +58,7 @@ Dynamic: license-file
|
|
|
58
58
|
:target: https://anaconda.org/conda-forge/diffpy.utils
|
|
59
59
|
|
|
60
60
|
.. |PR| image:: https://img.shields.io/badge/PR-Welcome-29ab47ff
|
|
61
|
+
:target: https://github.com/diffpy/diffpy.utils/pulls
|
|
61
62
|
|
|
62
63
|
.. |PyPI| image:: https://img.shields.io/pypi/v/diffpy.utils
|
|
63
64
|
:target: https://pypi.org/project/diffpy.utils/
|
|
@@ -68,8 +69,7 @@ Dynamic: license-file
|
|
|
68
69
|
.. |Tracking| image:: https://img.shields.io/badge/issue_tracking-github-blue
|
|
69
70
|
:target: https://github.com/diffpy/diffpy.utils/issues
|
|
70
71
|
|
|
71
|
-
diffpy.
|
|
72
|
-
========================================================================
|
|
72
|
+
Shared utilities for diffpy packages.
|
|
73
73
|
|
|
74
74
|
General utilities for analyzing diffraction data
|
|
75
75
|
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
:target: https://anaconda.org/conda-forge/diffpy.utils
|
|
26
26
|
|
|
27
27
|
.. |PR| image:: https://img.shields.io/badge/PR-Welcome-29ab47ff
|
|
28
|
+
:target: https://github.com/diffpy/diffpy.utils/pulls
|
|
28
29
|
|
|
29
30
|
.. |PyPI| image:: https://img.shields.io/pypi/v/diffpy.utils
|
|
30
31
|
:target: https://pypi.org/project/diffpy.utils/
|
|
@@ -35,8 +36,7 @@
|
|
|
35
36
|
.. |Tracking| image:: https://img.shields.io/badge/issue_tracking-github-blue
|
|
36
37
|
:target: https://github.com/diffpy/diffpy.utils/issues
|
|
37
38
|
|
|
38
|
-
diffpy.
|
|
39
|
-
========================================================================
|
|
39
|
+
Shared utilities for diffpy packages.
|
|
40
40
|
|
|
41
41
|
General utilities for analyzing diffraction data
|
|
42
42
|
|
|
@@ -14,7 +14,7 @@ maintainers = [
|
|
|
14
14
|
description = "General utilities for analyzing diffraction data"
|
|
15
15
|
keywords = ['text data parsers', 'wx grid', 'diffraction objects']
|
|
16
16
|
readme = "README.rst"
|
|
17
|
-
requires-python = ">=3.
|
|
17
|
+
requires-python = ">=3.12, <3.15"
|
|
18
18
|
classifiers = [
|
|
19
19
|
'Development Status :: 5 - Production/Stable',
|
|
20
20
|
'Environment :: Console',
|
|
@@ -25,9 +25,9 @@ classifiers = [
|
|
|
25
25
|
'Operating System :: Microsoft :: Windows',
|
|
26
26
|
'Operating System :: POSIX',
|
|
27
27
|
'Operating System :: Unix',
|
|
28
|
-
'Programming Language :: Python :: 3.11',
|
|
29
28
|
'Programming Language :: Python :: 3.12',
|
|
30
29
|
'Programming Language :: Python :: 3.13',
|
|
30
|
+
'Programming Language :: Python :: 3.14',
|
|
31
31
|
'Topic :: Scientific/Engineering :: Physics',
|
|
32
32
|
'Topic :: Scientific/Engineering :: Chemistry',
|
|
33
33
|
]
|
|
@@ -48,6 +48,9 @@ include = ["*"] # package names should match these glob patterns (["*"] by defa
|
|
|
48
48
|
exclude = [] # exclude packages matching these glob patterns (empty by default)
|
|
49
49
|
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
|
|
50
50
|
|
|
51
|
+
[project.scripts]
|
|
52
|
+
diffpy-utils = "diffpy.utils_app:main"
|
|
53
|
+
|
|
51
54
|
[tool.setuptools.dynamic]
|
|
52
55
|
dependencies = {file = ["requirements/pip.txt"]}
|
|
53
56
|
|
|
@@ -56,6 +59,11 @@ exclude-file = ".codespell/ignore_lines.txt"
|
|
|
56
59
|
ignore-words = ".codespell/ignore_words.txt"
|
|
57
60
|
skip = "*.cif,*.dat"
|
|
58
61
|
|
|
62
|
+
[tool.docformatter]
|
|
63
|
+
recursive = true
|
|
64
|
+
wrap-summaries = 72
|
|
65
|
+
wrap-descriptions = 72
|
|
66
|
+
|
|
59
67
|
[tool.black]
|
|
60
68
|
line-length = 79
|
|
61
69
|
include = '\.pyi?$'
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import warnings
|
|
3
|
+
|
|
4
|
+
# Deprecated decorator is available for Python 3.13+, once
|
|
5
|
+
# Support for earlier versions is dropped, this custom
|
|
6
|
+
# implementation can be removed.
|
|
7
|
+
try:
|
|
8
|
+
from warnings import deprecated as _builtin_deprecated
|
|
9
|
+
except ImportError:
|
|
10
|
+
_builtin_deprecated = None
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def deprecated(message, *, category=DeprecationWarning, stacklevel=1):
|
|
14
|
+
"""Deprecation decorator for functions and classes that is
|
|
15
|
+
compatible with Python versions prior to 3.13.
|
|
16
|
+
|
|
17
|
+
Examples
|
|
18
|
+
--------
|
|
19
|
+
Basic usage with a deprecated function:
|
|
20
|
+
|
|
21
|
+
.. code-block:: python
|
|
22
|
+
|
|
23
|
+
from diffpy.utils._deprecator import (
|
|
24
|
+
deprecated, build_deprecation_message
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
deprecation_warning = build_deprecation_message("diffpy.utils",
|
|
28
|
+
"old_function",
|
|
29
|
+
"new_function",
|
|
30
|
+
"4.0.0")
|
|
31
|
+
|
|
32
|
+
@deprecated(deprecation_warning)
|
|
33
|
+
def old_function(x, y):
|
|
34
|
+
'''This function is deprecated and will be removed in version
|
|
35
|
+
4.0.0. Please use new_function instead'''
|
|
36
|
+
return new_function(x, y)
|
|
37
|
+
|
|
38
|
+
def new_function(x, y):
|
|
39
|
+
return x + y
|
|
40
|
+
|
|
41
|
+
old_function(1, 2) # Works but emits DeprecationWarning
|
|
42
|
+
new_function(1, 2) # Works, no warning
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
Deprecating a class:
|
|
46
|
+
|
|
47
|
+
.. code-block:: python
|
|
48
|
+
|
|
49
|
+
from diffpy.utils._deprecator import (
|
|
50
|
+
deprecated, build_deprecation_message
|
|
51
|
+
)
|
|
52
|
+
deprecation_warning = build_deprecation_message("diffpy.utils",
|
|
53
|
+
"OldAtom",
|
|
54
|
+
"NewAtom",
|
|
55
|
+
"4.0.0")
|
|
56
|
+
|
|
57
|
+
@deprecated(deprecation_warning)
|
|
58
|
+
class OldAtom:
|
|
59
|
+
def __new__(cls, *args, **kwargs):
|
|
60
|
+
warnings.warn(
|
|
61
|
+
"OldAtom is deprecated and will be removed in
|
|
62
|
+
version 4.0.0. Use NewClass instead.",
|
|
63
|
+
DeprecationWarning,
|
|
64
|
+
stacklevel=2,
|
|
65
|
+
)
|
|
66
|
+
return NewAtom(*args, **kwargs)
|
|
67
|
+
|
|
68
|
+
class NewAtom:
|
|
69
|
+
def __init__(self, symbol):
|
|
70
|
+
self.symbol = symbol
|
|
71
|
+
|
|
72
|
+
a = OldAtom("C") # Works but emits DeprecationWarning
|
|
73
|
+
b = NewAtom("C") # Works with no warning
|
|
74
|
+
"""
|
|
75
|
+
if _builtin_deprecated is not None:
|
|
76
|
+
return _builtin_deprecated(
|
|
77
|
+
message, category=category, stacklevel=stacklevel
|
|
78
|
+
)
|
|
79
|
+
if not isinstance(message, str):
|
|
80
|
+
raise TypeError(
|
|
81
|
+
f"Expected an object of type str for 'message', not "
|
|
82
|
+
f"{type(message).__name__!r}"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
def decorator(obj):
|
|
86
|
+
setattr(obj, "__deprecated__", message)
|
|
87
|
+
if callable(obj):
|
|
88
|
+
|
|
89
|
+
@functools.wraps(obj)
|
|
90
|
+
def wrapper(*args, **kwargs):
|
|
91
|
+
warnings.warn(message, category, stacklevel=stacklevel + 1)
|
|
92
|
+
return obj(*args, **kwargs)
|
|
93
|
+
|
|
94
|
+
return wrapper
|
|
95
|
+
raise TypeError(
|
|
96
|
+
"deprecated decorator can only be applied to functions or classes"
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
return decorator
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def build_deprecation_message(
|
|
103
|
+
old_base, old_name, new_name, removal_version, new_base=None
|
|
104
|
+
):
|
|
105
|
+
"""Generate a deprecation message.
|
|
106
|
+
|
|
107
|
+
Parameters
|
|
108
|
+
----------
|
|
109
|
+
old_base : str
|
|
110
|
+
The base module or class where the deprecated item resides.
|
|
111
|
+
This will look like the import statement used in the code
|
|
112
|
+
currently
|
|
113
|
+
old_name : str
|
|
114
|
+
The name of the deprecated item.
|
|
115
|
+
new_name : str
|
|
116
|
+
The name of the new item to use.
|
|
117
|
+
removal_version : str
|
|
118
|
+
The version when the deprecated item will be removed.
|
|
119
|
+
new_base : str Optional. Defaults to old_base.
|
|
120
|
+
The base module or class where the new item resides.
|
|
121
|
+
This will look like the import statement that
|
|
122
|
+
will be used in the code moving forward. If not specified,
|
|
123
|
+
the new base defaults to the old one.
|
|
124
|
+
|
|
125
|
+
Returns
|
|
126
|
+
-------
|
|
127
|
+
str
|
|
128
|
+
A formatted deprecation message.
|
|
129
|
+
"""
|
|
130
|
+
if new_base is None:
|
|
131
|
+
new_base = old_base
|
|
132
|
+
return (
|
|
133
|
+
f"'{old_base}.{old_name}' is deprecated and will be removed in "
|
|
134
|
+
f"version {removal_version}. Please use '{new_base}.{new_name}' "
|
|
135
|
+
f"instead."
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def generate_deprecation_docstring(new_name, removal_version, new_base=None):
|
|
140
|
+
"""Generate a docstring for copy-pasting into a deprecated function.
|
|
141
|
+
|
|
142
|
+
This function will print the text to the terminal for copy-pasting.
|
|
143
|
+
|
|
144
|
+
Parameters
|
|
145
|
+
----------
|
|
146
|
+
new_name : str
|
|
147
|
+
The name of the new function or class to replace the existing one.
|
|
148
|
+
removal_version : str
|
|
149
|
+
The version when the deprecated item is targeted for removal,
|
|
150
|
+
e.g., 4.0.0.
|
|
151
|
+
new_base : str, optional
|
|
152
|
+
The new base for importing. The new import statement would look like
|
|
153
|
+
"from new_base import new_name". Defaults to None.
|
|
154
|
+
|
|
155
|
+
Example
|
|
156
|
+
-------
|
|
157
|
+
>>> from diffpy.utils._deprecator import generate_deprecation_docstring
|
|
158
|
+
>>> generate_deprecation_docstring("new_name", "4.0.0")
|
|
159
|
+
|
|
160
|
+
The message looks like:
|
|
161
|
+
This function has been deprecated and will be removed in version
|
|
162
|
+
{removal_version}. Please use {new_base}.{new_name} instead.
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
Returns
|
|
166
|
+
-------
|
|
167
|
+
None
|
|
168
|
+
"""
|
|
169
|
+
if new_base is None:
|
|
170
|
+
function_location = new_name
|
|
171
|
+
else:
|
|
172
|
+
function_location = f"{new_base}.{new_name}"
|
|
173
|
+
print(
|
|
174
|
+
f"This function has been deprecated and will be removed in version "
|
|
175
|
+
f"{removal_version}.\n"
|
|
176
|
+
f"Please use {function_location} instead."
|
|
177
|
+
)
|
|
178
|
+
return
|
|
@@ -108,18 +108,18 @@ class DiffractionObject:
|
|
|
108
108
|
|
|
109
109
|
Parameters
|
|
110
110
|
----------
|
|
111
|
-
xarray : ndarray
|
|
111
|
+
xarray : ``ndarray``
|
|
112
112
|
The independent variable array containing "q", "tth", or "d" values.
|
|
113
|
-
yarray : ndarray
|
|
113
|
+
yarray : ``ndarray``
|
|
114
114
|
The dependent variable array corresponding to intensity values.
|
|
115
115
|
xtype : str
|
|
116
116
|
The type of the independent variable in `xarray`. Must be one of
|
|
117
117
|
{*XQUANTITIES}.
|
|
118
|
-
wavelength : float, optional
|
|
118
|
+
wavelength : float, ``optional``, default is None.
|
|
119
119
|
The wavelength of the incoming beam, specified in angstroms (Å)
|
|
120
|
-
scat_quantity : str, optional
|
|
120
|
+
scat_quantity : str, ``optional``, default is an empty string "".
|
|
121
121
|
The type of scattering experiment (e.g., "x-ray", "neutron").
|
|
122
|
-
name : str, optional
|
|
122
|
+
name : str, ``optional``, default is an empty string "".
|
|
123
123
|
The name or label for the scattering data.
|
|
124
124
|
metadata : dict, optional, default is an empty dictionary {}
|
|
125
125
|
The additional metadata associated with the diffraction object.
|
|
@@ -211,8 +211,8 @@ class DiffractionObject:
|
|
|
211
211
|
return True
|
|
212
212
|
|
|
213
213
|
def __add__(self, other):
|
|
214
|
-
"""Add a scalar value or another DiffractionObject to the yarray
|
|
215
|
-
DiffractionObject.
|
|
214
|
+
"""Add a scalar value or another DiffractionObject to the yarray
|
|
215
|
+
of the DiffractionObject.
|
|
216
216
|
|
|
217
217
|
Parameters
|
|
218
218
|
----------
|
|
@@ -262,8 +262,8 @@ class DiffractionObject:
|
|
|
262
262
|
__radd__ = __add__
|
|
263
263
|
|
|
264
264
|
def __sub__(self, other):
|
|
265
|
-
"""Subtract scalar value or another DiffractionObject to the
|
|
266
|
-
the DiffractionObject.
|
|
265
|
+
"""Subtract scalar value or another DiffractionObject to the
|
|
266
|
+
yarray of the DiffractionObject.
|
|
267
267
|
|
|
268
268
|
This method behaves similarly to the `__add__` method, but performs
|
|
269
269
|
subtraction instead of addition. For details on parameters, returns
|
|
@@ -290,8 +290,8 @@ class DiffractionObject:
|
|
|
290
290
|
__rsub__ = __sub__
|
|
291
291
|
|
|
292
292
|
def __mul__(self, other):
|
|
293
|
-
"""Multiply a scalar value or another DiffractionObject with the
|
|
294
|
-
of this DiffractionObject.
|
|
293
|
+
"""Multiply a scalar value or another DiffractionObject with the
|
|
294
|
+
yarray of this DiffractionObject.
|
|
295
295
|
|
|
296
296
|
This method behaves similarly to the `__add__` method, but performs
|
|
297
297
|
multiplication instead of addition. For details on parameters,
|
|
@@ -318,8 +318,8 @@ class DiffractionObject:
|
|
|
318
318
|
__rmul__ = __mul__
|
|
319
319
|
|
|
320
320
|
def __truediv__(self, other):
|
|
321
|
-
"""Divide the yarray of this DiffractionObject by a scalar value
|
|
322
|
-
another DiffractionObject.
|
|
321
|
+
"""Divide the yarray of this DiffractionObject by a scalar value
|
|
322
|
+
or another DiffractionObject.
|
|
323
323
|
|
|
324
324
|
This method behaves similarly to the `__add__` method, but performs
|
|
325
325
|
division instead of addition. For details on parameters, returns,
|
|
@@ -360,7 +360,7 @@ class DiffractionObject:
|
|
|
360
360
|
|
|
361
361
|
Returns
|
|
362
362
|
-------
|
|
363
|
-
ndarray
|
|
363
|
+
``ndarray``
|
|
364
364
|
The shape (len(data), 4) 2D array with columns containing the `
|
|
365
365
|
yarray` (intensity) and the `xarray` values in q, tth, and d.
|
|
366
366
|
|
|
@@ -386,7 +386,7 @@ class DiffractionObject:
|
|
|
386
386
|
Returns
|
|
387
387
|
-------
|
|
388
388
|
input_xtype : str
|
|
389
|
-
The type of `xarray`, which must be one of {*XQUANTITIES}
|
|
389
|
+
The type of `xarray`, which must be one of ``{*XQUANTITIES}``.
|
|
390
390
|
"""
|
|
391
391
|
return self._input_xtype
|
|
392
392
|
|
|
@@ -400,7 +400,7 @@ class DiffractionObject:
|
|
|
400
400
|
|
|
401
401
|
Returns
|
|
402
402
|
-------
|
|
403
|
-
uuid : UUID
|
|
403
|
+
uuid : ``UUID``
|
|
404
404
|
The unique identifier of the DiffractionObject instance.
|
|
405
405
|
"""
|
|
406
406
|
return self._uuid
|
|
@@ -474,31 +474,34 @@ class DiffractionObject:
|
|
|
474
474
|
return self.on_d(), "d"
|
|
475
475
|
|
|
476
476
|
def on_q(self):
|
|
477
|
-
"""Return the tuple of two 1D numpy arrays containing q and y
|
|
477
|
+
"""Return the tuple of two 1D numpy arrays containing q and y
|
|
478
|
+
data.
|
|
478
479
|
|
|
479
480
|
Returns
|
|
480
481
|
-------
|
|
481
|
-
(q-array, y-array) : tuple of ndarray
|
|
482
|
+
(q-array, y-array) : tuple of ``ndarray``
|
|
482
483
|
The tuple containing two 1D numpy arrays with q and y data
|
|
483
484
|
"""
|
|
484
485
|
return [self.all_arrays[:, 1], self.all_arrays[:, 0]]
|
|
485
486
|
|
|
486
487
|
def on_tth(self):
|
|
487
|
-
"""Return the tuple of two 1D numpy arrays containing tth and y
|
|
488
|
+
"""Return the tuple of two 1D numpy arrays containing tth and y
|
|
489
|
+
data.
|
|
488
490
|
|
|
489
491
|
Returns
|
|
490
492
|
-------
|
|
491
|
-
(tth-array, y-array) : tuple of ndarray
|
|
493
|
+
(tth-array, y-array) : tuple of ``ndarray``
|
|
492
494
|
The tuple containing two 1D numpy arrays with tth and y data
|
|
493
495
|
"""
|
|
494
496
|
return [self.all_arrays[:, 2], self.all_arrays[:, 0]]
|
|
495
497
|
|
|
496
498
|
def on_d(self):
|
|
497
|
-
"""Return the tuple of two 1D numpy arrays containing d and y
|
|
499
|
+
"""Return the tuple of two 1D numpy arrays containing d and y
|
|
500
|
+
data.
|
|
498
501
|
|
|
499
502
|
Returns
|
|
500
503
|
-------
|
|
501
|
-
(d-array, y-array) : tuple of ndarray
|
|
504
|
+
(d-array, y-array) : tuple of ``ndarray``
|
|
502
505
|
The tuple containing two 1D numpy arrays with d and y data
|
|
503
506
|
"""
|
|
504
507
|
return [self.all_arrays[:, 3], self.all_arrays[:, 0]]
|
|
@@ -506,8 +509,8 @@ class DiffractionObject:
|
|
|
506
509
|
def scale_to(
|
|
507
510
|
self, target_diff_object, q=None, tth=None, d=None, offset=None
|
|
508
511
|
):
|
|
509
|
-
"""Return a new diffraction object which is the current object
|
|
510
|
-
rescaled in y to the target.
|
|
512
|
+
"""Return a new diffraction object which is the current object
|
|
513
|
+
but rescaled in y to the target.
|
|
511
514
|
|
|
512
515
|
By default, if `q`, `tth`, or `d` are not provided, scaling is
|
|
513
516
|
based on the max intensity from each object. Otherwise, y-value in
|
|
@@ -522,12 +525,12 @@ class DiffractionObject:
|
|
|
522
525
|
target_diff_object: DiffractionObject
|
|
523
526
|
The diffraction object you want to scale the current one onto.
|
|
524
527
|
|
|
525
|
-
q, tth, d : float, optional
|
|
528
|
+
q, tth, d : float, ``optional``, default is None
|
|
526
529
|
The value of the x-array where you want the curves to line up
|
|
527
530
|
vertically. Specify a value on one of the allowed grids, q, tth,
|
|
528
531
|
or d), e.g., q=10.
|
|
529
532
|
|
|
530
|
-
offset : float, optional
|
|
533
|
+
offset : float, ``optional``, default is None
|
|
531
534
|
The offset to add to the scaled y-values.
|
|
532
535
|
|
|
533
536
|
Returns
|
|
@@ -568,22 +571,23 @@ class DiffractionObject:
|
|
|
568
571
|
return scaled_do
|
|
569
572
|
|
|
570
573
|
def on_xtype(self, xtype):
|
|
571
|
-
"""Return a tuple of two 1D numpy arrays containing x and y
|
|
574
|
+
"""Return a tuple of two 1D numpy arrays containing x and y
|
|
575
|
+
data.
|
|
572
576
|
|
|
573
577
|
Parameters
|
|
574
578
|
----------
|
|
575
579
|
xtype : str
|
|
576
580
|
The type of quantity for the independent variable chosen from
|
|
577
|
-
{*XQUANTITIES, }
|
|
581
|
+
``{*XQUANTITIES, }``
|
|
578
582
|
|
|
579
583
|
Raises
|
|
580
584
|
------
|
|
581
585
|
ValueError
|
|
582
|
-
Raised when the specified xtype is not among {*XQUANTITIES, }
|
|
586
|
+
Raised when the specified xtype is not among ``{*XQUANTITIES, }``
|
|
583
587
|
|
|
584
588
|
Returns
|
|
585
589
|
-------
|
|
586
|
-
(xarray, yarray) : tuple of ndarray
|
|
590
|
+
(xarray, yarray) : tuple of ``ndarray``
|
|
587
591
|
The tuple containing two 1D numpy arrays with x and y data for
|
|
588
592
|
the specified xtype.
|
|
589
593
|
"""
|
|
@@ -597,16 +601,17 @@ class DiffractionObject:
|
|
|
597
601
|
raise ValueError(_xtype_wmsg(xtype))
|
|
598
602
|
|
|
599
603
|
def dump(self, filepath, xtype=None):
|
|
600
|
-
"""Dump the xarray and yarray of the diffraction object to a
|
|
601
|
-
file, with the associated information included in the
|
|
604
|
+
"""Dump the xarray and yarray of the diffraction object to a
|
|
605
|
+
two-column file, with the associated information included in the
|
|
606
|
+
header.
|
|
602
607
|
|
|
603
608
|
Parameters
|
|
604
609
|
----------
|
|
605
610
|
filepath : str
|
|
606
611
|
The filepath where the diffraction object will be dumped
|
|
607
|
-
xtype : str, optional
|
|
612
|
+
xtype : str, ``optional``, default is q
|
|
608
613
|
The type of quantity for the independent variable chosen from
|
|
609
|
-
{*XQUANTITIES, }
|
|
614
|
+
``{*XQUANTITIES, }``
|
|
610
615
|
|
|
611
616
|
Examples
|
|
612
617
|
--------
|
|
@@ -6,10 +6,18 @@
|
|
|
6
6
|
# (c) 2010 The Trustees of Columbia University
|
|
7
7
|
# in the City of New York. All rights reserved.
|
|
8
8
|
#
|
|
9
|
-
# File coded by:
|
|
9
|
+
# File coded by: Simon Billinge
|
|
10
10
|
#
|
|
11
11
|
# See AUTHORS.txt for a list of people who contributed.
|
|
12
12
|
# See LICENSE_DANSE.txt for license information.
|
|
13
13
|
#
|
|
14
14
|
##############################################################################
|
|
15
15
|
"""Various utilities related to data parsing and manipulation."""
|
|
16
|
+
|
|
17
|
+
# this allows load_data to be imported from diffpy.utils.parsers
|
|
18
|
+
# it is needed during deprecation of the old loadData structure
|
|
19
|
+
# when we remove loadData we can move all the parser functionality
|
|
20
|
+
# a parsers.py module (like tools.py) and remove this if we want
|
|
21
|
+
from .loaddata import load_data
|
|
22
|
+
|
|
23
|
+
__all__ = ["load_data"]
|