Skip to content

Commit

Permalink
correction on the definition of res and numpydoc build
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenhua0320 committed Sep 16, 2024
1 parent f330de1 commit f5ba982
Showing 1 changed file with 38 additions and 15 deletions.
53 changes: 38 additions & 15 deletions src/diffpy/srmise/dataclusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ class DataClusters:
The array of r values.
y : sequence of y values
The array of PDF values, G(r)
res : int
The clustering resolution, i.e., the number of points another point has to
res : float
The clustering resolution, i.e., the number of distance another point has to
be away from the center of an existing cluster to before a new cluster is
formed. A value of zero allows every point to be cluster.
formed. A value of zero allows every point to be a cluster.
data_order : array
The array of x, y indices ordered by decreasing y
clusters :
clusters : ndarray
The array of cluster ranges
current_idx - int
current_idx : int
The index of data_order currently considered
"""

Expand All @@ -61,8 +61,8 @@ def __init__(self, x, y, res):
The array of r values.
y : sequence of y values
The array of PDF values, G(r)
res : int
The clustering resolution, i.e., the number of points another point has to
res : float
The clustering resolution, i.e., the distance another point has to
be away from the center of an existing cluster to before a new cluster is
formed. A value of zero allows every point to be cluster.
"""
Expand Down Expand Up @@ -143,8 +143,8 @@ def _setdata(self, x, y, res):
The array of r values.
y : sequence of y values
The array of PDF values, G(r)
res : int
The clustering resolution, i.e., the number of points another point has to
res : float
The clustering resolution, i.e., the distance another point has to
be away from the center of an existing cluster to before a new cluster is
formed. A value of zero allows every point to be cluster.
"""
Expand Down Expand Up @@ -230,13 +230,18 @@ def find_nearest_cluster2(self, x):
"""Return [cluster index, distance] for cluster nearest to x.
Parameters
x - Coordinate of point of interest
----------
x : ndarray
Coordinate of point of interest
The distance is positive/negative if the point is right/left of the
nearest cluster. If the point is within an existing cluster then
distance = 0.
Return None if no clusters exists.
Returns
-------
array-like
The index of the nearest cluster, and the distance for cluster nearest to x. None if no cluster
"""
if self.status == self.INIT:
raise Exception("Cannot cluster next point while status is INIT.")
Expand All @@ -259,9 +264,14 @@ def find_nearest_cluster(self, idx):
distance = 0.
Parameters
idx - index of point in self.x of interest.
----------
idx : array-like
index of point in self.x of interest.
Return None if no clusters exist.
Returns
-------
array-like
The array of cluster index and the distacne to the nearest cluster. None if no clusters exist.
"""
if self.status == self.INIT:
raise Exception("Cannot cluster next point while status is INIT.")
Expand Down Expand Up @@ -302,7 +312,14 @@ def cluster_is_full(self, cluster_idx):
boundaries.
Parameters
cluster_idx - The index of the cluster to test
----------
cluster_idx : array-like
The index of the cluster to test
Returns
-------
bools
True if the cluster is full, False otherwise
"""
if cluster_idx > 0:
low = self.clusters[cluster_idx - 1, 1] + 1
Expand All @@ -321,7 +338,13 @@ def combine_clusters(self, combine):
unclustered points between them.
Parameters
combine - [[leftmost_idx1, ..., rightmost_idx1], ...]
----------
combine : ndarray
[[leftmost_idx1, ..., rightmost_idx1], ...]
Returns
-------
None
"""
# Ensure that the same clusters aren't combined multiple times.
combine_flat = np.array(combine).ravel()
Expand Down

0 comments on commit f5ba982

Please sign in to comment.