Skip to content

Commit

Permalink
Tidying docstrings.
Browse files Browse the repository at this point in the history
  • Loading branch information
bjmorgan committed Jul 5, 2021
1 parent 6b8b757 commit 6e15cce
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pyscses/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def energy_at_x(energy: np.ndarray,

def index_of_grid_at_x(coordinates: np.ndarray,
x: float) -> int:
"""
Assigns each site x coordinate to a position on a regularly or irregularly spaced grid.
"""Assigns each site x coordinate to a position on a regularly or irregularly spaced grid.
Returns the index of the grid point clostest to the value x
Args:
Expand All @@ -58,13 +58,15 @@ def index_of_grid_at_x(coordinates: np.ndarray,
Returns:
int: Index of grid position closest to the site x coordinate.
"""
return closest_index(coordinates, x)

def closest_index(myList: Union[list[float],np.ndarray],
myNumber: float) -> int:
"""
Assumes myList is sorted. Returns index of closest value to myNumber.
"""Returns index of closest value to myNumber.
Assumes myList is sorted.
If two numbers are equally close, return the index of the smallest number.
Args:
Expand All @@ -73,6 +75,7 @@ def closest_index(myList: Union[list[float],np.ndarray],
Returns:
pos (int): Index of position of number in myList which is closest to myNumber.
"""
myList = list(myList)
pos = bisect_left(myList, myNumber)
Expand Down

0 comments on commit 6e15cce

Please sign in to comment.