Skip to content

Commit 6dba890

Browse files
committed
NPI-3973 add additional logging to SType checks, restore a bizarre and previously removed code path for testing
1 parent 4eb7a63 commit 6dba890

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

gnssanalysis/gn_io/sinex.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def _get_valid_stypes(stypes: Union[list[str], set[str]]) -> _List[str]:
327327
"""Returns only stypes in allowed list
328328
Fastest if stypes size is small"""
329329
allowed_stypes = ["EST", "APR", "NEQ"]
330-
stypes = set(stypes) if not isinstance(stypes, set) else stypes
330+
stypes = set(stypes) if not isinstance(stypes, set) else stypes # Convert to set if not one.
331331
ok_stypes = sorted(stypes.intersection(allowed_stypes), key=allowed_stypes.index) # need EST to always be first
332332
if len(ok_stypes) != len(stypes):
333333
not_ok_stypes = stypes.difference(allowed_stypes)
@@ -544,12 +544,17 @@ def _get_snx_vector(
544544
if isinstance(path_or_bytes, str):
545545
path = path_or_bytes
546546
snx_bytes = _gn_io.common.path2bytes(path)
547-
# TODO Removed this very broken code path, not sure what happened
548-
# elif isinstance(path_or_bytes, list):
549-
# path, stypes, format, verbose = path_or_bytes
550-
# snx_bytes = _gn_io.common.path2bytes(path)
551-
else:
547+
# Very weird code path, should be removed if possible
548+
elif isinstance(path_or_bytes, list):
549+
_logging.error(
550+
f"path_or_bytes was a list! Using legacy code path. Please update this! Input values: {path_or_bytes}"
551+
)
552+
path, stypes, format, verbose = path_or_bytes
553+
snx_bytes = _gn_io.common.path2bytes(path)
554+
elif isinstance(path_or_bytes, bytes):
552555
snx_bytes = path_or_bytes
556+
else:
557+
raise ValueError(f"Unexpected type for path_or_bytes: {type(path_or_bytes)}. Value: {path_or_bytes}")
553558

554559
if snx_header == {}:
555560
snx_header = _get_snx_header(
@@ -560,7 +565,9 @@ def _get_snx_vector(
560565
"Indices are likely inconsistent between ESTIMATE and APRIORI in the EMR AC files hence files might be parsed incorrectly"
561566
)
562567

568+
_logging.info(f"Passing stypes through SType validator: {stypes}")
563569
stypes = _get_valid_stypes(stypes) # EST is always first as APR may have skips
570+
_logging.info(f"STypes after validator: {stypes}")
564571

565572
extracted = _snx_extract(snx_bytes=snx_bytes, stypes=stypes, obj_type="VECTOR", verbose=verbose)
566573
if extracted is None:

0 commit comments

Comments
 (0)