Skip to content

Commit 64491b0

Browse files
committed
Force path wrappings to correct regex string matching on Windows
1 parent a3e06ce commit 64491b0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/ramjet/photometric_database/tess_ffi_light_curve.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ def get_tic_id_and_sector_from_file_path(path: Union[Path, str]) -> (int, Union[
114114
:param path: The path of the file to extract the TIC ID and sector.
115115
:return: The TIC ID and sector. The sector might be omitted (as None).
116116
"""
117-
if isinstance(path, Path):
118-
path = str(path)
117+
path = str(Path(path))
119118
# Search for Brian Powell's FFI path convention with directory structure sector, magnitude, target.
120119
# E.g., "tesslcs_sector_12/tesslcs_tmag_1_2/tesslc_290374453"
121120
match = re.search(r'tesslcs_sector_(\d+)(?:_104)?/(?:2_min_cadence_targets|tesslcs_tmag_\d+_\d+)/tesslc_(\d+)', path)
@@ -141,14 +140,13 @@ def get_floor_magnitude_from_file_path(file_path: Union[Path, str]) -> int:
141140
:param file_path: The path of the file to extract the magnitude.
142141
:return: The magnitude floored.
143142
"""
144-
if isinstance(file_path, Path):
145-
file_path = str(file_path)
143+
file_path_string = str(Path(file_path))
146144
# Search for Brian Powell's FFI path convention with directory structure sector, magnitude, target.
147145
# E.g., "tesslcs_sector_12/tesslcs_tmag_1_2/tesslc_290374453"
148-
match = re.search(r'tesslcs_sector_\d+(?:_104)?/tesslcs_tmag_(\d+)_\d+/tesslc_\d+', file_path)
146+
match = re.search(r'tesslcs_sector_\d+(?:_104)?/tesslcs_tmag_(\d+)_\d+/tesslc_\d+', file_path_string)
149147
if match:
150148
return int(match.group(1))
151-
raise ValueError(f'{file_path} does not match a known pattern to extract magnitude from.')
149+
raise ValueError(f'{file_path_string} does not match a known pattern to extract magnitude from.')
152150

153151
@staticmethod
154152
def get_magnitude_from_file(file_path: Union[Path, str]) -> float:

0 commit comments

Comments
 (0)