Skip to content

Commit

Permalink
Performed basic testing to check if mmap is causing Windows test fail…
Browse files Browse the repository at this point in the history
…ures.
  • Loading branch information
birchkwok committed Sep 15, 2024
1 parent 4d40bb3 commit dffbd7f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lynse/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,29 @@ def wrapper(*args, **kwargs):


def load_chunk_file(filename):
np_array = np.asarray(np.load(filename, mmap_mode='r'))
np_array = np.load(filename)
return np_array


class NpyLoader:
def __init__(self, filename):
self.filename = filename
self.np_array = None
self.mmap = None
# self.mmap = None

def __enter__(self):
self.np_array = load_chunk_file(self.filename)

self.mmap = getattr(self.np_array, 'base', None)
# self.mmap = getattr(self.np_array, 'base', None)

return self.np_array

def __exit__(self, exc_type, exc_value, traceback):
if self.np_array is not None:
del self.np_array
if self.mmap is not None and hasattr(self.mmap, 'close'):
self.mmap.close()
pass
# if self.np_array is not None:
# del self.np_array
# if self.mmap is not None and hasattr(self.mmap, 'close'):
# self.mmap.close()



Expand Down

0 comments on commit dffbd7f

Please sign in to comment.