Skip to content

Commit 9b18415

Browse files
author
Thinh Nguyen
committed
minor bugfix
1 parent 258839b commit 9b18415

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

element_array_ephys/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def find_full_path(root_directories, relative_path):
1111
from provided potential root directories (in the given order)
1212
:param root_directories: potential root directories
1313
:param relative_path: the relative path to find the valid root directory
14-
:return: root_directory
14+
:return: root_directory (pathlib.Path object)
1515
"""
1616
relative_path = pathlib.Path(relative_path)
1717

@@ -36,7 +36,7 @@ def find_root_directory(root_directories, full_path):
3636
search and return one directory that is the parent of the given path
3737
:param root_directories: potential root directories
3838
:param full_path: the relative path to search the root directory
39-
:return: full-path
39+
:return: full-path (pathlib.Path object)
4040
"""
4141
full_path = pathlib.Path(full_path)
4242

@@ -48,8 +48,9 @@ def find_root_directory(root_directories, full_path):
4848
root_directories = [root_directories]
4949

5050
try:
51-
return next(root_dir for root_dir in root_directories
52-
if full_path.is_relative_to(root_dir))
51+
return next(pathlib.Path(root_dir) for root_dir in root_directories
52+
if pathlib.Path(root_dir) in set(full_path.parents))
53+
5354
except StopIteration:
5455
raise FileNotFoundError('No valid root directory found (from {})'
5556
' for {}'.format(root_directories, full_path))

element_array_ephys/readers/kilosort.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ def _stat(self):
9898
cluster_file = next(self._kilosort_dir.glob(cluster_pattern))
9999
except StopIteration:
100100
pass
101-
102-
cluster_file_suffix = cluster_file.suffix
103-
assert cluster_file_suffix in ('.csv', '.tsv', '.xlsx')
104-
break
101+
else:
102+
cluster_file_suffix = cluster_file.suffix
103+
assert cluster_file_suffix in ('.csv', '.tsv', '.xlsx')
104+
break
105105
else:
106106
raise FileNotFoundError(
107107
'Neither "cluster_groups" nor "cluster_KSLabel" file found!')

0 commit comments

Comments
 (0)