"""Stored housing snapshot quartiles, two explicitly named interpolation methods.""" import hashlib,json,statistics,sys from fractions import Fraction as F from decimal import Decimal,localcontext,ROUND_HALF_UP from pathlib import Path def show(x): with localcontext()as c:c.prec=70;return str((Decimal(x.numerator)/Decimal(x.denominator)).quantize(Decimal('.01'),rounding=ROUND_HALF_UP)) def value(x):return {'exact':str(x),'rounded_2dp':show(x)} def quartile(sorted_values,p,method): n=len(sorted_values);assert n>=4 index=(n-1)*p if method=='inclusive'else(n+1)*p-1 left=index.numerator//index.denominator;weight=index-left;assert 0<=lefthigh] assert not(lowhigh)and not(highhigh) groups.append({'month':month,'method':method,'count':len(records),'q1':value(q1),'q3':value(q3),'iqr':value(iqr),'lower_fence':value(low),'upper_fence':value(high),'flag_count':len(flagged),'flagged_rows':flagged,'all_rows':records}) return {'kind':'stored_snapshot_iqr_review_candidates_not_erroneous_transaction_detection','calculated_on':'2026-11-02','source_sha256':hashlib.sha256(raw).hexdigest(),'groups':groups,'method':'Zero-based quartileindex inclusive=(N-1)*p; exclusive=(N+1)*p-1. Linearinterpolation thenQ1-1.5IQR,Q3+1.5IQR. Strict outside only; equality notflagged. Fractions crosschecked against Python3.10 statistics.quantiles.','scope':'Only previously saved36rows; mixedmonths/areas/units are not matched properties. No new market query, transactionvalidity finding, automatic deletion, normality assumption, marketvalue or representativeness certification.'} if __name__=='__main__':print(json.dumps(calculate(Path(sys.argv[1]).read_bytes()),ensure_ascii=False,indent=2))