MCPcopy Create free account
hub / github.com/GameTechDev/PresentMon / load_csvs

Method load_csvs

Tests/Scripts/analyze-paced.py:118–206  ·  view source on GitHub ↗

Returns list of (label, DataFrame) based on run mode. RoundRobin: - Load: folder/name_robin_#.csv OneShot: - Must load: folder/name_oneshot.csv (mandatory) - Must also load: golds_folder/name_gold.csv Full: - Load: folder/na

(self, folder, name, golds_folder, run_mode)

Source from the content-addressed store, hash-verified

116 self.draw_plot(self.x_col, self.y_choices[0])
117
118 def load_csvs(self, folder, name, golds_folder, run_mode):
119 """
120 Returns list of (label, DataFrame) based on run mode.
121
122 RoundRobin:
123 - Load: folder/name_robin_#.csv
124
125 OneShot:
126 - Must load: folder/name_oneshot.csv (mandatory)
127 - Must also load: golds_folder/name_gold.csv
128
129 Full:
130 - Load: folder/name_full_#.csv
131 - Must also load: golds_folder/name_gold.csv
132 - Also try to include: folder/name_oneshot.csv (if present)
133 """
134 out = []
135
136 def try_load_csv(path, label=None):
137 try:
138 df = pd.read_csv(path, header=0)
139 if df.shape[1] >= 2:
140 lab = label if label is not None else os.path.basename(path)
141 out.append((lab, df))
142 if lab not in self.visible:
143 self.visible[lab] = True
144 else:
145 print(f"Skipping {path}: not enough columns")
146 except Exception as e:
147 print(f"Skipping {path}: {e}")
148
149 try:
150 folder_files = sorted(os.listdir(folder))
151 except FileNotFoundError:
152 print(f"Folder not found: {folder}")
153 folder_files = []
154
155 oneshot_fname = f"{name}_oneshot.csv"
156 gold_fname = f"{name}_gold.csv"
157
158 if run_mode == RunMode.RoundRobin:
159 robin_re = re.compile(rf'^{re.escape(name)}_robin_(\d+)\.csv$')
160 for fname in folder_files:
161 if robin_re.match(fname):
162 try_load_csv(os.path.join(folder, fname))
163
164 elif run_mode == RunMode.OneShot:
165 # Mandatory oneshot
166 oneshot_path = os.path.join(folder, oneshot_fname)
167 if os.path.isfile(oneshot_path):
168 try_load_csv(oneshot_path)
169 else:
170 print(f"ERROR: Oneshot file is mandatory but not found: {oneshot_path}")
171 return [] # cause error popup upstream
172
173 # Gold must be available for the comparison basis
174 if not golds_folder:
175 print("ERROR: Golds folder is required in one-shot mode.")

Callers 1

__init__Method · 0.95

Calls 1

printClass · 0.85

Tested by

no test coverage detected