diff options
author | Muriithi Frederick Muriuki | 2021-07-23 05:01:52 +0300 |
---|---|---|
committer | Muriithi Frederick Muriuki | 2021-07-23 05:01:52 +0300 |
commit | b817112a878a4efa3c673a38af7b0938a70cdb9e (patch) | |
tree | 6fbbf86b8a8d3d41962afb4141ba1a6d3cf879c2 | |
parent | 2b32b2da36d880e3d8cdaedd1775be02ebb5cd5f (diff) | |
download | genenetwork3-b817112a878a4efa3c673a38af7b0938a70cdb9e.tar.gz |
Add docstring for `nearest' function
Issue:
https://github.com/genenetwork/gn-gemtext-threads/blob/main/topics/gn1-migration-to-gn2/clustering.gmi
* gn3/computations/slink.py: add documentation for the `nearest` function in
the `gn3.computations.slink` module in the form of a (hopefully correct)
python docstring.
-rw-r--r-- | gn3/computations/slink.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/gn3/computations/slink.py b/gn3/computations/slink.py index 880ce9f..fc6f479 100644 --- a/gn3/computations/slink.py +++ b/gn3/computations/slink.py @@ -60,10 +60,33 @@ raise an exception.""" raise ValueError("Distances should be positive.") def nearest(lists, i, j): - """Computes some form of distance. -This is 'copied' over from genenetwork1, from https://github.com/genenetwork/genenetwork1/blob/master/web/webqtl/heatmap/slink.py#L42-L64. + """ + Computes shortest distance between member(s) in `i` and member(s) in `j`. -This description should be updated once the form/type of 'distance' identified.""" + Description: + This is 'copied' over from genenetwork1, from https://github.com/genenetwork/genenetwork1/blob/master/web/webqtl/heatmap/slink.py#L42-L64. + + This description should be updated to better describe what 'member' means in + the context where the function is used. + + Parameters: + lists (list of lists of distances): Represents a list of members and their + distances from each other. + Each inner list represents the distances the member at that coordinate + is from other members in the list: for example, a member at index 0 with + the values [0, 9, 1, 7] indicates that the member is: + - 0 units of distance away from itself + - 9 units of distance away from member at coordinate 1 + - 1 unit of distance away from member at coordinate 2 + - 7 units of distance away from member at coordinate 3 + i (int or list of ints): Represents the coordinate of a member, or a list of + coordinates of members on the `lists` list. + j (int or list of ints): Represents the coordinate of a member, or a list of + coordinates of members on the `lists` list. + + Returns: + int: Represents the shortest distance between member(s) in `i` and member(s) + in `j`.""" #### Guard Functions: Should we do this a different way? #### raise_valueerror_if_data_is_not_lists_or_tuples(lists) |