Skip to content

Commit c817d91

Browse files
authored
Merge pull request #5 from steppi/default-tol-files
Add loose default tolerance files for compiler/os/architecture combinations with a specific file
2 parents 74836e8 + 0decfa5 commit c817d91

File tree

234 files changed

+93
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+93
-3
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""Generate error tolerance tables for unspecified
2+
compiler/platform/os combinations by creating tables that are looser
3+
than all platform specific tables for a given collection of test cases
4+
for a particular function for a particular set of input types.."""
5+
6+
7+
import argparse
8+
import numpy as np
9+
import polars as pl
10+
import pyarrow as pa
11+
import pyarrow.parquet as pq
12+
13+
from functools import reduce
14+
from pathlib import Path
15+
16+
from xsref.tables import _get_git_info
17+
18+
19+
if __name__ == "__main__":
20+
parser = argparse.ArgumentParser()
21+
parser.add_argument("table_path_root")
22+
parser.add_argument("--factor", type=float, default=4.0)
23+
args = parser.parse_args()
24+
table_path_root = Path(args.table_path_root)
25+
26+
for inpath in table_path_root.glob("**/In_*.parquet"):
27+
types = inpath.name.removesuffix(".parquet").replace("In_", "")
28+
pattern = f"Err_{types}_*.parquet"
29+
other_err_table_name = pattern.replace("*", "other")
30+
err_tables = []
31+
for errpath in inpath.parent.glob(pattern):
32+
if errpath.name == other_err_table_name:
33+
continue
34+
err_tables.append(pl.read_parquet(errpath).to_numpy())
35+
other_err_table = reduce(lambda x, y: np.maximum(x, y), err_tables)
36+
factor = other_err_table.dtype.type(args.factor)
37+
with np.errstate(over="ignore"):
38+
other_err_table = np.maximum(
39+
other_err_table, np.finfo(other_err_table.dtype).eps
40+
) * factor
41+
X = [
42+
pa.array(other_err_table[:, i]) for i in range(other_err_table.shape[1])
43+
]
44+
other_err_table = pa.table(X, names=pq.read_schema(errpath).names)
45+
46+
metadata = pq.read_schema(inpath).metadata
47+
metadata[b"input_checksum"] = b"NA"
48+
metadata[b"output_checksum"] = b"NA"
49+
metadata[b"scipy_version"] = b"NA"
50+
metadata[b"cpp_compiler"] = b"NA"
51+
metadata[b"cpp_compiler_version"] = b"NA"
52+
metadata[b"architecture"] = b"NA"
53+
metadata[b"operating_system"] = b"NA"
54+
commit_hash, working_tree = _get_git_info()
55+
metadata[b"xsref_commit_hash"] = commit_hash
56+
metadata[b"working_tree_state"] = working_tree
57+
58+
other_err_table = other_err_table.replace_schema_metadata(metadata)
59+
outpath = inpath.parent / other_err_table_name
60+
pq.write_table(
61+
other_err_table, outpath, compression="zstd", compression_level=22
62+
)
10.9 KB
Binary file not shown.
5.32 MB
Binary file not shown.
Binary file not shown.
2.4 KB
Binary file not shown.
1.52 KB
Binary file not shown.
1.52 KB
Binary file not shown.
1.54 KB
Binary file not shown.
1.54 KB
Binary file not shown.
1.54 KB
Binary file not shown.

0 commit comments

Comments
 (0)