@@ -50,9 +50,6 @@ class NavData():
5050 str_map : Dict
5151 Map of the form {pandas column name : {array value : string}}.
5252 Map is of the form {pandas column name : {}} for non string rows.
53- num_cols : int
54- Number of columns in array containing data, set to 0 by default
55- for empty NavData
5653 curr_cols : int
5754 Current number of column for iterator, set to 0 by default
5855
@@ -70,7 +67,6 @@ def __init__(self, csv_path=None, pandas_df=None, numpy_array=None,
7067 # Attributes for looping over all columns
7168
7269 self .curr_col = 0
73- self .num_cols = 0
7470
7571 if csv_path is not None :
7672 self .from_csv_path (csv_path , ** kwargs )
@@ -81,6 +77,7 @@ def __init__(self, csv_path=None, pandas_df=None, numpy_array=None,
8177 else :
8278 self ._build_navdata ()
8379
80+
8481 if len (self ) > 0 :
8582 self .rename (self ._row_map (), inplace = True )
8683 self .postprocess ()
@@ -694,6 +691,18 @@ def shape(self):
694691 shp = np .shape (self .array )
695692 return shp
696693
694+ @property
695+ def num_cols (self ):
696+ """Return the number of columns in the NavData instance.
697+
698+ Returns
699+ -------
700+ num_cols : int
701+ Number of columns in the NavData instance.
702+ """
703+ num_cols = self .shape [1 ]
704+ return num_cols
705+
697706 @property
698707 def rows (self ):
699708 """Return all row names in instance as a list
@@ -879,7 +888,6 @@ def __iter__(self):
879888 Instantiation of NavData class with iteration initialized
880889 """
881890 self .curr_col = 0
882- self .num_cols = np .shape (self .array )[1 ]
883891 return self
884892
885893 def __next__ (self ):
@@ -890,7 +898,7 @@ def __next__(self):
890898 x_curr : gnss_lib_py.navdata.navdata.NavData
891899 Current column (based on iteration count)
892900 """
893- if self .curr_col >= self . num_cols :
901+ if self .curr_col >= len ( self ) :
894902 raise StopIteration
895903 x_curr = self .copy (rows = None , cols = self .curr_col )
896904 self .curr_col += 1
0 commit comments