From 08ba71e95f62408064d1496a7caf91a8067faea6 Mon Sep 17 00:00:00 2001 From: "Zong-han, Xie" Date: Sun, 13 Oct 2024 22:21:03 +0800 Subject: [PATCH] Fix following bugs: 1. incorrect statement to initialize index_column_num 2. _index_column should be np.uint64 3. incorrect " -1" causing incorrect dimension when generating index column 4. remove ".strip()" to preserve the original string in the CSV header. --- modmesh/timeseries_dataframe.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modmesh/timeseries_dataframe.py b/modmesh/timeseries_dataframe.py index a962a91e..911ddfdc 100644 --- a/modmesh/timeseries_dataframe.py +++ b/modmesh/timeseries_dataframe.py @@ -69,18 +69,18 @@ def read_from_text_file( raise Exception("Text file '{}' does not exist".format(txt_path)) nd_arr = np.genfromtxt(txt_path, delimiter=delimiter)[1:] - index_column_num = 0 if timestamp_in_file is not None else None # default treat 0th column as the index column + index_column_num = 0 if timestamp_in_file else None # default treat 0th column as the index column with open(txt_path, 'r') as f: - table_header = [x.strip() for x in f.readline().strip().split(delimiter)] + table_header = [x for x in f.readline().strip().split(delimiter)] if timestamp_in_file: if timestamp_column in table_header: index_column_num = table_header.index(timestamp_column) # If timestamp_column is None or not in table header, default treat 0th column as the index column - self._index_column = SimpleArrayUint64(nd_arr[:, index_column_num].astype(np.uintc)) + self._index_column = SimpleArrayUint64(array=nd_arr[:, index_column_num].astype(np.uint64)) self._index_column_name = table_header[index_column_num] else: - self._index_column = SimpleArrayUint64(np.arange(nd_arr.shape[0] - 1).astype(np.uintc)) + self._index_column = SimpleArrayUint64(array=np.arange(nd_arr.shape[0]).astype(np.uint64)) self._index_column_name = "Index" self._columns = table_header if index_column_num is not None: