From f5dfbe11bc71fb77c5edacf7902a1bff12876796 Mon Sep 17 00:00:00 2001 From: nikitakuklev Date: Mon, 7 Oct 2024 05:21:44 -0500 Subject: [PATCH] Fix casting of column-order parameter --- pysdds/readers/readers.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/pysdds/readers/readers.py b/pysdds/readers/readers.py index 6e267d5..2e6cc8e 100644 --- a/pysdds/readers/readers.py +++ b/pysdds/readers/readers.py @@ -390,6 +390,8 @@ def read( logger.debug(f"Params: {sdds.parameters}") logger.debug(f"Arrays: {sdds.arrays}") logger.debug(f"Columns: {sdds.columns}") + logger.debug(f"Data: {sdds.data}") + logger.debug(f"Description: {sdds.description}") if header_only: return sdds @@ -427,7 +429,7 @@ def read( if sdds._meta_fixed_rowcount: if sdds.mode != "binary": raise ValueError( - f'Meta-command "!#fixed-rowcount" requires binary mode, not {sdds.mode}' + f'Meta-command "!# fixed-rowcount" requires binary mode, not {sdds.mode}' ) # Verify that parameter, array, column, and page masks can be applied @@ -732,7 +734,7 @@ def __find_next_namelist(stream, accept_meta_commands=False): if line == "!# big-endian": if endianness == "auto" or endianness == "big": sdds.endianness = "big" - logger.debug(f"Binary file endianness set to ({sdds.endianness})") + logger.debug(f"Binary file endianness set to ({sdds.endianness}) from meta-command") meta_endianness_set = True else: raise ValueError( @@ -741,13 +743,14 @@ def __find_next_namelist(stream, accept_meta_commands=False): elif line == "!# little-endian": if endianness == "auto" or endianness == "little": sdds.endianness = "little" - logger.debug(f"Binary file endianness set to ({sdds.endianness})") + logger.debug(f"Binary file endianness set to ({sdds.endianness}) from meta-command") meta_endianness_set = True else: raise ValueError( f"File endianness ({line}) does not match requested one ({endianness})" ) elif line == "!# fixed-rowcount": + logger.debug("Fixed rowcount meta-command found - setting flag") sdds._meta_fixed_rowcount = True else: raise Exception(f"Meta command {line} is not recognized") @@ -997,7 +1000,7 @@ def __find_next_namelist(stream, accept_meta_commands=False): if line == "!# big-endian": if endianness == "auto" or endianness == "big": sdds.endianness = "big" - logger.debug(f"Binary file endianness set to ({sdds.endianness})") + logger.debug(f"Binary file endianness set to ({sdds.endianness}) from meta-command") meta_endianness_set = True else: raise ValueError( @@ -1006,13 +1009,14 @@ def __find_next_namelist(stream, accept_meta_commands=False): elif line == "!# little-endian": if endianness == "auto" or endianness == "little": sdds.endianness = "little" - logger.debug(f"Binary file endianness set to ({sdds.endianness})") + logger.debug(f"Binary file endianness set to ({sdds.endianness}) from meta-command") meta_endianness_set = True else: raise ValueError( f"File endianness ({line}) does not match requested one ({endianness})" ) elif line == "!# fixed-rowcount": + logger.debug("Fixed rowcount meta-command found - setting flag") sdds._meta_fixed_rowcount = True else: raise Exception(f"Meta command {line} is not recognized") @@ -1087,6 +1091,8 @@ def __find_next_namelist(stream, accept_meta_commands=False): nm_dict["lines_per_row"] = int(nm_dict["lines_per_row"]) if "no_row_counts" in nm_keys: nm_dict["no_row_counts"] = int(nm_dict["no_row_counts"]) + if 'column_major_order' in nm_keys: + nm_dict['column_major_order'] = int(nm_dict['column_major_order']) if "endian" in nm_keys: data_endianness = nm_dict["endian"] if meta_endianness_set: @@ -1243,6 +1249,7 @@ def _read_pages_binary( logger.debug(f"All numeric: {columns_all_numeric}") if sdds.data.column_major_order != 0: + logger.debug("Data is in column-major order - no special handling required") pass elif columns_all_numeric and sdds._meta_fixed_rowcount: # Numeric types but fixed rows - have to parse row by row