Skip to content

Commit

Permalink
Fix following bugs:
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Zong-han, Xie committed Oct 13, 2024
1 parent 1df1f77 commit 08ba71e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modmesh/timeseries_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 08ba71e

Please sign in to comment.