Datasets:
Formats:
csv
Languages:
English
Size:
< 1K
Tags:
mathematics
homogenization
spectral-theory
variational-methods
matrix-analysis
scientific-computing
Download export_tables.py from PureOne/EVE-QELTHA: direct link, hf CLI and curl.
- Browser
- Download file 3.02 kB
-
https://huggingface.co/datasets/PureOne/EVE-QELTHA/resolve/main/export_tables.py
- Command line
-
hf download hf://datasets/PureOne/EVE-QELTHA/export_tables.py
-
curl -L -o export_tables.py https://huggingface.co/datasets/PureOne/EVE-QELTHA/resolve/main/export_tables.py
3.02 kB
| #!/usr/bin/env python3 | |
| """Export three small Hub-viewable tables from the recorded verification JSON. | |
| No solver is rerun and no numerical value is rounded or fabricated. | |
| """ | |
| from pathlib import Path | |
| import csv | |
| import json | |
| ROOT = Path(__file__).resolve().parent | |
| def write_csv(name, rows): | |
| keys = list(dict.fromkeys(key for row in rows for key in row)) | |
| path = ROOT / 'data' / name | |
| path.parent.mkdir(exist_ok=True) | |
| with path.open('w', encoding='utf-8', newline='') as out: | |
| writer = csv.DictWriter(out, fieldnames=keys, lineterminator='\n') | |
| writer.writeheader() | |
| writer.writerows(rows) | |
| return len(rows) | |
| def response_columns(response): | |
| fields = {} | |
| for i in range(2): | |
| for j in range(2): | |
| fields[f'Y{i+1}{j+1}_real'] = response['real_part'][i][j] | |
| fields[f'Y{i+1}{j+1}_imag'] = response['imaginary_part'][i][j] | |
| for i, value in enumerate(response['eigenvalues'], 1): | |
| fields[f'response_eigenvalue_{i}'] = value | |
| return fields | |
| def main(): | |
| source = ROOT / 'research' / 'results' | |
| critical = json.loads((source / 'critical.json').read_text(encoding='utf-8')) | |
| rows = [] | |
| for case in critical['cases']: | |
| for record in case['rows']: | |
| row = dict(factor_kind=case['kind'], tau=case['tau'], n=record['n'], | |
| rho=record['penalty'], | |
| relative_response_error=record['relative_error_to_effective_response']) | |
| row.update(response_columns(record['response'])) | |
| row.update(record['solver_metrics']) | |
| rows.append(row) | |
| counts = {'critical_crossover': write_csv('critical_crossover.csv', rows)} | |
| ports = json.loads((source / 'nexus_uniform.json').read_text(encoding='utf-8')) | |
| rows = [] | |
| for i, record in enumerate(ports['rows']): | |
| row = dict(case_index=i, kind=record['kind'], epsilon=record['epsilon'], | |
| lambda_finite='' if record['strength'] == 'infinity' else record['strength'], | |
| hard_constraint=record['strength'] == 'infinity', | |
| check=record.get('check', 'main')) | |
| row.update({k: v for k, v in record.items() | |
| if k not in {'kind', 'epsilon', 'strength', 'check'}}) | |
| rows.append(row) | |
| counts['compact_ports'] = write_csv('compact_ports.csv', rows) | |
| design = critical['finite_critical_compensation_design'] | |
| rows = [] | |
| for record in design['rows']: | |
| row = dict(tau=design['tau'], n=record['n'], rho=record['penalty'], | |
| relative_response_error=record['relative_error_to_prescribed_response'], | |
| effective_potential_identity_error=design['effective_potential_identity_error']) | |
| row.update(response_columns(record['response'])) | |
| row.update(record['solver_metrics']) | |
| rows.append(row) | |
| counts['critical_compensation'] = write_csv('critical_compensation.csv', rows) | |
| print(json.dumps(counts, indent=2)) | |
| if __name__ == '__main__': | |
| main() | |