Datasets:
Formats:
json
Languages:
English
Size:
< 1K
Tags:
mathematics
convex-geometry
discrete-geometry
illumination-problem
computational-mathematics
exact-arithmetic
Download code/make_certificate.py from PureOne/SERAPH5-SAELYRA-v6: direct link, hf CLI and curl.
- Browser
- Download file 2.17 kB
-
https://huggingface.co/datasets/PureOne/SERAPH5-SAELYRA-v6/resolve/main/code/make_certificate.py
- Command line
-
hf download hf://datasets/PureOne/SERAPH5-SAELYRA-v6/code/make_certificate.py
-
curl -L -o make_certificate.py https://huggingface.co/datasets/PureOne/SERAPH5-SAELYRA-v6/resolve/main/code/make_certificate.py
2.17 kB
| #!/usr/bin/env python3 | |
| """Certify a supplied illuminating family for a normalized unconditional polytope. | |
| Input JSON keys: positive_rows (rational strings or integers), opposite_pairs. | |
| A failed test is not a proof that no other illuminating family exists. | |
| """ | |
| import argparse,json,sys | |
| from fractions import Fraction | |
| from pathlib import Path | |
| from verify_primary import orthant_vertices,make_certificate | |
| def main(): | |
| ap=argparse.ArgumentParser(description=__doc__);ap.add_argument('input',type=Path);ap.add_argument('--output',type=Path,required=True) | |
| args=ap.parse_args() | |
| try: | |
| obj=json.loads(args.input.read_text());raw=obj['positive_rows'];pairs=obj['opposite_pairs'] | |
| if not raw or not pairs:raise ValueError('Rows and direction pairs must be nonempty.') | |
| if any(isinstance(x,float) for r in raw for x in r):raise ValueError('Use rational strings, not floating-point coefficients.') | |
| rows=tuple(tuple(Fraction(x) for x in r) for r in raw);n=len(rows[0]) | |
| if not 2<=n<=8:raise ValueError('Supported dimensions are 2 through 8.') | |
| if len(rows)>20:raise ValueError('This simple enumerator is limited to 20 positive rows.') | |
| if any(len(r)!=n or min(r)<0 or max(r)>1 for r in rows):raise ValueError('Rows must be nonnegative, normalized, and equally sized.') | |
| if any(max(r[i] for r in rows)!=1 for i in range(n)):raise ValueError('Each coordinate must have unit intercept (column maximum one).') | |
| ds=[tuple(Fraction(x) for x in d) for d in pairs] | |
| if any(len(d)!=n or not any(d) for d in ds):raise ValueError('Each direction must be nonzero and have the correct dimension.') | |
| c=make_certificate(obj.get('label',args.input.stem),rows,orthant_vertices(rows),ds,True) | |
| args.output.parent.mkdir(parents=True,exist_ok=True);args.output.write_text(json.dumps(c,indent=2)+'\n') | |
| print(f"PASS: {c['direction_count']} directions; closed radius {c['closed_Hausdorff_radius']}; open radius {c['open_Hausdorff_radius']}") | |
| except (ValueError,KeyError,TypeError,OSError) as e: | |
| print(f'Certificate not issued: {e}',file=sys.stderr);sys.exit(1) | |
| if __name__=='__main__':main() | |