-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpurge_matrices.py
43 lines (36 loc) · 1014 Bytes
/
purge_matrices.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
from pathlib import Path
from plot_utils import load_data
from stats import TimeStepStats
known_data = set()
stats_dir = Path('./stats')
data_dir = Path('./matrices')
for stats_file in os.listdir(stats_dir):
stats = load_data(stats_dir / stats_file)
skip = False
try:
stats[0]
except KeyError:
skip = True
else:
skip = not isinstance(stats[0], TimeStepStats)
if skip:
print('Skipping', stats_file)
continue
for ts in stats:
for ls in ts.linear_solves:
known_data.add(ls.matrix_id)
known_data.add(ls.iterate_id)
known_data.add(ls.state_id)
known_data.add(ls.rhs_id)
found = 0
not_found = 0
for mat_file in os.listdir(data_dir):
if mat_file in known_data:
found += 1
# print("Found:", mat_file)
else:
not_found += 1
os.remove(data_dir / mat_file)
print("Removed:", mat_file)
print(f'Removed {not_found} / {found + not_found}')