Skip to content

Commit 2f11c69

Browse files
Merge branch 'diffpy:main' into readme
2 parents 6f5010d + 47b4763 commit 2f11c69

File tree

9 files changed

+45
-87
lines changed

9 files changed

+45
-87
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
conda activate test
4545
conda install --file requirements/run.txt
4646
conda install --file requirements/test.txt
47-
pip install .
47+
pip install . --no-deps
4848
4949
- name: Validate diffpy.srmise
5050
shell: bash -l {0}

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "diffpy.srmise"
7-
dynamic=['version']
7+
dynamic=['version', 'dependencies']
88
authors = [
99
{ name="Simon J.L. Billinge group", email="[email protected]" },
1010
{name="Luke Granlund", email="[email protected]"},
@@ -51,6 +51,9 @@ include = ["*"] # package names should match these glob patterns (["*"] by defa
5151
exclude = ["diffpy.srmise.tests*"] # exclude packages matching these glob patterns (empty by default)
5252
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
5353

54+
[tool.setuptools.dynamic]
55+
dependencies = {file = ["requirements/run.txt"]}
56+
5457
[tool.black]
5558
line-length = 115
5659
include = '\.pyi?$'

src/diffpy/srmise/baselines/polynomial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def estimate_parameters(self, r, y):
105105
import numpy.linalg as la
106106

107107
a = np.array([r[cut_idx]]).T
108-
slope = la.lstsq(a, y[cut_idx])[0][0]
108+
slope = la.lstsq(a, y[cut_idx], rcond=-1)[0][0]
109109
return np.array([slope, 0.0])
110110
except Exception as e:
111111
emsg = "Error during estimation -- " + str(e)
@@ -256,4 +256,5 @@ def getmodule(self):
256256
y = -r + 10 * np.exp(-((r - 5) ** 2)) + np.random.rand(len(r))
257257
est = f.estimate_parameters(r, y)
258258
print("Actual baseline: ", np.array([-1, 0.0]))
259+
# TODO: Make test est baseline in ways of tolerance function
259260
print("Estimated baseline: ", est)

src/diffpy/srmise/dataclusters.py

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ class DataClusters:
4040
The array of r values.
4141
y : sequence of y values
4242
The array of PDF values, G(r)
43-
res : int
44-
The clustering resolution, i.e., the number of points another point has to
43+
res : float
44+
The clustering resolution, i.e., the number of distance another point has to
4545
be away from the center of an existing cluster to before a new cluster is
46-
formed. A value of zero allows every point to be cluster.
46+
formed. A value of zero allows every point to be a cluster.
4747
data_order : array
4848
The array of x, y indices ordered by decreasing y
49-
clusters :
49+
clusters : ndarray
5050
The array of cluster ranges
51-
current_idx - int
51+
current_idx : int
5252
The index of data_order currently considered
5353
"""
5454

@@ -61,8 +61,8 @@ def __init__(self, x, y, res):
6161
The array of r values.
6262
y : sequence of y values
6363
The array of PDF values, G(r)
64-
res : int
65-
The clustering resolution, i.e., the number of points another point has to
64+
res : float
65+
The clustering resolution, i.e., the distance another point has to
6666
be away from the center of an existing cluster to before a new cluster is
6767
formed. A value of zero allows every point to be cluster.
6868
"""
@@ -143,8 +143,8 @@ def _setdata(self, x, y, res):
143143
The array of r values.
144144
y : sequence of y values
145145
The array of PDF values, G(r)
146-
res : int
147-
The clustering resolution, i.e., the number of points another point has to
146+
res : float
147+
The clustering resolution, i.e., the distance another point has to
148148
be away from the center of an existing cluster to before a new cluster is
149149
formed. A value of zero allows every point to be cluster.
150150
"""
@@ -230,13 +230,18 @@ def find_nearest_cluster2(self, x):
230230
"""Return [cluster index, distance] for cluster nearest to x.
231231
232232
Parameters
233-
x - Coordinate of point of interest
233+
----------
234+
x : ndarray
235+
Coordinate of point of interest
234236
235237
The distance is positive/negative if the point is right/left of the
236238
nearest cluster. If the point is within an existing cluster then
237239
distance = 0.
238240
239-
Return None if no clusters exists.
241+
Returns
242+
-------
243+
array-like
244+
The index of the nearest cluster, and the distance for cluster nearest to x. None if no cluster
240245
"""
241246
if self.status == self.INIT:
242247
raise Exception("Cannot cluster next point while status is INIT.")
@@ -259,9 +264,14 @@ def find_nearest_cluster(self, idx):
259264
distance = 0.
260265
261266
Parameters
262-
idx - index of point in self.x of interest.
267+
----------
268+
idx : array-like
269+
index of point in self.x of interest.
263270
264-
Return None if no clusters exist.
271+
Returns
272+
-------
273+
array-like
274+
The array of cluster index and the distacne to the nearest cluster. None if no clusters exist.
265275
"""
266276
if self.status == self.INIT:
267277
raise Exception("Cannot cluster next point while status is INIT.")
@@ -302,7 +312,14 @@ def cluster_is_full(self, cluster_idx):
302312
boundaries.
303313
304314
Parameters
305-
cluster_idx - The index of the cluster to test
315+
----------
316+
cluster_idx : array-like
317+
The index of the cluster to test
318+
319+
Returns
320+
-------
321+
bools
322+
True if the cluster is full, False otherwise
306323
"""
307324
if cluster_idx > 0:
308325
low = self.clusters[cluster_idx - 1, 1] + 1
@@ -321,7 +338,13 @@ def combine_clusters(self, combine):
321338
unclustered points between them.
322339
323340
Parameters
324-
combine - [[leftmost_idx1, ..., rightmost_idx1], ...]
341+
----------
342+
combine : ndarray
343+
[[leftmost_idx1, ..., rightmost_idx1], ...]
344+
345+
Returns
346+
-------
347+
None
325348
"""
326349
# Ensure that the same clusters aren't combined multiple times.
327350
combine_flat = np.array(combine).ravel()

src/diffpy/srmise/tests/__init__.py

Whitespace-only changes.

src/diffpy/srmise/tests/debug.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/diffpy/srmise/tests/run.py

Lines changed: 0 additions & 34 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)