[Bug]: experimental-design silently drops a treatment arm when an allocation ratio is fractional

Author: aniruddhaadak80Created Sep 28, 2026Updated Sep 28, 2026

What happened

randomization._normalize_ratio() checks that every allocation-ratio entry is positive, but never that it is an integer, and then builds the block template with int(r), which floors. A fractional ratio therefore degrades silently rather than raising.

_normalize_ratio(["treatment", "control"], (1.5, 1)) -> ['treatment', 'control']
_normalize_ratio(["treatment", "control"], (0.5, 1)) -> ['control']

The second case deletes an arm outright. simple_randomization() derives its assignment probabilities from the template, so probs becomes [0, 1] and every unit is assigned to control:

python
>>> from randomization import simple_randomization
>>> simple_randomization(n=500, arms=("treatment", "control"), ratio=(0.5, 1), seed=0)["arm"].value_counts().to_dict()
{'control': 500}

A 500-subject trial requested at a fractional ratio enrolls zero subjects on treatment and still returns a clean, unremarkable schedule — no warning anywhere. block_randomization collapses the same way: unit falls to 1, so every block contains only the surviving arm.

What you expected instead

A ValueError. The guard's own message already claims ratio entries must be positive integers, and the existing test comment states the intent plainly — "A zero-weight arm would silently vanish from the allocation." A ratio of 0.5 is the same failure arrived at from the other direction, and it was not covered.

Steps to reproduce

  1. uv run --with numpy --with pandas python -c "import sys; sys.path.insert(0, 'skills/experimental-design/scripts'); from randomization import _normalize_ratio, simple_randomization; print(_normalize_ratio(['treatment','control'], (0.5, 1))); print(simple_randomization(n=500, ratio=(0.5, 1), seed=0)['arm'].value_counts().to_dict())"
  2. See ['control'] followed by {'control': 500}, with exit status 0.
  3. Control: a row with fewer fields than the header, or ratio=(1, 0), is refused correctly.

Error output

No traceback — the failure is silent, which is the problem.

Environment

  • Agent host: n/a (ran the script directly)
  • Model: n/a
  • Repository version or commit: 49c6e97 (main)
  • Python version: 3.12.10
  • Operating system: Windows 10

Filed alongside a fix that adds the missing integrality check and a regression test. Whole-number floats (1.0, 2.0) stay valid, since they are integers as values.

Source: K-Dense-AI/scientific-agent-skills