diff options
| author | J08nY | 2025-03-21 18:51:04 +0100 |
|---|---|---|
| committer | J08nY | 2025-04-16 12:25:06 +0200 |
| commit | ff9a8fbcf06995c5fa42816bae3111c7d46793af (patch) | |
| tree | 9284ac2a092c571af8bdfeea5c6e11e26ed7559a | |
| parent | 6e59917666dbe7b2c2e2685ab6b01c4c43dacf2e (diff) | |
| download | ECTester-ff9a8fbcf06995c5fa42816bae3111c7d46793af.tar.gz ECTester-ff9a8fbcf06995c5fa42816bae3111c7d46793af.tar.zst ECTester-ff9a8fbcf06995c5fa42816bae3111c7d46793af.zip | |
| -rw-r--r-- | epare/probmaps.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/epare/probmaps.py b/epare/probmaps.py index cf1a050..a5d4510 100644 --- a/epare/probmaps.py +++ b/epare/probmaps.py @@ -15,6 +15,7 @@ def divides_any(l: int, small_scalars: set[int]) -> bool: return True return False + def process_small_scalars(scalar_results: MultResults, divisors: set[int]) -> ProbMap: result = {} for divisor in divisors: @@ -25,18 +26,27 @@ def process_small_scalars(scalar_results: MultResults, divisors: set[int]) -> Pr result[divisor] = count / scalar_results.samples return ProbMap(result, scalar_results.samples, scalar_results.kind) + def load_chunk(fname: str, divisors: set[int], kind: str) -> dict[MultIdent, ProbMap]: with open(fname, "rb") as f: - multiples = pickle.load(f) + multiples = {} + while True: + try: + mult, distr = pickle.load(f) + multiples[mult] = distr + except EOFError: + break res = {} for mult, results in multiples.items(): results.kind = kind res[mult] = process_small_scalars(results, divisors) return res + def powers_of(k, max_power=20): return [k**i for i in range(1, max_power)] + def prod_combine(one, other): return [a * b for a, b in itertools.product(one, other)] @@ -99,4 +109,4 @@ if __name__ == "__main__": print(f"Got {prob_map.samples} for {mult}.") # Save with open(f"{divisor_name}_{kind}_distrs.pickle", "wb") as f: - pickle.dump(distributions_mults, f)
\ No newline at end of file + pickle.dump(distributions_mults, f) |
