From 651437f441ef87615c9a87e1c72a8e210ebca543 Mon Sep 17 00:00:00 2001 From: Ronald Maj <36747983+ronaldmaj@users.noreply.github.com> Date: Thu, 9 Jan 2025 14:07:59 +1100 Subject: [PATCH] Apply suggestions from code review Fixing various type hints and adding helpful comments Co-authored-by: Nathan <95725385+treefern@users.noreply.github.com> --- gnssanalysis/gn_io/igslog.py | 9 ++++++--- tests/test_igslog.py | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gnssanalysis/gn_io/igslog.py b/gnssanalysis/gn_io/igslog.py index c3ed733..adea66a 100644 --- a/gnssanalysis/gn_io/igslog.py +++ b/gnssanalysis/gn_io/igslog.py @@ -257,14 +257,15 @@ def parse_igs_log_data(data: bytes, file_path: str, file_code: str) -> Union[_np :param bytes data: The bytes object returned from an open() call on a IGS site log in "rb" mode :param str file_path: The path to the file from which the "data" bytes object was obtained :param str file_code: Code from the filename_array passed to the parse_igs_log() function - :return Union[_np.ndarray, None]: Returns array with relevant data from the IGS log file bytes object + :return Union[_np.ndarray, None]: Returns array with relevant data from the IGS log file bytes object, + or `None` for unsupported version of the IGS Site log format. """ # Determine the version of the IGS log based on the data, Warn if unrecognised try: version = determine_log_version(data) except LogVersionError as e: logger.warning(f"Error: {e}, skipping parsing the log file") - return + return None # Extract information from ID block blk_id = extract_id_block(data=data, file_path=file_path, file_code=file_code, version=version) @@ -312,8 +313,10 @@ def parse_igs_log_file(filename_array: _np.ndarray) -> Union[_np.ndarray, None]: """Reads igs log file and outputs ndarray with parsed data :param _np.ndarray filename_array: Metadata on input log file. Expects ndarray of the form [CODE DATE PATH] - :return _np.ndarray: Returns array with data from the parsed IGS log file + :return Union[_np.ndarray, None]: Returns array with data from the parsed IGS log file, or `None` for unsupported + version of the IGS Site log format. """ + # Split filename_array out into its three components (CODE, DATE, PATH), discarding the second element (DATE): file_code, _, file_path = filename_array with open(file_path, "rb") as file: diff --git a/tests/test_igslog.py b/tests/test_igslog.py index 788c705..5b8e5da 100644 --- a/tests/test_igslog.py +++ b/tests/test_igslog.py @@ -132,6 +132,7 @@ def setUp(self): self.setUpPyfakefs() def test_gather_metadata(self): + self.fs.reset() # Ensure fake filesystem is cleared from any previous tests, as it is backed by real filesystem. # Create some fake files file_paths = ["/fake/dir/abmf.log", "/fake/dir/aggo.log"] self.fs.create_file(file_paths[0], contents=v2_data)