Skip to content

Commit

Permalink
Update util.py
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-grim authored Nov 19, 2024
1 parent 1286cbb commit e749317
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/deep_neurographs/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,16 +682,15 @@ def get_memory_available():
return psutil.virtual_memory().available / 1e9


def spaced_idxs(container, k):
def spaced_idxs(arr_length, k):
"""
Generates an array of indices based on a specified step size and ensures
the last index is included.
Parameters:
----------
container : iterable
An iterable (e.g., list, array) from which the length is determined.
The length of this container dictates the range of generated indices.
arr_length : int
Length of array to be sampled from.
k : int
Step size for generating indices.
Expand All @@ -703,7 +702,7 @@ def spaced_idxs(container, k):
"container" is guaranteed to be included in the output.
"""
idxs = np.arange(0, len(container) + k, k)[:-1]
if len(container) % 2 == 0:
idxs = np.append(idxs, len(container) - 1)
idxs = np.arange(0, arr_length + k, k)[:-1]
if arr_length % 1 == 0:
idxs = np.append(idxs, arr_length - 1)
return idxs

0 comments on commit e749317

Please sign in to comment.