Skip to content

Semeio failing test tests/fmudesign/test_design_distributions.py::test_sample_discrete #793

Description

@xjules

What happened? (You can include a screenshot if it helps explain)

PR semeio test fails

  def test_sample_discrete():
        rng = np.random.default_rng()
    
        outcomes = ["foo", "bar.com"]
        # Test basic functionality
        values = dists.sample_discrete([",".join(outcomes)], rng.uniform(size=10))
        assert all(value in outcomes for value in values)
    
        # Test empty case
        assert not dists.sample_discrete([",".join(outcomes)], np.array([])).size
    
        # Test weighted case where only bar.com should appear
        assert "foo" not in dists.sample_discrete(
            [",".join(outcomes), "0,1"], rng.uniform(size=10)
        )
    
        # Test weights that don't sum to 1
        weighted_values = dists.sample_discrete(
            [",".join(outcomes), "2,6"], rng.uniform(size=100)
        )
        # Should see roughly 25% foo and 75% bar.com
        foo_count = np.sum(weighted_values == "foo")
>       assert 15 <= foo_count <= 35  # Allow some variance due to randomness
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       assert np.int64(39) <= 35

What did you expect to happen?

Test should pass

Steps to reproduce

Example of failing run: https://github.com/equinor/ert/actions/runs/18306935292/job/52126239549?pr=12002

Environment where bug has been observed

  • Python 3.11
  • Python 3.12
  • macOS
  • RHEL8
  • RHEL9
  • Local queue
  • LSF queue
  • Slurm queue
  • OpenPBS queue

Metadata

Metadata

Assignees

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions