Fix decimal percentages and scientific probability literals in binomial questions
#9
by emberian - opened
Files changed (6)
- root/specialists/statistics-v2/organ_stats_v1.py+38-2
- root/specialists/statistics-v2/organ_stats_v2.py+5-5
- root/specialists/statistics-v3/organ_stats_v1.py+38-2
- root/specialists/statistics-v3/organ_stats_v2.py+5-5
- root/specialists/statistics/organ_stats_v1.py+38-2
- tests/statistics/test_binomial_probability_binding.pyAdded+121
5 unmodified lines6789101112131415161726 unmodified lines444546474849505152535 unmodified linesfrom __future__ import annotationsimport mathimport reimport statistics as stNUMS = re.compile(r"-?\d+(?:\.\d+)?")def nums_after(t):m = re.search(r"(?:of|for|in|data(?:set)?|numbers|values|list)[:\s]+((?:-?\d+(?:\.\d+)?[,\s]+(?:and\s+)?)+-?\d+(?:\.\d+)?)", t, re.I)return [float(x) for x in NUMS.findall(m.group(1))] if m else None26 unmodified linesv = math.perm(n, k) if k is not None else math.factorial(n)return self._say("permutations", "There are %d ordered arrangements (%s)." % (v, "P(%d, %d)" % (n, k) if k is not None else "%d!" % n), v)# binomial P(X = k)m = re.search(r"\bprobability\b.*?\bexactly (\d+)\b.*?\b(\d+) (?:trials|flips|tosses|rolls|attempts|times)\b.*?\b(?:p|probability of success|chance)\s*(?:=|of|is)?\s*(0?\.\d+|\d+(?:\.\d+)?%)", low)if m:k, n, p = int(m.group(1)), int(m.group(2)), m.group(3)p = float(p.rstrip("%")) / 100 if p.endswith("%") else float(p)v = math.comb(n, k) * p ** k * (1 - p) ** (n - k)return self._say("binomial", "P(X = %d) = %.6g for %d trials with p = %g (C(%d,%d) · p^%d · (1−p)^%d)." % (k, v, n, p, n, k, k, n - k), v)m = re.search(r"\bz[- ]?score\b.*?(-?\d+(?:\.\d+)?)\D+?(?:mean|average|μ)\D*?(-?\d+(?:\.\d+)?)\D+?(?:standard deviation|sd|std|σ)\D*?(\d+(?:\.\d+)?)", low)5 unmodified lines678910111213141516171819202122232425262728293031323334353637383940414243444546474849505126 unmodified lines7879808182838485868788895 unmodified linesfrom __future__ import annotationsimport mathfrom fractions import Fractionimport reimport statistics as st# Consume the complete scalar before converting percent to probability.# In particular, 0.5% is 0.005 and 0.5e-2 is 0.005, never 0.5.PROBABILITY = r"([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(?:\s*%)?)(?![\w%/]|[.,]\d|[+-]|\s*%)"NUMS = re.compile(r"-?\d+(?:\.\d+)?")def probability_value(literal):"""Bind a bounded exact scalar before using the existing float formula.No numerical distribution theorem is claimed. A probability rounded ontoeither endpoint would silently change the stated Bernoulli model, so itis refused. Limits apply before Fraction allocates exponent-sized values."""token = literal.replace(" ", "")if len(token) > 4096:return Nonepercent = token.endswith("%")scalar = token[:-1] if percent else tokenexponent = re.search(r"[eE]([+-]?)(\d+)$", scalar)if exponent:digits = exponent.group(2).lstrip("0") or "0"if len(digits) > 5 or int(digits) > 10000:return Nonetry:exact = Fraction(scalar) / (100 if percent else 1)if not 0 <= exact <= 1:return Nonevalue = float(exact)except (ValueError, OverflowError, ZeroDivisionError):return Noneif not math.isfinite(value) or (exact != 0 and value == 0) or (exact != 1 and value == 1):return Nonereturn valuedef nums_after(t):m = re.search(r"(?:of|for|in|data(?:set)?|numbers|values|list)[:\s]+((?:-?\d+(?:\.\d+)?[,\s]+(?:and\s+)?)+-?\d+(?:\.\d+)?)", t, re.I)return [float(x) for x in NUMS.findall(m.group(1))] if m else None26 unmodified linesv = math.perm(n, k) if k is not None else math.factorial(n)return self._say("permutations", "There are %d ordered arrangements (%s)." % (v, "P(%d, %d)" % (n, k) if k is not None else "%d!" % n), v)# binomial P(X = k)m = re.search(r"\bprobability\b.*?\bexactly (\d+)\b.*?\b(\d+) (?:trials|flips|tosses|rolls|attempts|times)\b.*?\b(?:p|probability of success|chance)\s*(?:=|of|is)?\s*" + PROBABILITY, low)if m:k, n, p = int(m.group(1)), int(m.group(2)), m.group(3)p = probability_value(p)if p is None or k > n:return self._say("impossible", "That isn't a supported binomial setup (need 0 ≤ p ≤ 1, a safely representable p, and k ≤ n).", status="withheld")v = math.comb(n, k) * p ** k * (1 - p) ** (n - k)return self._say("binomial", "P(X = %d) = %.6g for %d trials with p = %g (C(%d,%d) · p^%d · (1−p)^%d)." % (k, v, n, p, n, k, k, n - k), v)m = re.search(r"\bz[- ]?score\b.*?(-?\d+(?:\.\d+)?)\D+?(?:mean|average|μ)\D*?(-?\d+(?:\.\d+)?)\D+?(?:standard deviation|sd|std|σ)\D*?(\d+(?:\.\d+)?)", low)
14 unmodified lines1516171819202122232452 unmodified lines77787980818283848514 unmodified linesfrom fractions import Fractionimport refrom organ_stats_v1 import StatsOrganD = r"(\d+)"P = r"(\d*\.\d+|\d+(?:\.\d+)?\s*%|0|1)"def _kn_choose(low):52 unmodified linesor re.search(r"\bwith (?:a )?(?:probability|chance)\s*(?:of)?\s*" + P, low))if km and nm and pm:k, n, ps = int(km.group(1)), int(nm.group(1)), pm.group(1).replace(" ", "")p = float(ps.rstrip("%")) / 100 if ps.endswith("%") else float(ps)if not 0 <= p <= 1 or k > n:return self._say("impossible", "That isn't a valid binomial setup (need 0 ≤ p ≤ 1 and k ≤ n).", status="withheld")v = math.comb(n, k) * p ** k * (1 - p) ** (n - k)return self._say("binomial", "P(X = %d) = %s for n = %d trials with p = %s (C(%d, %d) p^%d (1 − p)^%d)." % (k, "%.6g" % v, n, "%g" % p, n, k, k, n - k), v)14 unmodified lines1516171819202122232452 unmodified lines77787980818283848514 unmodified linesfrom fractions import Fractionimport refrom organ_stats_v1 import StatsOrgan, PROBABILITY, probability_valueD = r"(\d+)"P = PROBABILITYdef _kn_choose(low):52 unmodified linesor re.search(r"\bwith (?:a )?(?:probability|chance)\s*(?:of)?\s*" + P, low))if km and nm and pm:k, n, ps = int(km.group(1)), int(nm.group(1)), pm.group(1).replace(" ", "")p = probability_value(ps)if p is None or k > n:return self._say("impossible", "That isn't a supported binomial setup (need 0 ≤ p ≤ 1, a safely representable p, and k ≤ n).", status="withheld")v = math.comb(n, k) * p ** k * (1 - p) ** (n - k)return self._say("binomial", "P(X = %d) = %s for n = %d trials with p = %s (C(%d, %d) p^%d (1 − p)^%d)." % (k, "%.6g" % v, n, "%g" % p, n, k, k, n - k), v)
5 unmodified lines6789101112131415161726 unmodified lines444546474849505152535 unmodified linesfrom __future__ import annotationsimport mathimport reimport statistics as stNUMS = re.compile(r"-?\d+(?:\.\d+)?")def nums_after(t):m = re.search(r"(?:of|for|in|data(?:set)?|numbers|values|list)[:\s]+((?:-?\d+(?:\.\d+)?[,\s]+(?:and\s+)?)+-?\d+(?:\.\d+)?)", t, re.I)return [float(x) for x in NUMS.findall(m.group(1))] if m else None26 unmodified linesv = math.perm(n, k) if k is not None else math.factorial(n)return self._say("permutations", "There are %d ordered arrangements (%s)." % (v, "P(%d, %d)" % (n, k) if k is not None else "%d!" % n), v)# binomial P(X = k)m = re.search(r"\bprobability\b.*?\bexactly (\d+)\b.*?\b(\d+) (?:trials|flips|tosses|rolls|attempts|times)\b.*?\b(?:p|probability of success|chance)\s*(?:=|of|is)?\s*(0?\.\d+|\d+(?:\.\d+)?%)", low)if m:k, n, p = int(m.group(1)), int(m.group(2)), m.group(3)p = float(p.rstrip("%")) / 100 if p.endswith("%") else float(p)v = math.comb(n, k) * p ** k * (1 - p) ** (n - k)return self._say("binomial", "P(X = %d) = %.6g for %d trials with p = %g (C(%d,%d) · p^%d · (1−p)^%d)." % (k, v, n, p, n, k, k, n - k), v)m = re.search(r"\bz[- ]?score\b.*?(-?\d+(?:\.\d+)?)\D+?(?:mean|average|μ)\D*?(-?\d+(?:\.\d+)?)\D+?(?:standard deviation|sd|std|σ)\D*?(\d+(?:\.\d+)?)", low)5 unmodified lines678910111213141516171819202122232425262728293031323334353637383940414243444546474849505126 unmodified lines7879808182838485868788895 unmodified linesfrom __future__ import annotationsimport mathfrom fractions import Fractionimport reimport statistics as st# Consume the complete scalar before converting percent to probability.# In particular, 0.5% is 0.005 and 0.5e-2 is 0.005, never 0.5.PROBABILITY = r"([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(?:\s*%)?)(?![\w%/]|[.,]\d|[+-]|\s*%)"NUMS = re.compile(r"-?\d+(?:\.\d+)?")def probability_value(literal):"""Bind a bounded exact scalar before using the existing float formula.No numerical distribution theorem is claimed. A probability rounded ontoeither endpoint would silently change the stated Bernoulli model, so itis refused. Limits apply before Fraction allocates exponent-sized values."""token = literal.replace(" ", "")if len(token) > 4096:return Nonepercent = token.endswith("%")scalar = token[:-1] if percent else tokenexponent = re.search(r"[eE]([+-]?)(\d+)$", scalar)if exponent:digits = exponent.group(2).lstrip("0") or "0"if len(digits) > 5 or int(digits) > 10000:return Nonetry:exact = Fraction(scalar) / (100 if percent else 1)if not 0 <= exact <= 1:return Nonevalue = float(exact)except (ValueError, OverflowError, ZeroDivisionError):return Noneif not math.isfinite(value) or (exact != 0 and value == 0) or (exact != 1 and value == 1):return Nonereturn valuedef nums_after(t):m = re.search(r"(?:of|for|in|data(?:set)?|numbers|values|list)[:\s]+((?:-?\d+(?:\.\d+)?[,\s]+(?:and\s+)?)+-?\d+(?:\.\d+)?)", t, re.I)return [float(x) for x in NUMS.findall(m.group(1))] if m else None26 unmodified linesv = math.perm(n, k) if k is not None else math.factorial(n)return self._say("permutations", "There are %d ordered arrangements (%s)." % (v, "P(%d, %d)" % (n, k) if k is not None else "%d!" % n), v)# binomial P(X = k)m = re.search(r"\bprobability\b.*?\bexactly (\d+)\b.*?\b(\d+) (?:trials|flips|tosses|rolls|attempts|times)\b.*?\b(?:p|probability of success|chance)\s*(?:=|of|is)?\s*" + PROBABILITY, low)if m:k, n, p = int(m.group(1)), int(m.group(2)), m.group(3)p = probability_value(p)if p is None or k > n:return self._say("impossible", "That isn't a supported binomial setup (need 0 ≤ p ≤ 1, a safely representable p, and k ≤ n).", status="withheld")v = math.comb(n, k) * p ** k * (1 - p) ** (n - k)return self._say("binomial", "P(X = %d) = %.6g for %d trials with p = %g (C(%d,%d) · p^%d · (1−p)^%d)." % (k, v, n, p, n, k, k, n - k), v)m = re.search(r"\bz[- ]?score\b.*?(-?\d+(?:\.\d+)?)\D+?(?:mean|average|μ)\D*?(-?\d+(?:\.\d+)?)\D+?(?:standard deviation|sd|std|σ)\D*?(\d+(?:\.\d+)?)", low)
14 unmodified lines1516171819202122232452 unmodified lines77787980818283848514 unmodified linesfrom fractions import Fractionimport refrom organ_stats_v1 import StatsOrganD = r"(\d+)"P = r"(\d*\.\d+|\d+(?:\.\d+)?\s*%|0|1)"def _kn_choose(low):52 unmodified linesor re.search(r"\bwith (?:a )?(?:probability|chance)\s*(?:of)?\s*" + P, low))if km and nm and pm:k, n, ps = int(km.group(1)), int(nm.group(1)), pm.group(1).replace(" ", "")p = float(ps.rstrip("%")) / 100 if ps.endswith("%") else float(ps)if not 0 <= p <= 1 or k > n:return self._say("impossible", "That isn't a valid binomial setup (need 0 ≤ p ≤ 1 and k ≤ n).", status="withheld")v = math.comb(n, k) * p ** k * (1 - p) ** (n - k)return self._say("binomial", "P(X = %d) = %s for n = %d trials with p = %s (C(%d, %d) p^%d (1 − p)^%d)." % (k, "%.6g" % v, n, "%g" % p, n, k, k, n - k), v)14 unmodified lines1516171819202122232452 unmodified lines77787980818283848514 unmodified linesfrom fractions import Fractionimport refrom organ_stats_v1 import StatsOrgan, PROBABILITY, probability_valueD = r"(\d+)"P = PROBABILITYdef _kn_choose(low):52 unmodified linesor re.search(r"\bwith (?:a )?(?:probability|chance)\s*(?:of)?\s*" + P, low))if km and nm and pm:k, n, ps = int(km.group(1)), int(nm.group(1)), pm.group(1).replace(" ", "")p = probability_value(ps)if p is None or k > n:return self._say("impossible", "That isn't a supported binomial setup (need 0 ≤ p ≤ 1, a safely representable p, and k ≤ n).", status="withheld")v = math.comb(n, k) * p ** k * (1 - p) ** (n - k)return self._say("binomial", "P(X = %d) = %s for n = %d trials with p = %s (C(%d, %d) p^%d (1 − p)^%d)." % (k, "%.6g" % v, n, "%g" % p, n, k, k, n - k), v)
5 unmodified lines6789101112131415161726 unmodified lines444546474849505152535 unmodified linesfrom __future__ import annotationsimport mathimport reimport statistics as stNUMS = re.compile(r"-?\d+(?:\.\d+)?")def nums_after(t):m = re.search(r"(?:of|for|in|data(?:set)?|numbers|values|list)[:\s]+((?:-?\d+(?:\.\d+)?[,\s]+(?:and\s+)?)+-?\d+(?:\.\d+)?)", t, re.I)return [float(x) for x in NUMS.findall(m.group(1))] if m else None26 unmodified linesv = math.perm(n, k) if k is not None else math.factorial(n)return self._say("permutations", "There are %d ordered arrangements (%s)." % (v, "P(%d, %d)" % (n, k) if k is not None else "%d!" % n), v)# binomial P(X = k)m = re.search(r"\bprobability\b.*?\bexactly (\d+)\b.*?\b(\d+) (?:trials|flips|tosses|rolls|attempts|times)\b.*?\b(?:p|probability of success|chance)\s*(?:=|of|is)?\s*(0?\.\d+|\d+(?:\.\d+)?%)", low)if m:k, n, p = int(m.group(1)), int(m.group(2)), m.group(3)p = float(p.rstrip("%")) / 100 if p.endswith("%") else float(p)v = math.comb(n, k) * p ** k * (1 - p) ** (n - k)return self._say("binomial", "P(X = %d) = %.6g for %d trials with p = %g (C(%d,%d) · p^%d · (1−p)^%d)." % (k, v, n, p, n, k, k, n - k), v)m = re.search(r"\bz[- ]?score\b.*?(-?\d+(?:\.\d+)?)\D+?(?:mean|average|μ)\D*?(-?\d+(?:\.\d+)?)\D+?(?:standard deviation|sd|std|σ)\D*?(\d+(?:\.\d+)?)", low)5 unmodified lines678910111213141516171819202122232425262728293031323334353637383940414243444546474849505126 unmodified lines7879808182838485868788895 unmodified linesfrom __future__ import annotationsimport mathfrom fractions import Fractionimport reimport statistics as st# Consume the complete scalar before converting percent to probability.# In particular, 0.5% is 0.005 and 0.5e-2 is 0.005, never 0.5.PROBABILITY = r"([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(?:\s*%)?)(?![\w%/]|[.,]\d|[+-]|\s*%)"NUMS = re.compile(r"-?\d+(?:\.\d+)?")def probability_value(literal):"""Bind a bounded exact scalar before using the existing float formula.No numerical distribution theorem is claimed. A probability rounded ontoeither endpoint would silently change the stated Bernoulli model, so itis refused. Limits apply before Fraction allocates exponent-sized values."""token = literal.replace(" ", "")if len(token) > 4096:return Nonepercent = token.endswith("%")scalar = token[:-1] if percent else tokenexponent = re.search(r"[eE]([+-]?)(\d+)$", scalar)if exponent:digits = exponent.group(2).lstrip("0") or "0"if len(digits) > 5 or int(digits) > 10000:return Nonetry:exact = Fraction(scalar) / (100 if percent else 1)if not 0 <= exact <= 1:return Nonevalue = float(exact)except (ValueError, OverflowError, ZeroDivisionError):return Noneif not math.isfinite(value) or (exact != 0 and value == 0) or (exact != 1 and value == 1):return Nonereturn valuedef nums_after(t):m = re.search(r"(?:of|for|in|data(?:set)?|numbers|values|list)[:\s]+((?:-?\d+(?:\.\d+)?[,\s]+(?:and\s+)?)+-?\d+(?:\.\d+)?)", t, re.I)return [float(x) for x in NUMS.findall(m.group(1))] if m else None26 unmodified linesv = math.perm(n, k) if k is not None else math.factorial(n)return self._say("permutations", "There are %d ordered arrangements (%s)." % (v, "P(%d, %d)" % (n, k) if k is not None else "%d!" % n), v)# binomial P(X = k)m = re.search(r"\bprobability\b.*?\bexactly (\d+)\b.*?\b(\d+) (?:trials|flips|tosses|rolls|attempts|times)\b.*?\b(?:p|probability of success|chance)\s*(?:=|of|is)?\s*" + PROBABILITY, low)if m:k, n, p = int(m.group(1)), int(m.group(2)), m.group(3)p = probability_value(p)if p is None or k > n:return self._say("impossible", "That isn't a supported binomial setup (need 0 ≤ p ≤ 1, a safely representable p, and k ≤ n).", status="withheld")v = math.comb(n, k) * p ** k * (1 - p) ** (n - k)return self._say("binomial", "P(X = %d) = %.6g for %d trials with p = %g (C(%d,%d) · p^%d · (1−p)^%d)." % (k, v, n, p, n, k, k, n - k), v)m = re.search(r"\bz[- ]?score\b.*?(-?\d+(?:\.\d+)?)\D+?(?:mean|average|μ)\D*?(-?\d+(?:\.\d+)?)\D+?(?:standard deviation|sd|std|σ)\D*?(\d+(?:\.\d+)?)", low)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121"""Independent regressions for untrusted Python binomial probability readers.
No verified theorem is claimed. Expected values come from enumerating allBernoulli sequences with exact rational mass, independently of the organ'sclosed-form coefficient formula. Run with ORACLE7_TEST_ROOT pointing to acheckout or python -B -m unittest discover -s tests/statistics."""from fractions import Fractionimport importlibfrom itertools import productimport mathimport osfrom pathlib import Pathimport sysimport unittest
ROOT = Path(os.environ.get('ORACLE7_TEST_ROOT', Path(__file__).resolve().parents[2]))SPECS = [('statistics', 'organ_stats_v1', 'StatsOrgan'), ('statistics-v2', 'organ_stats_v2', 'StatsOrganV2'), ('statistics-v3', 'organ_stats_v3', 'StatsOrganV3')]
def organ(sid, module, cls): for name in ('organ_stats_v1', 'organ_stats_v2', 'organ_stats_v3'): sys.modules.pop(name, None) sys.path.insert(0, str(ROOT/'root/specialists'/sid)) try: return getattr(importlib.import_module(module), cls)() finally: sys.path.pop(0)
def mass(k, n, p): return sum((math.prod(p if bit else 1-p for bit in bits) for bits in product((0, 1), repeat=n) if sum(bits) == k), Fraction())
def question(p, n=2, k=1): return f'What is the probability of exactly {k} successes in {n} trials with p = {p}?'
class BinomialProbabilityBinding(unittest.TestCase): def test_percent_exponent_and_signed_scalar_preserve_probability(self): literals = [('0.5%', Fraction(1, 200)), ('.5%', Fraction(1, 200)), ('0.5 %', Fraction(1, 200)), ('50.0%', Fraction(1, 2)), ('1.5%', Fraction(3, 200)), ('100.0%', Fraction(1)), ('+0.5%', Fraction(1, 200)), ('0.5e-2', Fraction(1, 200)), ('5e-1%', Fraction(1, 200)), ('5E-1%', Fraction(1, 200)), ('0', Fraction()), ('1', Fraction(1)), ('25%', Fraction(1, 4))] for spec in SPECS: instance = organ(*spec) for literal, p in literals: for n in range(0, 6): for k in range(n+1): with self.subTest(spec=spec[0], literal=literal, n=n, k=k): reply = instance.answer(question(literal, n, k)) self.assertIsNotNone(reply) self.assertEqual(reply['status'], 'answered') self.assertAlmostEqual(reply['value'], float(mass(k, n, p)), places=13)
def test_all_probability_role_spellings(self): for spec in SPECS[1:]: instance = organ(*spec) for role in ['p = 0.5%', 'chance of success is 0.5%', 'probability of success on each trial is 0.5%', 'success probability is 0.5%', 'with probability 0.5%']: with self.subTest(spec=spec[0], role=role): reply = instance.answer(f'Probability of exactly 1 success in 2 trials, {role}?') self.assertEqual(reply['status'], 'answered') self.assertAlmostEqual(reply['value'], 0.00995, places=13)
def test_out_of_domain_scalar_is_withheld(self): for spec in SPECS: instance = organ(*spec) for literal in ['-0.5', '-0.5%', '1.01', '101%', '100.1%', '2', '1e2']: with self.subTest(spec=spec[0], literal=literal): reply = instance.answer(question(literal)) self.assertIsNotNone(reply) self.assertEqual(reply['status'], 'withheld')
def test_exact_domain_and_float_endpoint_refusals(self): literals = ['1e-10000', '1e10000', '-1e-10000', '1.000000000000000000000000001', '0.999999999999999999999999999', '100.000000000000000000000001%', '99.9999999999999999999999999%', '1e10001', '1e-10001', '1e999999999999999999999999', '0.' + '0'*4096 + '1'] for spec in SPECS: instance = organ(*spec) for literal in literals: with self.subTest(spec=spec[0], literal=literal[:70]): reply = instance.answer(question(literal)) self.assertIsNotNone(reply) self.assertEqual(reply['status'], 'withheld') # Subnormal but nonzero probabilities remain distinguishable from # the endpoint, and the existing formula can represent this mass. with self.subTest(spec=spec[0], literal='1e-320'): reply = instance.answer(question('1e-320', n=1, k=1)) self.assertIsNotNone(reply) self.assertEqual(reply['status'], 'answered') self.assertGreater(reply['value'], 0) self.assertEqual(reply['value'], float(Fraction(1, 10**320))) for literal in ['0e-10000', '1.000000000000000000000000000', '100.0%']: with self.subTest(spec=spec[0], literal=literal): reply = instance.answer(question(literal, n=1, k=1)) self.assertIsNotNone(reply) self.assertEqual(reply['status'], 'answered')
def test_no_numeric_prefix_for_malformed_or_unsupported_scalar(self): for spec in SPECS: instance = organ(*spec) for literal in ['0.5e', '0.5e-', '0.5.2', '0.5%%', '0.5abc', '0.5/2', '0.5+0.1', '0.5,2', '0.5 % %', '0.5e-2oops']: with self.subTest(spec=spec[0], literal=literal): reply = instance.answer(question(literal)) self.assertTrue(reply is None or reply['status'] == 'withheld', reply)
if __name__ == '__main__': unittest.main()root/specialists/statistics-v2/organ_stats_v1.py+38-2
root/specialists/statistics-v2/organ_stats_v2.py+5-5
root/specialists/statistics-v3/organ_stats_v1.py+38-2
root/specialists/statistics-v3/organ_stats_v2.py+5-5
root/specialists/statistics/organ_stats_v1.py+38-2
tests/statistics/test_binomial_probability_binding.pyAdded+121